STR: 1. Visit http://clb.confined.space/wasm_grow.html (you can download this for local examination, the file is standalone/self-contained) 2. Click on "new WebAssembly.Memory({ initial: 1 });" button 3. Click on "Grow Wasm" button repeatedly, until "wasm.buffer.byteLength == " field is no longer able to grow. 4. Observe the amount of memory that was possible to be reached. 5. Click on Reload and go to step 2. Observed: On subsequent page reloads, there is less and less memory available for the Wasm heap to grow. E.g. in one such test, max heap went from 768 MB -> 544 MB -> 512 MB on each page reload.
Which version of Safari are you seeing this with? Safari 13 as set in Version field is very old, and thus bugs in it are not relevant unless also happening with the latest version.
This was tested on iPhoneXS on iOS 13.3.1. My apologies for not testing a newer version, but iOS refuses to update itself on my phone. It is stuck in a "Update Available -> Install Update -> Verifying Update -> Unable to Install Update, An error occurred when installing iOS 14.4" sequence when attempting to install iOS 14.4, and I do not have another iOS device to test. Based on reports from this thread https://forum.unity.com/threads/android-chromium-unable-to-grow-allocated-memory-above-256mb-confirmed.1014475/ , and the conversation in this thread, https://github.com/WebAssembly/design/issues/1397 I believe that the issues are still current. However please close if this is not actionable to investigate further. Thanks!
<rdar://problem/74735924>
Still reproduces on the latest iOS 14.5 beta.
I cannot reproduce this on 13.3/M1 Macbook. We always get the full 4.0000 GB. On iOS 16.4, iPhone Xs, I similarly always get 1.9062gb if we ask for it from the beginning. On the other hand, if we ask for a fixed smaller amount, we are often unable to grow the memory. Reloading doesn't seem to matter here, this has more to do with our heap layout. I also get "this page is reloaded because it is using significant memory," even though I have 32gb of ram. We should tune that heuristic.
It is frustrating that this issue still has not been resolved. Reload of our audio editing app triggers this bug. You can test it here: https://goldwave.com/editor. Reloading the page (usually just 2 or 3 times) fails on Safari version 17.2 with a memory range error, but Firefox and Chrome work fine (on non-iOS devices). The error continues for every reload until Safari is terminated.
This issue is even more apparent in iOS 17.3. Our product (https://demo.microblink.com/blinkid-extract) no longer works on iOS 17.3 as any memory allocation request gets denied after an initial size of 200mb. Using a fixed memory size without grow calls can also trigger this issue. If using shared memory, closing the tab won't fix the issue. You need to restart the entire browser.
Additionally, here are my test results using http://clb.confined.space/wasm_grow.html on iOS 17.3: 1. Probing will return 815mb - grow fails 2. Clicking "reload" and probing will then return 0.99gb - grow fails 3. Reloading and allocating 1 page, and pressing grow will error out at only 4mb 4. Doing a page reload, allocating 1 page and then growing errors out at 768mb 5. Reloading page + probe returns 1.4678gb 6. Reloading page + initial size of 524mb fails initial allocation. 7. Reloading + initial size of 384 works. Grow fails. 8. Reloading + initial size of 800mb works. Grow works. 9. Reloading + initial size of 181 mb fails. It's completely unpredictable and therefore unusable in production. Depending on the conditions you can error out at 2gb or at 4mb, asking upfront or growing. This has been an issue for 3 years now and seems to be getting worse.
@Justin & @Yusuke - does Gigacage commit - https://github.com/WebKit/WebKit/commit/416a9ccb3e0c77d9dccdf2d10689ba7c98b1738b will help this?
I am seeing this issue manifest as well, seemingly more often in recent iOS versions (17.4 and 17.5), when testing a barcode scanning library that uses WASM. Only killing Safari resolves the issue.
Created attachment 471670 [details] Screenshot of Instruments memory profile of MobileSafari (iOS 17.5.1) Instruments screenshot of MobileSafari process when issue occurs. On iOS 17.5.1, on an iPhone 15 Pro (MTV63ZD/A) the issue starts happening when memory usage of MobileSafari hits 6.0 GB.
Reproduction repository: https://github.com/pixelverse-llc/safari-wasm-oom-reproducer Repeatedly reloading index.html triggers the issue after an unknown number of refreshes (~a dozen in my experiment)
Created attachment 471697 [details] Reproduction repository; Refresh a dozen or so times and it triggers the OOM condition, and does not recover.
Note: I can not reproduce this issue in the Safari iOS 18 Developer Beta (22A5282m).
I can also no longer reproduce this in Safari on iOS 17.6 Beta.
Thank you for following up!