-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Unexpected "OpenGL ES 3.0 (WebGL 1.0)" reported by glGetString(GL_VER… #13497
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
Conversation
…SION) #13295 In Safari 14 with experimental WebGL 2.0 disabled, canvas.getContext("webgl2") returns NULL first time. However calling the same method after creation of WebGL 1.0 context suddenly returns non-NULL context! This is inconsistent with other browsers and causes Emscripten to misbehave if context creation routines are called multiple times (with intention to re-use existing context).
Thank you for submitting a pull request! If this is your first PR, make sure to add yourself to AUTHORS. |
I don't know much about this stuff, cc @juj @kainino0x |
This is pretty weird, thanks for the fix! Confirmed I'm seeing the bug on Safari 14.0.3 repro'd with cc @kenrussell |
I don't know what the bug could be. Safari 14's code is already quite old. This problem will be completely resolved in the Safari release in which WebGL 2.0 is enabled by default. cc @grorg |
So... the conclusion is waiting for the next Safari release hopefully fixing the issues? |
Ah, sorry - I should have looked more deeply into this. I didn't understand what I was looking at. Unfortunately the bug is still present. It will be masked when WebGL 2.0 is enabled by default in Safari, but fundamentally it's still there. I've filed and taken https://bugs.webkit.org/show_bug.cgi?id=222758 to fix this. In the interim, Emscripten could work around it by checking (carefully, to avoid exceptions for undefined 'WebGL2RenderingContext') the return type of canvas.getContext() in its JavaScript helper libraries and returning null if it's the wrong type for 'webgl' or 'webgl2', but I realize that's pretty gross. Sorry again for not understanding earlier what the bug was. |
That does seem like a more accurate workaround than the one in this PR. IIUC, the current PR just reports back the correct WebGL version (is that right?), but I'm hesitant about that because it would make this return an unexpected value - getting WebGL 1.0 from requesting WebGL 2.0 - that applications probably aren't using but could potentially break on. I guess the question is whether we just want to fix the reporting, or if we want a real workaround. |
Current PR is located within |
@juj hoping you might have thoughts here |
@kenrussell I just happened to look at the Canvas spec: |
Yes, I agree completely. Filed KhronosGroup/WebGL#3256 about clarifying this. |
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.
Per discussion with @juj and @kripken today - I think this isn't the best workaround.
Instead, it would be ideal to filter the results of the getContext
call in a JavaScript shim before returning the result to higher levels.
- If the context type is 'webgl2' and the context is a WebGLRenderingContext, return null.
- If the context type is 'webgl' and the context isn't a WebGLRenderingContext, return null. (This avoids problems where WebGL2RenderingContext might not be defined in the window or worker global scope.)
- Otherwise, return the context.
How does this sound as a general approach?
(In addition, we can still have #defines
in Emscripten which completely ifdef-out WebGL 2.0 support.)
…SION) #13295
In Safari 14 with experimental WebGL 2.0 disabled, canvas.getContext("webgl2") returns NULL first time.
However calling the same method after creation of WebGL 1.0 context suddenly returns non-NULL context!
This is inconsistent with other browsers and causes Emscripten to misbehave
if context creation routines are called multiple times (with intention to re-use existing context).