<?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>290623</bug_id>
          
          <creation_ts>2025-03-28 06:03:16 -0700</creation_ts>
          <short_desc>WebGL context loss on demo.epm.agency</short_desc>
          <delta_ts>2025-11-06 02:55:10 -0800</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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <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="Kimmo Kinnunen">kkinnunen</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>djg</cc>
    
    <cc>karlcow</cc>
    
    <cc>kbr</cc>
    
    <cc>kkinnunen</cc>
    
    <cc>paul.neave</cc>
    
    <cc>robyer1</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2106796</commentid>
    <comment_count>0</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2025-03-28 06:03:16 -0700</bug_when>
    <thetext>Original reporter reports:

I am also finding this issue reproducible in both Safari and also Safari Webview in Flutter InAppWebView on an iPad Pro 6th generation Safari, iPhone 13 mini Safari, Mac Mini M1 MacOS Safari using the following test website built on ThreeJS if you use the red buttons at the top to directly navigate between the two 3D pages, sometimes the context is lost or on dispose of the WebGL context, the new webpage loading can get stuck in a loop of reloading or load a blank page or crash safari.

https://demo.epm.agency/safarikiller2/threejs/main/

Here is a smaller repro page, I have many websites that this issue happens with only when on Safari on iOS. Webview on iOS and Safari on MacOS on all my devices:

iPhone 13 mini
iPad Pro 2020
Mac Mini M1

https://demo.epm.agency/epmpitest/index.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106797</commentid>
    <comment_count>1</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2025-03-28 06:04:58 -0700</bug_when>
    <thetext>Initially I can not reproduce the issue with iOS 18.
To the original reporter:

Can you report, for https://demo.epm.agency/epmpitest/index.html
- which versions of the operating systems you are reproducing this?
- what are the steps to reproduce?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106802</commentid>
    <comment_count>2</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2025-03-28 06:17:17 -0700</bug_when>
    <thetext>I can repro by *Click the hotspots in the sample above to move to the next page, then use the red button at the top to go back to the main page

Seems to be out of memory error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106810</commentid>
    <comment_count>3</comment_count>
    <who name="">robyer1</who>
    <bug_when>2025-03-28 06:54:30 -0700</bug_when>
    <thetext>I couldn&apos;t reproduce it outside of Safari, is there a reason the memory is kept between web pages as the WebGL context is disposed between page loads.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106970</commentid>
    <comment_count>4</comment_count>
    <who name="Kenneth Russell">kbr</who>
    <bug_when>2025-03-28 15:44:43 -0700</bug_when>
    <thetext>Does WebKit watch for destruction of the JavaScript execution context from HTMLCanvasElement and proactively shut down its rendering context? See in Chromium:

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/canvas/html_canvas_element.cc;l=1694?q=HTMLCanvasElement::ContextDestroyed

This helps clean up graphics resources more eagerly than having the JavaScript garbage collector discover the unreachable canvas / rendering context / etc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2107285</commentid>
    <comment_count>5</comment_count>
    <who name="">robyer1</who>
    <bug_when>2025-03-30 15:43:48 -0700</bug_when>
    <thetext>(In reply to Kimmo Kinnunen from comment #2)
&gt; I can repro by *Click the hotspots in the sample above to move to the next
&gt; page, then use the red button at the top to go back to the main page
&gt; 
&gt; Seems to be out of memory error.

If there is anything I can do to debug why the memory isn&apos;t disposed between webpages let me know, both pages I kept the memory footprint small for this repro so I wasn&apos;t expecting memory usage to be high enough to trigger an error.

As Kenneth Russel mentioned, is there any rendering context that is not shut down when navigating between the two pages perhaps? For me the crash is intermittent sometimes I can quickly switch between pages and other times the crash can happen quite soon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2107363</commentid>
    <comment_count>6</comment_count>
    <who name="">robyer1</who>
    <bug_when>2025-03-31 02:42:48 -0700</bug_when>
    <thetext>In Safari Web Inspector Memory Tab linked to Safari on iPhone 13 mini, the page memory starts at 180mb~ then when changing between the hotspot button linked page and back to the main index via the red button at the top and repeating that in a loop, the memory increases up to 338mb and then I can eventually hit &quot;A problem repeatedly occured on...&quot; Black screen crash.

I have WebGL websites with over 500mb or even 800mb page memory usage that can run fine on this phone unless their context is lost via a page change like in this example.

I suspect this is an issue with the memory of the last page not being cleared.

I have another minimal repro here at 

https://demo.epm.agency/memorydemo/index.html

Use the red button at the top to navigate between 2 pages, one is white and one is green. Expected behaviour is that memory from the last webpage is disposed on navigation but what happens is the memory grows until the new webpage loading causes  &quot;A problem repeatedly occured on...&quot; Black screen crash.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2108855</commentid>
    <comment_count>7</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-04-04 06:04:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/148589473&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>