"WebGL: context lost." error when backgrounding Safari on iPadOS 17 Developer Beta 8

On iOS 17 Developer Beta 8 on tablets only (so iPadOS), we are seeing the error "WebGL: context lost." in the Web Inspector Console, after backgrounding Safari that is viewing a WebGL application.

We are utilizing BabylonJS for a 3D rendering application. In some instances, backgrounding the Safari app, then making it active again in the foreground will cause the WebGL canvas to lose context, essentially crashing WebGL for any browser. Sometimes the crash just forces a full page refresh, and sometimes it hard-crashes with the console error, preventing the canvas element from rendering anything and becoming unresponsive. Once affected, any tab in Safari or Google Chrome will have unresponsive canvas elements.

We have tested this with BabylonJS, ThreeJS, and minimal vanilla WebGL code, and each fail. To reproduce the issue, visit any one of the below in Safari: https://playground.babylonjs.com/ https://threejs.org/playground https://codepen.io/haferje/pen/QWzdavd With Web Inspector connected, as the page loads and before the WebGL instance has been initialized, quickly background Safari, then bring it back to the foreground. In the inspector Console, you will see the context lost error, and in Safari you will see that the webgl scene fails to create.

For our applications, this also happens periodically when we background them even after WebGL is already initialized. This error was not present in beta 7.

We are trying to understand why this is happening, so maybe it can be fixed before iOS 17 is released publicly, or we can create a work-around for the issue.

We are seeing the same "WebGL: context lost" issue on iOS 17 Beta 8 Safari when running our Phaser 3 application using WebGL rendering. The issue occurs while loading the page and locking the device and then unlocking again. Any subsequent reload of the page then causes the same "WebGL: context lost" error. The browser cache needs to be cleared before the page would successfully load after the error occurred.

We are also experiencing the same issue using Mapbox

Yesterday we have seen this on our products, which are using the PIXI framework, and also on other various websites using WebGL.

Safari minimzed and restored can't start WebGL context on iOS 17 public release.

Also when the phone is locked and unlocked again. Does not happen always, but very often.

Happens on various phones like iPhone 11, 12, 13. Refreshing web page does NOT help. Killing Safari and restarting fixes it.

This is very critical for us.

Issue still persists after iOS patches. Updating to iOS 17.2 still did not help. WebGL stops working and refreshing the page does not help.

We have also encountered the same problem, which is very serious. Some game players have reported that the game is stuck. The log is related to ""WebGL: context lost"", which only appears in iOS 16.7 and 17, and does not occur in lower versions. It seems that if you open the game in iOS Safari, switch to the background for a few minutes and then come back again, the problem will reappear with a certain probability.

To add on, we are also encountering the same problem with our WebGL game built in Unity. Seems like others in the Unity community are experiencing as well. So it's seemingly like this problem is effecting most WebGL experiences - which seems bad. Would be great to get some update from Apple on this.

I filed a ticket in the WebKit bug tracker here: https://bugs.webkit.org/show_bug.cgi?id=262628

We have also reports from our users regarding our webgl based 3D rendering apps.

https://github.com/OHIF/Viewers/issues/3661

https://github.com/OHIF/Viewers/issues/3693

We also have this issue in a Three.js based application. It is reproducible on iPad running 17.0.3. The only workaround we found was to clear the cache for Safari on the iPad settings, not something that would be practical for users. In our case this can also cause WebGLRenderingContext: getShaderPrecisionFormat() method to return null, presumably due to the lost context. Our logs indicate it may be happening on the newer versions of MacOS as well.

Update, there may be a fix in Safari 17.1.x https://developer.apple.com/documentation/safari-release-notes/safari-17_1-release-notes#WebGL "WebGL Resolved Issues Fixed an issue which would cause unnecessary “WebGL: context lost.” errors after Safari has been moved to the background on iPadOS. (115500744)"

Can we get confirmation from Apple that this fix only applies to iPad? We see this issue on iPhone and it's exactly what the fix seems to address.

This problem also exists in 16.7/16.7.1. There are many users using this version of the system. This problem is fatal and greatly affects the use of iOS safari to render WebGL game applications. Hope you can solve it in iOS 16.

hi, guys Today, I try this issue with the latest iPadOS 16 version 16.7.3 RC. I was not able to reproduce the problem after exiting the background operation state several times. as I know, the iPad 5th and iPad Pro (1th) can upgrade to this version which devices that is restricted from updating to iOS17.1+.

Hi everyone! According to our investigation the issue can be triggered by the usage of the flat qualifier. Bug report for WebKit: https://bugs.webkit.org/show_bug.cgi?id=268071

"WebGL: context lost." error when backgrounding Safari on iPadOS 17 Developer Beta 8
 
 
Q