We have a very lightweight Unity game that we’ve been running pretty successfully on mobile web. That said, we’ve just run into a pretty show-stopping issue with iOS 17 Safari. The game will work totally fine on iOS 17 Safari - but then after some combination of backgrounding, using other sites and other apps (not totally sure the exact repo) - it errors with:
“WebGL: context lost”
At this point, no matter how many times I refresh, I will always get this error. Force quiting browser and event reseting the device doesn’t seem to recover it. I’ve also tried to do different combos of compressed builds - and nothing seems to work. The one thing that does recover is clearing the safari cache.
To the best of my knowledge that’s right. We got reports of this from two users who preemptively upgraded to iOS 17. Myself, I’ve used iOS 16 extensively with the game and never encountered. I upgraded to reproduce and was able to within 10 minutes of upgrading.
It’s also worth noting that this doesn’t seem to be an issue with Chrome on iOS 17. I haven’t been able to reproduce the problem there.
We have also encountered the same problem, which is very serious. Some 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 Safari, switch to the background for a few minutes and then come back again, the problem will reappear with a certain probability.
Would you be able to directly raise bug reports to https://bugs.webkit.org/ to highlight the issue to Safari? If you have multiple/different bug reports, independently reporting them can give a sense of urgency for a “many different authors are hitting this regression” feedback.
Do you have any ideas to potentially work around this problem? We’re trying to figure out a stop gap solution assuming it doesn’t get fixed - and curious if you have any thoughts on paths to explore.
Hi! Just wanted to mention that we also seem to be running into this issue with WebGL apps on Safari 17 and 17.1 beta for our WebGL app running on macOS. Safari almost immediately spits out “WebGL: context lost” in the console once the app loads.
Our app is privately accessed, but here’s a public app we found that has the same issue https://beatsaver.com/ to reproduce the issue hit the Play icon next to any of the songs to get the WebGL app to open (which will almost immediately lose its WebGL context)
Not sure if this is the same issue other folks are seeing on iOS, but the issue was not fixed for us in the Safari 17.1 beta on macOS.
In any case, even if not sure if there already exists a WebKit bug, I recommend opening bugs specifically about your own web sites in case any of the already reported symptoms don’t match (e.g. supposed to be fixed by 17.1, but issue still persists)
I updated my M1 Mac Mini to latest version yesterday and played around with a couple of Unity WebGL builds there. I was not able to reproduce the issue in those tests at least.
One evolution on our end - and possibly a pretty logical one. We had “Run in Background” enabled in our project for no good reason (outside of that I think it’s by default enabled). Disabling “Run in Background” seemingly avoids this error for us. Note, if you are in the state (let’s say with a different build that has it in enabled) - the disabled run in background won’t recover you from the state. But it does seem to prevent you from getting in it.
Some other learnings for us:
My confident repro was open our game in 5 tabs in safari. Background, go to YouTube and watch about 3-5 YouTube Shorts - back to safari and it would be in the context lost error.
In our repro, force quitting Safari and reopening always recovers (seems like others who were having this issue, this wasn’t the case). Not clear cache also recovers as well.
Thanks MasterControlProgram, really good to know. We’ve also got “Run in Background” enabled and were suspecting it to be related to the issue - I might try disabling it too to see if that resolves the issue. We do need that setting on though, our app takes a while to sync some content so we want to let the user leave the tab and have it keep syncing.
It also seems like the app at https://beatsaver.com/ that I linked before has “Run in Background” enabled (in Chrome on macOS, I can navigate to a different tab and the app keeps playing sound)
bbridgesvb - with some more testing today with real users it seems like we still see it but it’s much harder to repo. So unfortunately, might not be solved with just that and aligns with your beatsaver comment.
bbridgesvb - Actually curious. You mentioned that you’re able to repro on MacOSX in 17.1. Have you tried testing on 17.1 iOS? Curious if you can repro on mobile.
I used my iPhone here to see if iOS 17.1 does not reappear. You can also try again to see if it reappears.
But there are definitely problems with 16.7/16.7.1. Many users will stay on the last version of 16, worrying that there will be no fixes in the future(Because all previous issue tickets were marked with iOS 17 and were in the resolved state).
It is recommended that you file a new issue to urge them to fix iOS 16.
I just raised a new issue, you can also raise it separately. This problem is too fatal. If it is not fixed, there will be many players reporting problems in iOS16 in the future. https://bugs.webkit.org/show_bug.cgi?id=263103
MasterControlProgram sorry I went on vacation - I haven’t tested anything on iOS, our WebGL app isn’t offered on mobile. If I get a chance to update one of my mobile test devices and test I’ll let you know though my findings.
We got information from WebKit contributors that it looks like the issue would be present in iOS Safari 16.6-16.7.2 (which is the latest 16.7.x version atm) branch, without a current fix, and it is present in iOS Safari 17.0 branch, but fixed in iOS 17.1.
WebKit developers are aware that iOS 16.7.2 still has the issue - although reporting it upstream with your project certainly won’t hurt, to get the visibility of when it does get fixed.
Also, I got validation that the above observation of disabling “Run In Background” should indeed successfully mitigate the issue for Safari, since the Metal rendering queue would likely fail when Safari is attempting to do the rendering while on background.