In Safari 15, using the gl_FragDepth feature of WebGL 2 in a fragment shader rendering to a framebuffer without a depth attachment, causes all color writes to fail, resulting in a blank screen.
In Chrome and Firefox on both Windows and Android it works correctly.
Minimal repro: https://downloads.scirra.com/labs/bugs/webglfragdepth/
This is a lightly modified version of the fbo_blit example from WebGL 2 samples (http://webglsamples.org/WebGL2Samples/). This example does not use any depth attachment on the FBO. The only meaningful change is the addition of this line to the fragment shader:
gl_FragDepth = 1.0;
This causes all the color writes to fail, producing a blank screen (tested on Safari 15.2 on macOS 12.1 and iPadOS 15.2). However it renders correctly in Chrome/Firefox on Windows/Android. Removing that line causes rendering to work again in Safari. With no depth attachment, it is expected that all writes to gl_FragDepth would simply have no effect. Instead the observed result is that the color writes stop working producing no rendering at all.
We need this to work in our WebGL engine as we want to use some 2D shaders both with and without a depth buffer in use; however in Safari the presence of gl_FragDepth causes all rendering to fail.
> Minimal repro: https://downloads.scirra.com/labs/bugs/webglfragdepth/
Is a red/grey checkerboard a pass or a failure on this test? If it’s a pass, this may be fixed on trunk already.
The correct rendering should match this sample: http://webglsamples.org/WebGL2Samples/#fbo_blit
i.e. if you see a red background with some images, it works.
When it does not work, it's just a black screen with some text at the top.
Thank you. I'm getting black screen with some text at the top on STP 137; and a checkerboard without images on the iOS build that I have installed.
So this doesn't appear to be fixed yet.
Thanks for reporting this; it's a bug in ANGLE's Metal backend. I've filed it upstream against ANGLE as:
Metal: Writing gl_FragDepth without depth attachment disables color writes
We can perhaps prototype a fix in WebKit's copy of ANGLE, but ideally it'll be fixed upstream and just rolled into WebKit to avoid merge conflicts.
The corresponding ANGLE issue is marked fixed, but the issue still reproduces in Safari 15.4 and TP 142. When is it supposed to be fixed?