-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use internal name for Module['canvas']
#21536
base: main
Are you sure you want to change the base?
Conversation
bc32251
to
4b2b61c
Compare
We don't have any code side tests that so canvas stuff but I measured the code size saving locally: Before:
After:
|
In terms of what to call this I decided on |
Instead of referring to this via `Module['canvas']` everywhere we can use the normal `makeModuleReceiveExpr` method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this seems like a good idea! Two concerns though:
- I seem to see missing deps in the first few files. Is it handled in a way I am missing?
- How is existing user code handled? That is, I see some test changes here - will existing user code with
Module['canvas']
break in an unclear way? I think if there is a good error in debug builds it might be ok.
@@ -591,7 +591,7 @@ var emscriptenCpuProfiler = { | |||
}, | |||
|
|||
detectWebGLContext() { | |||
if (Module['canvas']?.GLctxObject?.GLctx) return Module['canvas'].GLctxObject.GLctx; | |||
if (mainCanvas?.GLctxObject?.GLctx) return mainCanvas.GLctxObject.GLctx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not have a __deps
for it?
@@ -358,7 +358,7 @@ var LibraryEGL = { | |||
EGL.contextAttributes.majorVersion = glesContextVersion - 1; // WebGL 1 is GLES 2, WebGL2 is GLES3 | |||
EGL.contextAttributes.minorVersion = 0; | |||
|
|||
EGL.context = GL.createContext(Module['canvas'], EGL.contextAttributes); | |||
EGL.context = GL.createContext(mainCanvas, EGL.contextAttributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__deps
in this file?
There could be some missing ones. I'll take a look. As with all the deps we are kind of reliant here on out test coverage (and review process!) to ensure correctness.
As for existing code that does This means that in practice |
One thing I worry here is that previously the binding to Also, I see previously we have had a couple of places that would assign back to |
Module['canvas'] = GL.offscreenCanvases[data.moduleCanvasId].offscreenCanvas; | ||
Module['canvas'].id = data.moduleCanvasId; | ||
if (!mainCanvas && data.moduleCanvasId && GL.offscreenCanvases[data.moduleCanvasId]) { | ||
mainCanvas = GL.offscreenCanvases[data.moduleCanvasId].offscreenCanvas; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is one such place where if user had existing code that accessed Module['canvas']
, that code would no longer work?
Fwiw I've considered the whole variable Although now reading this PR I see that when using OffscreenCanvas, there is that access to |
Yes, I think you are correct in your assessment here. I guess I will hold off on this change for now then. Marked as draft. |
Pull request was converted to draft
Instead of referring to this via
Module['canvas']
everywhere we can use the normalmakeModuleReceiveExpr
method.