WebGL game crashing on iOS device

Hi,

I created this thread one week ago, but it got taken down, because I posted on the wrong forum.

I am looking for any advice or direction to solving this issue.

I can’t figure out why WebGL game keeps crashing on our iOS device. I searched trough forum and google for a solution and couldn’t quite pinpoint the reason for crashing.

Game crashes both during loading/instantiating addressables and while playing the game. Safari shortly displays “This webpage was reloaded because a problem occurred” and then the website refreshes.
WebGL game doesn’t crash on Android or newer iPhone device.

Details:

  • iPhone 8
  • iOS 16.3.1
  • Unity 2021.3.18f1
  • WebGL 2
  • Color space - Linear

We used memory profiler and exported results to Unity 2022 version for more data. It uses around 250MB, up to 300MB.

We also tested with Web inspector and Mac device. These are the screenshots:

Another issue that could be connected with my problem are pixelated shadows. This issue is also present on newer iPhones. Disabling “WebGL via Metal” solves this. Android doesn’t have this problem.

8908254--1219470--upload_2023-3-28_9-27-44.png

The good news is that Apple recently fixed a Webkit bug that was causing our applications to crash and that fix landed in: 16.4 beta 3
https://bugs.webkit.org/show_bug.cgi?id=248768
The bad news is you’ll have to update your iOS version. Sadly there’s not much we can do about this from our side.

Same issue on iPhone 14 Pro, iOS 17.3.1. Also crash happens when loading addressables.

we’re looking into this, thank you for sharing.

@sinedsem would you mind sharing a build that shows the crash? we’re having a hard time reproducing the problem consistently in some of our projects that use addressables.

Hi, I’m experiencing the same issue on an iOS device. I’m using Unity 2022.3.19f1 and iOS 17.2.1 on an iPhone 13 and iPhone 14 Pro max.

Here is my build: https://thientm27.github.io/Vitural-Tour-WebGL/
GitHub repository: https://github.com/thientm27/Vitural-Tour-WebGL

Initially, I was using only one scene. When I open it on iOS, I encounter an error after the loading screen. I tried placing an empty scene before my main scene and loading the main scene after a delay of 1 second, but the error still occurs. In some instances, iOS manages to load my main scene and operate normally, but this is not consistent.

Android and Windows platforms, as well as an iPhone 7 Plus running iOS 15.8.2, run smoothly without any issues.

9735091--1392139--1fdd8199-171e-47c9-be38-d0c21e143d97.jpg

Update:
I’ve tried numerous methods to fix the issue, such as switching to WebGL 1, changing project settings, continuously building and testing with various fixes, but none of them worked, consuming an entire day of troubleshooting.

However, the good news is that when I used Unity 6 beta versions to build, the product seemed to run fairly smoothly on iOS. So far, no errors have occurred, and I hope this solution can help others

@denkhotieu We tested your build on iOS 17.3.1 and it never crashed :face_with_spiral_eyes: We’re still looking for a project that reliably crashes!

This crash issue occurs when I adjust the image at 2048 level; when I adjust it to 1024, everything operates fairly well. The problem here is that the crash seems to only appear in newer versions of iOS. I’m also not sure if this is an issue with GitHub or my build version. I really hope you can take a look at it.

I have rebuilt my product’s crash and deployed it here.

Git page: https://thientm27.github.io/Vitural-Tour-WebGL-Develop/
Git repo: https://github.com/thientm27/Vitural-Tour-WebGL-Develop

Here’s videos of me testing the application on my iPhone 7 and iPhone 13

IP 7: https://youtube.com/shorts/qibgsWXZkhk
IP 13: https://youtube.com/shorts/kejzPQJyfpA

@denkhotieu could you please open a bug report, so that our customer QA team can take over testing this on different devices/iOS versions and we can get a concrete repro?

1 Like

additionally, since we haven’t been able to reproduce the crash on iOS 17.4.1, can you upgrade to the latest iOS version on your iPhone 13 to see if it happens there?

1 Like

@unityruba

Hello,
We’ve recently received complaints about WebGL crashes on our end as well. The issue occurs when the game reaches a midway point, where the screen freezes. Currently, we suspect it’s a problem related to how iOS handles WebGL image memory. Android users haven’t reported any similar issues.

In the game, we utilize addressable assets to load images with resolutions including 2048, 1024, 512, 256, 128, and 64. Should we suggest updating their iOS version at this point?

Model: iPhone11,6 Unity Version: 2021.3.8f1

Yes this seems like an issue that I’m experiencing when I attempt to load certain scenes. I get the same error. Sometimes increasing the Initial memory allocation can help in the first instance but seems like something doesn’t get cleaned up from memory and it just delays the crash until the next time.

Makes me wonder what I’m doing wrong but works fine on Android and desktop browsers. My suspicion is a memory limitation or something.
Unity 2023.2.11f1, iOS 17.4.1, iPhone SE(3rd Gen), iPhone 12, older iPad Mini

This issue only occurs with iOS users,
and it is suspected to be related to the use of IndexedDB within WebGL.

Sounds plausible. Are you aware of any workarounds?

Maybe because 2021 is ancient
“Unity 2021.3 is now the legacy LTS. It will be updated monthly until it reaches the end of its support cycle in mid-2024.”
https://unity.com/releases/editor/qa/lts-releases

Why are you still using 2021 for web???

For what it’s worth, I’ve tried projects built in Unity 2021.3.24f1, 2022.3.7f1, 2022.3.16f1, 6000.0.0b13 & 6000.0.0b15 on both iOS 17.3-17.5b4 (iPhone 13 Pro) & Android 12-14 (Nokia 6.1); and none have worked reliably on iOS. No matter the build configuration, or utilisation of addressables, I’ve found that projects will work up until they use a certain amount of memory (whether this is while the wasm & initial data is still loading, or during runtime). In my most recent project on 2022.3.16f1, we utilise addressables to keep our initial download times low. This project will load to our bootstrapping scene just fine, but exhibit this crashing behaviour while it is downloading additional scenes and resources.

If the issue is with the use of IndexedDB, is it possible to enable/disable the use of IndexedDB depending on the browser the build is running on?

This depends on a variety of factors and can be solved quite easily:

  • What error message does browser give upon crash

  • What is the console printing before / right before crash

  • What’s your final build size

  • How big are your addressables

  • Whats your max texture size

  • What texture compression format are you using

Addressables are good to keep initial download size down, but if they are absorbing all your very limited memory your going to have crashes.

https://blog.unity.com/engine-platform/web-runtime-updates-enhance-browser-experience
“In Unity 6, you will be able to enable 4GB memory support. This enables bigger real-time 3D experiences on the web, making use of the larger memory available to desktop browsers. In the future”

Might want to switch over workflow to prepare for Unity 6. 4GB for web games is everyone’s dream come true

Well I was able to reduce the occurrence of this issue for me by really cutting back on the texture memory burden in the asset bundle I was loading, and increasing the starting heap size to 512MB. Not gone completely but the theory about heap resizing kind of has a bid more cred IMO

I thought Unity 6 finally officially supports mobile WebGL. But I’m still crashing on iOS Safari due to memory. We’ve reduced our app to use very little textures and it still is very unstable.
Device logs show highwater killing it due to memory pressure. Doesn’t happen all the time, but I can get it to happen regularly enough. Only iOS safari!

50733.283 memorystatus: killing_highwater_process pid 7700 [com.apple.WebKit.WebContent] (highwater 100) 1807222KB - memorystatus_available_pages: 148247 compressor_size:167001

1 Like