tkeskita / BVtkNodes

Create and execute VTK pipelines in Blender Node Editor
GNU General Public License v3.0
119 stars 20 forks source link

Freeze of VTK To Blender Volume during animation when frame changes with Update All Automatically selected #114

Open fuvesib opened 3 months ago

fuvesib commented 3 months ago

Occurs with both Blender versions 3.6 LTS and 4.2 LTS.

Steps to reproduce:

According to my testing, it only happens with VTK To Blender Volume and Update All Automatically selected. It does not happen with other nodes like VTK To Blender Mesh and VTK To OpenVDB Exporter, or with other Update Modes.

tkeskita commented 3 months ago

Thanks for the bug report and pull request #115 ! Were you able to find out the actual reason for the freeze? While #115 seems to provide a workaround, I'd prefer to fix the cause of freeze instead of adding new modes, if possible. I'm still trying to figure out the code, it has been a while since I looked at this code..

tkeskita commented 3 months ago

Hmm looks like freeze happens in calling bpy.ops.object.volume_import() https://docs.blender.org/api/current/bpy.ops.object.html#bpy.ops.object.volume_import

fuvesib commented 3 months ago

Yes, it happens at bpy.ops.object.volume_import() Something similar is reported in issue #17 but the Blender bug report mentioned there is solved since then. I tried using bpy.ops.object.volume_import() and frame_change_pre() together in a small separate script, which worked fine. I also tried commenting out bpy.ops.object.volume_import() part (so objects are deleted, volume.vdb file is written but not loaded), which worked fine. And using bpy.ops.object.volume_import() with just frame_change_post() (the workaround with the new mode in my pull request) works fine as well according to my testing. So I suspect the issue is caused by the combination of bpy.ops.object.volume_import(), frame_change_post(), and depsgraph_update_post(). However, I don't fully understand the structuring of on_frame_change() and on_depsgraph_update() in init.py file so I didn't continue the investigation.

tkeskita commented 3 months ago

Thanks for clarifications. This feels like a bug in volume_import(), but I'll try to check this out better later on..

tkeskita commented 3 months ago

Ok yes, I think I see. Apparently deleting volume object triggers depsgraph update (and not the volume_import()), thereby the forever loop..

Related to use of Blender application handlers

tkeskita commented 3 months ago

Hey I committed something that should fix this issue, could you please test on your end? Thanks!