Skip to content

Workaround Safari WebGL issue: After successfully acquiring WebGL con… #13659

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

Merged
merged 2 commits into from
Mar 17, 2021

Conversation

juj
Copy link
Collaborator

@juj juj commented Mar 15, 2021

…text on a canvas, calling .getContext() will always return that context independent of which 'webgl' or 'webgl2' context version was passed. See https://bugs.webkit.org/show_bug.cgi?id=222758. Fixes #13295

…text on a canvas, calling .getContext() will always return that context independent of which 'webgl' or 'webgl2' context version was passed. See https://bugs.webkit.org/show_bug.cgi?id=222758. Fixes emscripten-core#13295
@juj juj force-pushed the workaround_safari_getcontext_bug branch from 92471c3 to 7d9e154 Compare March 15, 2021 10:40
canvas.getContextSafariWebGL2Fixed = canvas.getContext;
canvas.getContext = function(ver, attrs) {
var gl = canvas.getContextSafariWebGL2Fixed(ver, attrs);
return ((ver == 'webgl') == (gl instanceof WebGLRenderingContext)) && gl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this end up returning "false" for getContext if this fails, rather than null? I'd suggest writing this more clearly with if-statements.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised if that matters, but sure, adjusted to return null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected "OpenGL ES 3.0 (WebGL 1.0)" reported by glGetString(GL_VERSION)
3 participants