Maniphest T96394

Regression: Missing update in custom Nodetree
Closed, Archived

Assigned To
None
Authored By
Gregory (Apofis)
Mar 13 2022, 11:17 AM
Tags
  • BF Blender
  • Nodes & Physics
  • Python API
Subscribers
Gregory (Apofis)
Jacques Lucke (JacquesLucke)
Pratik Borhade (PratikPB2123)

Description

System Information
Operating system: Windows-10-10.0.19042-SP0 64 Bits
Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 461.40

Blender Version
Broken: version: 3.1.0, current master
Affected by rB7e712b2d6a0d257d272ed35622b41d06274af8df

Short description of error
If create custom node tree with name "CustomNodeTree" and try update node tree by script: bpy.data.node_groups["CustomNodeTree"].interface_update(bpy.context) - tree not updated. In version Blender 3.0 function works good

Exact steps for others to reproduce the error

  1. Download archive batch_render_nodes.zip
  2. Install zip-archive add-on in Blender 3.0 and Blender 3.1
  3. Download test file Batch_Render_Nodes_UPDATE_TREE_TEST.blend
  1. Open test file in Blender 3.0
  2. Try change sockets values
  3. Sockets output values updated
  1. Open same test file in Blender 3.1
  2. Try change sockets values
  3. Sockets output values not updated

For update sockets and all node tree i used function https://docs.blender.org/api/current/bpy.types.NodeTree.html#bpy.types.NodeTree.interface_update


3.0.03.1.0

Related Objects

Mentioned Here
P2851 (An Untitled Masterwork)
rB7e712b2d6a0d: Nodes: refactor node tree update handling

Event Timeline

Gregory (Apofis) created this task.Mar 13 2022, 11:17 AM
Pratik Borhade (PratikPB2123) added a subscriber: Pratik Borhade (PratikPB2123).Mar 21 2022, 7:12 AM
Pratik Borhade (PratikPB2123) changed the task status from Needs Triage to Needs Information from User.Mar 21 2022, 7:40 AM

Create custom node tree by python

Hi, thanks for the report. You mean using default python template?

I don't think I understand steps for reproducing the problem. Are you using custom script? Can you attach that?
Also, please test again on latest 3.2 build: https://builder.blender.org/download/daily/
Similar reports I have seen where responsible commit was rB7e712b2d6a0d257d272ed35622b41d06274af8df

Gregory (Apofis) added a comment.EditedMar 23 2022, 8:12 PM
In T96394#1326520, @Pratik Borhade (PratikPB2123) wrote:

Create custom node tree by python

Hi, thanks for the report. You mean using default python template?

I don't think I understand steps for reproducing the problem. Are you using custom script? Can you attach that?
Also, please test again on latest 3.2 build: https://builder.blender.org/download/daily/
Similar reports I have seen where responsible commit was rB7e712b2d6a0d257d272ed35622b41d06274af8df

Thanks!

I codding add-on for batch rendering using node trees.
Steps:

  1. Download archive batch_render_nodes.zip
  2. Install zip-archive add-on in Blender 3.0 and Blender 3.1

3.Download test file Batch_Render_Nodes_UPDATE_TREE_TEST.blend

  1. Open test file Batch_Render_Nodes_UPDATE_TREE_TEST.blend in Blender 3.0
  2. Try change sockets values
  3. Sockets output values updated
  1. Open test file Batch_Render_Nodes_UPDATE_TREE_TEST.blend in Blender 3.1
  2. Try change sockets values
  3. Sockets output values not updated

I try Blender 3.2. Sockets output information also not updated

For update sockets and all node tree i used function https://docs.blender.org/api/current/bpy.types.NodeTree.html#bpy.types.NodeTree.interface_update

Also i upload screen videocapture

Pratik Borhade (PratikPB2123) changed the task status from Needs Information from User to Confirmed.Mar 24 2022, 3:39 AM
Pratik Borhade (PratikPB2123) added projects: Nodes & Physics, Python API.
Pratik Borhade (PratikPB2123) added a subscriber: Jacques Lucke (JacquesLucke).

Thank you for the information :)
I can confirm now. This is got affected after the same commit. This one- rB7e712b2d6a0d257d272ed35622b41d06274af8df
@Jacques Lucke (JacquesLucke) ^

Pratik Borhade (PratikPB2123) renamed this task from Function - interface_update(context) - from class NodeTree not work in Blender 3.1 to Regression: Missing update in custom Nodetree.Mar 24 2022, 3:43 AM
Pratik Borhade (PratikPB2123) updated the task description.
Pratik Borhade (PratikPB2123) updated the task description.
Jacques Lucke (JacquesLucke) added a comment.Mar 24 2022, 11:50 AM

I'm not 100%, but right now this does not feel like a bug in Blender to me.

It seems like you expect Blender to call the update method on every node when you call interface_update. However, there is no reason why it should do that. interface_update is a method that was supposed to be called to force an update when the inputs or outputs of a node group changed. However, Blender never calls this function itself anymore, so maybe it should even be removed.

From what I can tell, the current update-logic in the addon is very brittle. This is also shown by the fact that you always call interface_update three times, so that data can propagate for three nodes. This might give the illusion that it works, but is still unreliable when there are longer chains of nodes.

A short term fix would be to just call node.update() for all the nodes manually.

@persistent
def updateNodeTreeTimerThread():

        for tree in bpy.data.node_groups:
            if tree.bl_idname == 'BatchNodesTree':
                for _ in range(3):
                    for node in tree.nodes:
                        node.update()

In addition you might have to loop over the different area/regions in the Blender UI and call tag_redraw on them.
For a more complete example see P2851.

I highly recommend you to implement a system that gives you control over when and in what order nodes are executed.

Gregory (Apofis) added a comment.EditedApr 6 2022, 1:32 PM
In T96394#1329178, @Jacques Lucke (JacquesLucke) wrote:

I'm not 100%, but right now this does not feel like a bug in Blender to me.

It seems like you expect Blender to call the update method on every node when you call interface_update. However, there is no reason why it should do that. interface_update is a method that was supposed to be called to force an update when the inputs or outputs of a node group changed. However, Blender never calls this function itself anymore, so maybe it should even be removed.

From what I can tell, the current update-logic in the addon is very brittle. This is also shown by the fact that you always call interface_update three times, so that data can propagate for three nodes. This might give the illusion that it works, but is still unreliable when there are longer chains of nodes.

A short term fix would be to just call node.update() for all the nodes manually.

@persistent
def updateNodeTreeTimerThread():

        for tree in bpy.data.node_groups:
            if tree.bl_idname == 'BatchNodesTree':
                for _ in range(3):
                    for node in tree.nodes:
                        node.update()

In addition you might have to loop over the different area/regions in the Blender UI and call tag_redraw on them.
For a more complete example see P2851.

I highly recommend you to implement a system that gives you control over when and in what order nodes are executed.

Thanks !I have updated the code, thanks to your advice. Update nodes works

Jacques Lucke (JacquesLucke) closed this task as Archived.Apr 7 2022, 2:14 PM