It looks like Safari's page history navigation stack retains old WebAssembly compiled pages in memory, and is unable to release them on demand on memory pressure when visiting a new page with wasm content, but instead Safari OOMs due to running out of executable memory to compile WebAssembly. (this is only a hypothesis, alternative is that the old Wasm compiled pages genuinely memory leak Wasm code memory?) STR: 1. Visit https://connect.unity.com/p/kart-mobile-1-0-6?loadingMobile=1 2. Click on Play. 3. Click OK when seeing the dialog that mobile is not yet supported in Unity. 4. When seeing the [Name Your Game] dialog, reload the page and go to step 2. After some 2-3 reloads, the page is unable to load, but fails in WebAssembly compilation stage with error message [Error] failed to asynchronously prepare wasm: Error: Out of executable memory in function at index 13067 o (commons.631d1802c56e56ea3106.bundle.js:1:368842) printErr (UnityLoader.js:4:11151) (anonymous function) (blob:https://connect.unity3dusercontent.com/698c33ac-6d65-4875-89b4-ec8bdfddc8b4:8:31284) promiseReactionJob It has observed that smaller WebAssembly modules enable more refreshes until hitting this OOM. E.g. this page https://connect.unity.com/p/kart-template-oz?loadingMobile=1 contains the same content as in the STR link URL in step 1, but optimized for size rather than speed, and that OOMs as well, but needs more page refreshes for it to happen. Tested to reproduce on iPhone 11 Pro Max on iOS 13.3.
For reference, the size of the .wasm file in https://connect.unity.com/p/kart-mobile-1-0-6?loadingMobile=1 is 21,478,291 bytes, whereas the size of the .wasm file in https://connect.unity.com/p/kart-template-oz?loadingMobile=1 is 5,305,089 bytes.
Ops, posted wrong size for the kart-template-oz figure (that was the gzipped size on disk). The correct size for .wasm module in https://connect.unity.com/p/kart-template-oz?loadingMobile=1 is 18,140,743 bytes. So 3,337,548 bytes smaller uncompressed compared to wasm module in kart-mobile-1-0-6 url.
<rdar://problem/58634092>
Hi there, thanks for the report! I think what was happening was that the Unity wasm module was using a very large amount of memory just to launch and the GC couldn't collect the old module's JIT memory fast enough during a reload. This appears to have been fixed by the new Wasm interpreter. Also, the game seems to launch dramatically faster (<1-2s vs 30+sec).
Hey, this is great! Any info on which iOS/Safari version would first have the fix? I'd love to verify that the issue no longer reproes. In addition to the above links failing, it has been reported that https://tiny.vision/demos/TinyRacing/Wasm/TinyRacing.html would also fail to run. That page is an order of magnitude smaller compared to the Kart mobile web page in comment 0.
The fix should have shipped with Safari 13.1 in MacOS 10.15.4 and iOS 13.4.