VTK WASM with Threading enabled: Rendering not possible in main thread?

Hi all,

in my VTK WASM app, I recently wanted to explore whether rendering can be accelerated by turning on threading. My plan was to keep rendering in the main thread, just to make it faster for multi-threaded rendering algorithms (like vtkCutter). However, when not setting -sPROXY_TO_PTHREAD=1, the console shows an error “Tried to spawn a new thread, but the thread pool is exhausted.” when invoking the rendering pipeline.

When setting PROXY_TO_PTHREAD and OFFSCREENCANVAS_SUPPORT to 1, the problem does not occur, even though I would think the number of available threads is the same (actually in both cases, vtkSMPTools::GetEstimatedDefaultNumberOfThreads() called at the beginning of main() returns 4. The problem with moving rendering to an own thread, besides the need to proxy all related embind calls to the rendering thread, is the following: I need to change the canvas size from time to time with JavaScript, but this does not seem to be possible with an offscreen canvas (the problem has been posted here javascript - Is it possible to resize a canvas after transferControlToOffscreen() in wasm? - Stack Overflow).

Are there any hints what I can do to keep rendering in the main thread while still being able to use threading for acceleration? And if not, what I can do to change the offscreen canvas size later with JavaScript?

Thanks,

Sophonet