"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.

Post not yet marked as solved Up vote post of MarxentQA1 Down vote post of MarxentQA1
3.7k views
  • 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.

Add a Comment

Replies

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.

  • I have posted to 3 different Apple reporting sites and have yet to hear anything back. Considering iOS 17 is due for public release soon, we were hoping someone with more low-level knowledge of the WebGL system may have come across this issue as well, or may have some indication of a fix/workaround.

    I have seen some promise in disabling any code that interacts with our Babylon engine, when the Safari window is backgrounded, but it seems to more mitigate the issue than resolve it.

  • @MarxentQA1 if you have any new infomation,please update here. we meet the same problem.

  • Looks like 17.1 has a fix according to the comments below.

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.

  • We are also experiencing exactly same issue with our App and it became really challenging to bring customers on iOS17. Hope we get fix for this ASAP.

  • We are also facing similar issues for an application that uses https://www.marzipano.net/. I hope Apple fixes this quickly.

Add a Comment

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: It also seems to be possible to work around in some cases by closing the Safari app by double tapping the home key and swiping it away.

Add a Comment

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)"

  • we are still experiencing same issue in our app with 17.1 beta 4 release where you need to clear cache when experiencing crash or app freezing issue. Issue seems to be not addressed yet.

  • The problem persists, particularly on iPads, although it's occurring less frequently, we're still encountering it. The current method to simulate it is quite straightforward: start and stop the specific WebGL application on the device around 5 to 10 times. Eventually, the WebGL won't initialize.

Add a Comment

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.

  • Same for us. We are seeing this issue appear for iOS versions 16.7 and above on iPhone. Apple please confirm that the fix will be in the next iOS version not just iPadOS.

Add a Comment

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