Skip to content

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

Merged
juj merged 2 commits into
emscripten-core:mainfrom
juj:workaround_safari_getcontext_bug
Mar 17, 2021
Merged

Workaround Safari WebGL issue: After successfully acquiring WebGL con…#13659
juj merged 2 commits into
emscripten-core:mainfrom
juj:workaround_safari_getcontext_bug

Conversation

@juj

@juj juj commented Mar 15, 2021

Copy link
Copy Markdown
Collaborator

…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
Comment thread src/library_webgl.js Outdated
canvas.getContextSafariWebGL2Fixed = canvas.getContext;
canvas.getContext = function(ver, attrs) {
var gl = canvas.getContextSafariWebGL2Fixed(ver, attrs);
return ((ver == 'webgl') == (gl instanceof WebGLRenderingContext)) && gl;

Copy link
Copy Markdown
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
Copy Markdown
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