GPencil: Crash when opening a file that has a gpencil data block with layer transforms #96216

Closed
opened 2022-03-07 13:12:53 +01:00 by Falk David · 13 comments
Member

System Information
Operating system: Linux-5.15.23-76051523-generic-x86_64-with-glibc2.34 64 Bits
Graphics card: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.54

Blender Version
Broken: version: 3.2.0 Alpha, branch: master
Worked: 3.1

Caused by 7ca13eef7c

Short description of error
Blender crashes on opening a file that was saved with layer transforms.

Exact steps for others to reproduce the error

  • Open Blender with the 2D Animation template.
  • Change the layer transform in the object data properties panel under "Transform".

Save the file and reopen it -> Blender crashes.

or

Open test file -> Blender crashes.

gpencil-orig-pointers-bug.blend

Investigation

The crash occurs when a grease pencil data-block is expanded for the first time and then tries to access the gpf->runtime.gpf_orig pointer in copy_frame_to_eval_cb from BKE_gpencil_prepare_eval_data. That pointer is NULL.

This is because in deg_update_copy_on_write_datablock when we do a copy on write, we only call BKE_gpencil_data_update_orig_pointers in GPencilBackup::restore_to_gpencil if a backup has been created. But RuntimeBackup::init_from_id returns early if deg_copy_on_write_is_expanded is false.

Maybe the solution is to add some logic to update_id_after_copy to make sure the runtime orig pointers are updated.

**System Information** Operating system: Linux-5.15.23-76051523-generic-x86_64-with-glibc2.34 64 Bits Graphics card: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.54 **Blender Version** Broken: version: 3.2.0 Alpha, branch: master Worked: 3.1 Caused by 7ca13eef7c **Short description of error** Blender crashes on opening a file that was saved with layer transforms. **Exact steps for others to reproduce the error** - Open Blender with the 2D Animation template. - Change the layer transform in the object data properties panel under "Transform". # Save the file and reopen it -> Blender crashes. or # Open test file -> Blender crashes. [gpencil-orig-pointers-bug.blend](https://archive.blender.org/developer/F12900604/gpencil-orig-pointers-bug.blend) **Investigation** The crash occurs when a grease pencil data-block is expanded for the first time and then tries to access the `gpf->runtime.gpf_orig` pointer in `copy_frame_to_eval_cb` from `BKE_gpencil_prepare_eval_data`. That pointer is `NULL`. This is because in `deg_update_copy_on_write_datablock` when we do a copy on write, we only call `BKE_gpencil_data_update_orig_pointers` in `GPencilBackup::restore_to_gpencil` if a backup has been created. But `RuntimeBackup::init_from_id` returns early if `deg_copy_on_write_is_expanded` is false. Maybe the solution is to add some logic to `update_id_after_copy` to make sure the runtime orig pointers are updated.
Author
Member

Added subscriber: @filedescriptor

Added subscriber: @filedescriptor
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Cannot repro here.

**System Information**
Operating system: Linux-5.13.0-0.rc6.45.fc35.x86_64-x86_64-with-glibc2.34.9000 64 Bits
Graphics card: NVIDIA GeForce GTX 970M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 495.44
version: 3.2.0 Alpha, branch: master, commit date: 2022-03-07 06:49, hash: `rBad2948face07`
Cannot repro here. ``` **System Information** Operating system: Linux-5.13.0-0.rc6.45.fc35.x86_64-x86_64-with-glibc2.34.9000 64 Bits Graphics card: NVIDIA GeForce GTX 970M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 495.44 version: 3.2.0 Alpha, branch: master, commit date: 2022-03-07 06:49, hash: `rBad2948face07` ```
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Can confirm now, will bisect

Can confirm now, will bisect
Member

Caused by 7ca13eef7c

Caused by 7ca13eef7c
Author
Member

Quick fix hack:

diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 6346bab1fe8..414f031ece4 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -41,6 +41,7 @@
 - include "DNA_ID.h"
 - include "DNA_anim_types.h"
 #include "DNA_armature_types.h"
+#include "DNA_gpencil_types.h"
 - include "DNA_mesh_types.h"
 - include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
@@ -733,6 +734,14 @@ void update_id_after_copy(const Depsgraph *depsgraph,
       scene_setup_view_layers_after_remap(depsgraph, id_node, reinterpret_cast<Scene *>(id_cow));
       break;
     }
+    case ID_GD: {
+      bGPdata *gpd_cow = (bGPdata *)id_cow;
+      bGPDlayer *gpl = (bGPDlayer *)(gpd_cow->layers.first);
+      if (gpl != NULL && gpl->runtime.gpl_orig == NULL) {
+        BKE_gpencil_data_update_orig_pointers((bGPdata *)id_orig, gpd_cow);
+      }
+      break;
+    }
     default:
       break;
   }
Quick fix hack: ``` diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 6346bab1fe8..414f031ece4 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -41,6 +41,7 @@ - include "DNA_ID.h" - include "DNA_anim_types.h" #include "DNA_armature_types.h" +#include "DNA_gpencil_types.h" - include "DNA_mesh_types.h" - include "DNA_modifier_types.h" #include "DNA_object_types.h" @@ -733,6 +734,14 @@ void update_id_after_copy(const Depsgraph *depsgraph, scene_setup_view_layers_after_remap(depsgraph, id_node, reinterpret_cast<Scene *>(id_cow)); break; } + case ID_GD: { + bGPdata *gpd_cow = (bGPdata *)id_cow; + bGPDlayer *gpl = (bGPDlayer *)(gpd_cow->layers.first); + if (gpl != NULL && gpl->runtime.gpl_orig == NULL) { + BKE_gpencil_data_update_orig_pointers((bGPdata *)id_orig, gpd_cow); + } + break; + } default: break; } ```

Added subscriber: @Sergey

Added subscriber: @Sergey

If the datablock was not copied yet, there is nothing to be backed up from it. So this part of the logic seems to be working as intended.

@filedescriptor, your proposed patch looks good and safe.

If the datablock was not copied yet, there is nothing to be backed up from it. So this part of the logic seems to be working as intended. @filedescriptor, your proposed patch looks good and safe.
Author
Member

Fixed by 21d633f83b but we might want to look into a cleaner solution.

Fixed by 21d633f83b but we might want to look into a cleaner solution.
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Philipp Oeser self-assigned this 2022-03-08 11:19:05 +01:00
Member

OK, will close then.

OK, will close then.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#96216
No description provided.