Replies: 1 comment
-
This can be closed - I have learned that it is not possible to detect when canvases are rendered by the main thread after the have been transferred to an offscreen canvas. This is done asynchronously and there is no mechanism to subscribe. I have also learned that emscripten supports transferring DOM canvases to offscreen (mentioned in html5 doc) - this is not possible with Offscreen Canvases that have been created on the main thread. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
instead of creating multiple "heavy" WebGL-contexts in my app I am using a single hidden
<canvas id="canvas">
as the rendering target and copy corresponding parts of it to on-screen, non-GL canvases using context2d.drawImage() after each rendering pass. In non-threading mode, this works fine.However, with pthread and offscreen canvases turned on, the hidden
<canvas>
in the DOM is actually not needed (I could also copy from the offscreen canvas directly but do not know how to get hold of it, since context2d.drawImage() is called in the main thread, and findCanvasEventTarget("#canvas") in the main thread returns the DOM canvas, not the offscreen one). Furthermore, after a rendering pass the hidden canvas does not yet contain the rendered image, this gets updated later after my rendering function in an event callback has ended and control is back at the main thread - and I would not know how to hook into it and copy the canvas later. Since the specs of OffscreenCanvas specify that DOM-canvases that have been transferred to offscreen have to do updates only in the next main event loop, I guess the best approach would be to pass an offscreen canvas to the emscripten Module before initialization, but that currently is not supported (when creating an offscreen canvas and passing it as "canvas" member to the Module, there is an error that the browser does not support OffscreenCanvases).Any ideas or suggestion for a good approach?
Thanks,
Sophonet
Beta Was this translation helpful? Give feedback.
All reactions