Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fuvesib opened this issue Jul 20, 2024 · 6 comments

Comments

@fuvesib
Copy link

fuvesib commented Jul 20, 2024

Occurs with both Blender versions 3.6 LTS and 4.2 LTS.

Steps to reproduce:

  • Open Blender
  • Go to BVTK Node Tree
  • In Tree, Examples add cubeflow_openvdb_export
  • In Inspect, Update Mode select Update All Automatically
  • Change the frame

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

fuvesib commented Jul 21, 2024

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
Copy link
Owner

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

@tkeskita
Copy link
Owner

tkeskita commented Aug 4, 2024

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 added a commit that referenced this issue Aug 4, 2024
- Added a guard variable volume_import_is_running to detect a
  special case in VTK to Blender Volume node, where deletion
  of old volume object triggers a depsgraph update in the middle
  of the update process. This caused infinite loop in frame change
  when Update All Automatically Update Mode was applied.
- Added also a guard variable on_depsgraph_update_is_running,
  although currently it seems not necessary. Consider it as a
  kind of extra safety feature for now. The Blender update handlers
  seem to be called often, and sometimes in quite surprising cases.
@tkeskita
Copy link
Owner

tkeskita commented Aug 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants