emscripten-core / emscripten-core/emscripten

Chrome passes browser.test_sdl2_canvas_proxy, but should actually fail

Open
#25,438 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Debugging the failure of `browser.test_sdl2_canvas_proxy` in Firefox, it turns out that Chrome is behaving in a nonstandard manner in its WebGL2 implementation, which hides a SDL2 Emscripten port bug, and causes the test to accidentally pass.

In Firefox the test fails as is correct, unmasking the SDL2 bug.

Reported the Chrome bug in https://issues.chromium.org/issues/448407149

What is happening is that SDL2 attempts to compile the following fragment shader:

```
#extension GL_OES_EGL_image_external : require

#define mediump
#define highp
#define lowp
#define SDL_TEXCOORD_PRECISION

uniform samplerExternalOES u_texture;
varying mediump vec4 v_color;
varying SDL_TEXCOORD_PRECISION vec2 v_texCoord;

void main()
{
gl_FragColor = texture2D(u_texture, v_texCoord);
gl_FragColor *= v_color;
}
```

but `GL_OES_EGL_image_external` is not a ratified WebGL extension, and `samplerExternalOES` is not a valid keyword in WebGL. I.e. SDL2 is leaking a native EGL+OpenGLES2/3 extension shader into WebGL.

Still, Chrome happily compiles and links the above shader. That shader doesn't do anything in the `browser.test_sdl2_canvas_proxy`, it just is getting compiled in by SDL2, but never activated (it is not part of the test)

Firefox croaks on the above unrecognized shader, and because `browser.test_sdl2_canvas_proxy` is testing the ancient asynchronously proxied WebGL support, then there is this code in the proxying implementation:

```
43: { name: 'getShaderParameter', func: () => {assert(ctx.getShaderParameter(objects[buffer[i++]], buffer[i++]), 'we cannot handle errors, we are async proxied WebGL') },
```

which assert-fails in Firefox, as it should. Chrome is silently passing past since it compiled the shader.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.