Open JoeOsborn opened 2 hours ago
findCanvasEventTarget
has a similar bug, in that it will sometimes return a key from GL.offscreenCanvases, sometimes return an element from GL.offscreenCanvases, and sometimes return an arbitrary HTML element. It should always return something of a reasonable type, whether or not offscreen canvas support is enabled. (In particular it does not make sense for it to sometimes return an element of GL.offscreenCanvases and sometimes an HTML element.)
If client code asks for explicit swap control, a transferred canvas record is obtained from
GL.offscreenCanvases
, but then that record (and not the underlying OffscreenCanvas) is passed through toGL.createContext
, which expects an actual offscreen canvas. The fix is to add....offscreenCanvas || ....canvas
on the end of line 174, or else to change the code ofemscripten_webgl_do_create_context
to unpack the canvas.https://github.com/emscripten-core/emscripten/blob/5203d0805881ac4daf841e08cb320b1885b01cfb/src/library_html5_webgl.js#L174