Bug 268071

Summary: The usage of flat qualifier breaks the WebGL context in Safari
Product: WebKit Reporter: Daniel Eke <endanke>
Component: WebGLAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ahmad.saleem792, dino, kbr, kkinnunen, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: iPhone / iPad   
OS: Unspecified   

Daniel Eke
Reported 2024-01-25 03:03:51 PST
We have run into a regression regarding the usage of the "flat" storage qualifier in GLSL shaders, which causes the browser to lose the WebGL context across several tabs. This breaks rendering of any further WebGL content and to recover, the browser needs to be force-closed and opened again. The issue was reproducible in Safari on multiple iPad models (MK2K3KN/A and MQDW2TY/A) on one iPhone model (MT9G2ZD/A) and across different iOS versions (16.3.1 and 17.3). On desktop environment we were unable to reproduce it. The exact conditions are not clear, as the browser can render some frames before it loses the context, but usually it happens within a couple of seconds. As a minimal example, we've set the following property in a vertex shader: flat out float v_test; ... v_test = 1.0; And accessed it in the fragment shader similar to: flat in float v_test; ... float alpha = v_test; glFragColor = vec4(1.0, 1.0, 1.0, alpha); The repeated usage of these shaders breaks the context in a couple of seconds.
Attachments
Kimmo Kinnunen
Comment 1 2024-01-25 10:55:34 PST
To confirm: - What does "these shaders breaks the context in a couple of seconds"? Is it WebGL context lost or crash? If I'm reading correctly, it's context lost. If you can share a minimal example, that would be good. In case your flat shading algorithm does not care which vertex provokes the values, please see https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/ to fix your issue.
Kimmo Kinnunen
Comment 2 2024-01-25 10:55:56 PST
possibly fix.
Daniel Eke
Comment 3 2024-01-25 12:35:48 PST
It means GL context lost, which we saw in the logs in some cases. In other cases it just manifests by stopping the rendering and turning the target surface to blank, without any additional logs. I'm working on a self-contained example. It turns out just the usage of "flat" is not enough, but it's definitely required to produce the problem. Thanks for the linked example, I'll take a look.
Ahmad Saleem
Comment 4 2024-01-25 18:05:34 PST
*** This bug has been marked as a duplicate of bug 268070 ***
Ahmad Saleem
Comment 5 2024-01-25 18:06:06 PST
Apologise! Wanted to mark other way around.
Ahmad Saleem
Comment 6 2024-01-25 18:06:17 PST
*** Bug 268070 has been marked as a duplicate of this bug. ***
Daniel Eke
Comment 7 2024-01-25 21:04:48 PST
Oh excuse me, apparently I sent the form twice accidentally. Thanks for noticing the duplication.
Radar WebKit Bug Importer
Comment 8 2024-02-01 03:04:13 PST
Kimmo Kinnunen
Comment 9 2024-08-30 06:23:21 PDT
Marking this fixed in bug 272023 e38cf95a58 Metal: Release prov. vertex buffers on event set If this persists, please reopen. *** This bug has been marked as a duplicate of bug 272023 ***
Kimmo Kinnunen
Comment 10 2024-08-30 06:25:53 PDT
iOS 18 beta macOS 15 Beta Sequoia Safari Technology Preview (macOS)
Note You need to log in before you can comment on or make changes to this bug.