Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

OffscreenRenderer render_to_image cause crashing on jupyter notebook

Open pnchuyen opened this issue 1 year ago • 2 comments

Checklist

My Question

I tried to get the perspective projected image of a mesh in a TensorFlow Dataset generator by using OffscreenRenderer render_to_image. I can add the mesh to the render. But when I call render_to_image, the Jupyter Notebook kernel appears to have died with this message (class utils::PreconditionPanic in struct utils::JobSystem::ThreadState &__cdecl utils::JobSystem::getState(void) noexcept:228 reason: This thread has not been adopted.). Please refer below image for the error: image Does anyone have any ideas to fix it? Thank you very much!

pnchuyen avatar Feb 01 '24 04:02 pnchuyen

Think I'm running into the same issue. #4437 seems to be related. Did you ever find a solution?

ndahn avatar Sep 05 '24 16:09 ndahn

My setup is as follows: I have a GUI where widgets can be generated dynamically. I noticed that my 3d viewport works when created for the test setup, but not when manually created by the user. It turns out that the open3d stuff needs to be instantiated on the main thread (it's probably documented somewhere...). Once I moved the instantiation into my main loop (via a worker queue) everything works as expected.

ndahn avatar Sep 05 '24 17:09 ndahn

@ndahn what does that look like on a jupyter notebook? should it not use the main thread by default?

RomanStadlhuber avatar Jan 22 '25 13:01 RomanStadlhuber

In my case I didn't use a jupyter notebook. I am writing a GUI which uses the Open3D OffscreenRenderer to render scenes and then forward the result to my display buffer. I use dearpygui as my framework which - as many GUIs - runs on the main thread and has user interactions come in from a separate thread.

My code loads some of the heavier dependencies (like Open3D) on widget creation instead of when the module is loaded. So when the user triggered something that would load Open3D it would run and initialize everything on the user thread, then fail with the above error message. I was able to solve this by delegating widget creation to the main thread.

Is it possible to initialize the OffscreenRenderer from a different thread? If so I couldn't find the documentation. Otherwise I think it's also fine, but a slightly more helpful error message could help avoid confusion :)

ndahn avatar Jan 22 '25 17:01 ndahn