Dynamic node declarations don't update reliably #106732

Closed
opened 2023-04-09 10:14:46 +02:00 by Lukas Tönne · 0 comments
Member

Dynamic node declarations are intended for nodes whose socket layout changes based on settings or external dependencies. Currently their only use is in node groups, future uses will include "zone" nodes such as the simulation zone.

Generating sockets based on dynamic declarations crashes easily because the general update function nodeDeclarationEnsure expect sockets to match the declaration in certain code paths, which defeats the purpose of dynamic declarations.

For example: copying a node into a different node tree may invalidate a reference, such as the output_node_id of simulation input nodes. This will cause the declaration to be cleared, while the node sockets remain unchanged. An operator like clipboard.paste will then call nodeDeclarationEnsure which crashes in update_socket_declarations.

During node tree updates the update_node_declaration_and_sockets is used to also modify the socket lists to match dynamic declarations. However, this update happens at the end of operators, where node declarations may already have been updated and crashed.

nodeDeclarationEnsure update_socket_declarations
image image
  • nodeDeclarationEnsure should run refresh_node after a build_node_declaration_dynamic. This will update sockets if they don't match the declaration.
  • Optional: Have a way to detect declaration changes, so nodeDeclarationEnsure can run a dynamic update. Currently it only runs dynamic updates once when the declaration is null. Dynamic nodes rely on operators calling update_socket_declarations explicitly to redo the declaration.
Dynamic node declarations are intended for nodes whose socket layout changes based on settings or external dependencies. Currently their only use is in node groups, future uses will include "zone" nodes such as the [simulation zone](https://code.blender.org/2022/11/geometry-nodes-workshop-2022/#simulation). Generating sockets based on dynamic declarations crashes easily because the general update function `nodeDeclarationEnsure` expect sockets to match the declaration in certain code paths, which defeats the purpose of dynamic declarations. For example: copying a node into a different node tree may invalidate a reference, such as the [`output_node_id`](https://projects.blender.org/blender/blender/src/commit/e665a50fb6364142198d0b8cff44b0730709e4bc/source/blender/makesdna/DNA_node_types.h#L1606) of simulation input nodes. This will cause the declaration [to be cleared](https://projects.blender.org/blender/blender/src/branch/geometry-nodes-simulation/source/blender/nodes/geometry/nodes/node_geo_simulation_input.cc#L104-L122), while the node sockets remain unchanged. An operator like `clipboard.paste` will then [call `nodeDeclarationEnsure`](https://projects.blender.org/blender/blender/src/commit/e665a50fb6364142198d0b8cff44b0730709e4bc/source/blender/editors/space_node/clipboard.cc#L241) which crashes in [`update_socket_declarations`](https://projects.blender.org/blender/blender/src/commit/e665a50fb6364142198d0b8cff44b0730709e4bc/source/blender/blenkernel/intern/node.cc#L3641). During node tree updates the `update_node_declaration_and_sockets` is used to also modify the socket lists to match dynamic declarations. However, this update happens at the end of operators, where node declarations may already have been updated and crashed. |`nodeDeclarationEnsure`|`update_socket_declarations`| |---|---| |![image](/attachments/69b8f27f-dbe1-41ee-8b92-d8851886f64f)|![image](/attachments/318c7f9c-f7eb-416f-afad-a4b4d45ef7f9)| - [ ] `nodeDeclarationEnsure` should run `refresh_node` after a `build_node_declaration_dynamic`. This will update sockets if they don't match the declaration. - [ ] Optional: Have a way to detect declaration changes, so `nodeDeclarationEnsure` can run a dynamic update. Currently it only runs dynamic updates once when the declaration is null. Dynamic nodes rely on operators calling `update_socket_declarations` explicitly to redo the declaration.
Lukas Tönne added the
Type
To Do
label 2023-04-09 10:14:46 +02:00
Lukas Tönne added this to the Nodes & Physics project 2023-04-09 10:14:47 +02:00
Blender Bot added the
Status
Resolved
label 2023-04-17 16:11:11 +02:00
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 Assignees
1 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#106732
No description provided.