WebGL builds on iOS keep refreshing or crashing when focus is lost

Hi, our game starts off with around 280MB of memory, it grows up to around 700MB and eventually even reaches 1GB after some time is passed. This works fine on Android and Windows, but on iOS as soon as it goes above, say, 500MB, when I switch to another tab (or another app) and come back, the tab’s reloaded. From there, even if I don’t switch the tab it’ll still reload on the same spot.

This is happening on iPhone 14, and has been reproduced several times, so it’s not random. I’m currently testing with a test build to manually allocate memory and find the exact threshold for this phenomenal, and in the meantime I would appreciate anyone’s experience on this issue and what solutions you went with. Is reducing memory going to make it go away completely? are there some configuration values I can provide to my html file so that the browser doesn’t reload it forcefully?

Thank you

Update: made a test project that lets me allocate memory manually and then I tested opening another app and coming back. it crashed when I was at 280MB. will try again to find out if it was a coincidence. here’s a table of tests:

PlayerSettings.initialMemorySize = 280 | game crashes at around 280MB
PlayerSettings.initialMemorySize = 1000 | game crashes at around 880MB

Other findings:

  • Once game crashes once on Safari, it goes into a loop where it loads the game and the reloads instantly. It doesn’t happen on any other browser or any other platform, just iOS with Safari