<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>268071</bug_id>
          
          <creation_ts>2024-01-25 03:03:51 -0800</creation_ts>
          <short_desc>The usage of flat qualifier breaks the WebGL context in Safari</short_desc>
          <delta_ts>2024-08-30 06:25:53 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebGL</component>
          <version>Other</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>272023</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Daniel Eke">endanke</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>dino</cc>
    
    <cc>kbr</cc>
    
    <cc>kkinnunen</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2007509</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel Eke">endanke</who>
    <bug_when>2024-01-25 03:03:51 -0800</bug_when>
    <thetext>We have run into a regression regarding the usage of the &quot;flat&quot; 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&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007620</commentid>
    <comment_count>1</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2024-01-25 10:55:34 -0800</bug_when>
    <thetext>To confirm:
- What does &quot;these shaders breaks the context in a couple of seconds&quot;? Is it WebGL context lost or crash? If I&apos;m reading correctly, it&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007621</commentid>
    <comment_count>2</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2024-01-25 10:55:56 -0800</bug_when>
    <thetext>possibly fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007652</commentid>
    <comment_count>3</comment_count>
    <who name="Daniel Eke">endanke</who>
    <bug_when>2024-01-25 12:35:48 -0800</bug_when>
    <thetext>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&apos;m working on a self-contained example. It turns out just the usage of &quot;flat&quot; is not enough, but it&apos;s definitely required to produce the problem.

Thanks for the linked example, I&apos;ll take a look.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007792</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-01-25 18:05:34 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 268070 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007794</commentid>
    <comment_count>5</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-01-25 18:06:06 -0800</bug_when>
    <thetext>Apologise! Wanted to mark other way around.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007796</commentid>
    <comment_count>6</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-01-25 18:06:17 -0800</bug_when>
    <thetext>*** Bug 268070 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007836</commentid>
    <comment_count>7</comment_count>
    <who name="Daniel Eke">endanke</who>
    <bug_when>2024-01-25 21:04:48 -0800</bug_when>
    <thetext>Oh excuse me, apparently I sent the form twice accidentally. Thanks for noticing the duplication.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2009672</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-02-01 03:04:13 -0800</bug_when>
    <thetext>&lt;rdar://problem/122083140&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2056536</commentid>
    <comment_count>9</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2024-08-30 06:23:21 -0700</bug_when>
    <thetext>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 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2056538</commentid>
    <comment_count>10</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2024-08-30 06:25:53 -0700</bug_when>
    <thetext>iOS 18 beta
macOS 15 Beta Sequoia
Safari Technology Preview (macOS)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>