owl-project / NVISII

Apache License 2.0
327 stars 28 forks source link

ViSII locks up when rendering to image while pre-render callback is set. #84

Closed natevm closed 3 years ago

natevm commented 3 years ago

Something to do with GIL...

natevm commented 3 years ago

The issue here was that Python locks GIL when calling functions like visii.render, which wait for the renderer to render out an image. Simultaneously, the renderer waits to ensure GIL if the callback is set. This causes deadlock. Unfortunately, it isn't so trivial to fix this issue.

I've implemented a workaround, where if the user calls a function that would otherwise wait on the renderer, if the callback is currently set, I instead throw an error to avoid the deadlock. In that error message, it's instructed to the user that they should either temporarily clear the callback, or alternatively call the function from within the callback.

Later on down the road, we could implement some non-blocking render call, and use python to periodically check if the render is complete without necessarily locking up GIL. For the mean time though, the above workaround seems to work alright.