Gpencil: Geometry nodes instance on points with GP crash on last keyframe delete #125866

Closed
opened 2024-08-04 16:28:21 +02:00 by Aleš Jelovčan · 4 comments

System Information
Operating system: Windows-10-10.0.22631-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 4090 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 537.32

Blender Version
Broken: version: 4.3.0 Alpha, branch: main, commit date: 2024-08-03 09:19, hash: e6178be3b855
Worked: (newest version of Blender that worked as expected)

Short description of error
If GPv3 is used as a Points input in instance on points, Blender will crash when last frame is deleted

image

Exact steps for others to reproduce the error
Delete keyframe in attached file

**System Information** Operating system: Windows-10-10.0.22631-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 4090 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 537.32 **Blender Version** Broken: version: 4.3.0 Alpha, branch: main, commit date: 2024-08-03 09:19, hash: `e6178be3b855` Worked: (newest version of Blender that worked as expected) **Short description of error** If GPv3 is used as a Points input in instance on points, Blender will crash when last frame is deleted <img width="569" alt="image" src="attachments/fd5b5671-1caf-4992-b424-a0e1466cbb07"> **Exact steps for others to reproduce the error** Delete keyframe in attached file
Aleš Jelovčan added the
Type
Report
Status
Needs Triage
Severity
Normal
labels 2024-08-04 16:28:22 +02:00
Member

Looks pretty complex for me...

What I can see is that the custom data layer will have a null anonymous_id_ which I have no idea what's causing it...

Looks pretty complex for me... What I can see is that the custom data layer will have a null `anonymous_id_` which I have no idea what's causing it...
YimingWu added
Module
Grease Pencil
Status
Confirmed
and removed
Status
Needs Triage
labels 2024-08-05 06:51:13 +02:00
Member

Prefer if crashes are always High priority

Prefer if crashes are always High priority
Philipp Oeser added
Severity
High
and removed
Severity
Normal
labels 2024-08-05 09:20:46 +02:00
Member

It seems the bke::Instances data is actually null after deleting the keyframe (the component exists but the internal pointer is null). The same happens if i just move the keyframe instead of deleting it. This data should be created in advance, not sure what is going on.

It seems the `bke::Instances` data is actually null after deleting the keyframe (the component exists but the internal pointer is null). The same happens if i just _move_ the keyframe instead of deleting it. This data should be created in advance, not sure what is going on.
Member

The issue is that the code assumes a valid InstancesComponent pointer when it transfers attributes from layers to instances.

GeometrySet::propagate_attributes_from_layer_to_instances(
geometry_set.get_grease_pencil()->attributes(),
geometry_set.get_instances_for_write()->attributes_for_write(),
propagation_info);

But geometry_set.get_instances_for_write() can return a nullptr even if the component exists (which is ensured by the code above).

InstancesComponent &instances_component =
geometry_set.get_component_for_write<InstancesComponent>();
bke::Instances *dst_instances = instances_component.get_for_write();
if (dst_instances == nullptr) {
dst_instances = new bke::Instances();
instances_component.replace(dst_instances);

This is because the GeometrySet::get_component_ptr function checks GeometrySet::has(type) which in turn checks both component.has_value() and component->is_empty():

return component.has_value() && !component->is_empty();

So the fix is to simply check if the instance component "exists" before accessing it:

-      GeometrySet::propagate_attributes_from_layer_to_instances(
-          geometry_set.get_grease_pencil()->attributes(),
-          geometry_set.get_instances_for_write()->attributes_for_write(),
-          propagation_info);
+      if (geometry_set.has_instances()) {
+        GeometrySet::propagate_attributes_from_layer_to_instances(
+            geometry_set.get_grease_pencil()->attributes(),
+            geometry_set.get_instances_for_write()->attributes_for_write(),
+            propagation_info);
+      }

The is_empty check here does not make sense to me (but probably has to stay because it's everywhere now). Getting a pointer to the instances geometry should not be contingent on the component having an actual instance (IMO). I guess we just have to live with that.

The issue is that the code assumes a valid `InstancesComponent` pointer when it transfers attributes from layers to instances. https://projects.blender.org/blender/blender/src/commit/e981389bddb1e5b79b30c296edba63ceb22a6942/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc#L257-L260 But `geometry_set.get_instances_for_write()` can return a nullptr __even if the component exists__ (which is ensured by the code above). https://projects.blender.org/blender/blender/src/commit/e981389bddb1e5b79b30c296edba63ceb22a6942/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc#L193-L198 This is because the `GeometrySet::get_component_ptr` function checks `GeometrySet::has(type)` which in turn checks both `component.has_value()` and `component->is_empty()`: https://projects.blender.org/blender/blender/src/commit/e981389bddb1e5b79b30c296edba63ceb22a6942/source/blender/blenkernel/intern/geometry_set.cc#L152 So the fix is to simply check if the instance component "exists" before accessing it: ```diff - GeometrySet::propagate_attributes_from_layer_to_instances( - geometry_set.get_grease_pencil()->attributes(), - geometry_set.get_instances_for_write()->attributes_for_write(), - propagation_info); + if (geometry_set.has_instances()) { + GeometrySet::propagate_attributes_from_layer_to_instances( + geometry_set.get_grease_pencil()->attributes(), + geometry_set.get_instances_for_write()->attributes_for_write(), + propagation_info); + } ``` The `is_empty` check here does not make sense to me (but probably has to stay because it's everywhere now). Getting a pointer to the instances geometry should not be contingent on the component having an actual instance (IMO). I guess we just have to live with that.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-08-05 12:15:21 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#125866
No description provided.