Kitware/vtk-js

[Feature] Rendering with OffscreenCanvas

neo15201788751 opened this issue · 3 comments

Feature Request

Add RenderWindow which supporting OffscreenCanvas

Motivation and Detailed Description

It is easy to produce bad performance with rendering in main execution thread only,
OffscreenCanvas inside a worker context could be helpful.

I made a branch named offscreen-canvas-demo in my fork to show that with very few changes, it is possible to use an OffscreenCanvas
It is based on #3051
It doesn't use WebWorkers though
The example uses a single WebGL context (from the offscreen canvas) to do all the rendering and calls drawImage to draw to the "normal" canvases that you can see

Use npm run example ManyRenderWindows to start the example

Thanks, But OffscreenCanvas inside main thread can not help.

This branch is just to show that it is possible to use an offscreen canvas with the OpenGL render window with just a few changes
There is still work to do, you will have for example to:

  • create a canvas, call transferControlToOffscreen() on it and send it to the web worker
  • create the VTK rendering pipeline in the web worker
  • find a way to send the events to the interactor (maybe through a proxy)