Bug 269777 - Only ~300 MB of RAM is reliably available to WebAssembly pages
Summary: Only ~300 MB of RAM is reliably available to WebAssembly pages
Status: RESOLVED DUPLICATE of bug 269937
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebAssembly (show other bugs)
Version: Safari 17
Hardware: iPhone / iPad iOS 17
: P2 Critical
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 221530
  Show dependency treegraph
 
Reported: 2024-02-20 01:27 PST by jujjyl
Modified: 2024-02-22 12:36 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jujjyl 2024-02-20 01:27:08 PST
STR:

1. Visit the web site http://clb.confined.space/dump/mem_growth.html
2. Repeatedly click on Allocate Memory until all memory is exhausted.

3. Observe that on the first visit, it seems that the page is able to allocate about ~1GB of RAM before being exhausted.

4. Reload the page by clicking on the reload icon.

5. Again, repeatedly click on Allocate Memory until all memory is exhausted.

6. Observe that this time the page is only able to allocate up to ~300MB - ~500MB of RAM.

when testing this multiple times, on an iPhone Xs I had one occasion where only 28MB of RAM was able to be acquired after a page reload.

Expected:
1. The test page should be able to allocate up to 4GB of RAM for WebAssembly, which is the maximum memory limit for Wasm at the time being. (see Chrome)
2. The available amount of RAM to WebAssembly should not drastically shrink after a back-to-back page reload of the test page. (1GB -> 300MB -> 28MB available.. did the previous page not get fully garbage collected?)

Tested on:
 - iPhone Xs MT9G2FS/A iOS 17.0.3 (64GB, 4GB of RAM)
 - iPad Pro 12.9 inch 3rd Generation MTEL2KN/A iOS 17.2 (Model A1876 64GB, 4GB of RAM)
 - iPhone 12 with iOS 17.3.1 (4GB of RAM)
 - iPhone 14 Pro with iOS 17.3.1 (6GB of RAM)

As another data point, testing out the same page on Xiaomi Redmi Note 10 5G, the cheapest mobile phone sold on Finnish phone stores in 2021 for Android gaming for kids for 129€, has 5GB of RAM, and reliably acquires 4GB in Chrome 121 across each page reload.

Unity has recently rolled out 2GB -> 4GB memory expansion support for Unity WebAssembly builds, which has led to an increased amount of bug reports from web developers testing the feature out on iOS devices, and realizing they are not able to allocate even 1/10th of the memory on wasm pages on iOS compared to Android Chrome.

There is also a related earlier bug report at https://bugs.webkit.org/show_bug.cgi?id=221530 , which is also seen in this context: sometimes iOS force-reloads the page when it does not agree to how much memory a web page should be allowed(?) to use, leading to Unity customers complaining that Safari "crashes" when attempting to run Unity content.

This is a showstopper for shipping Unity content on the web for Safari, so marking this issue tentatively Critical.
Comment 1 Kenneth Russell 2024-02-20 11:49:54 PST
Same test case as Bug 221530, but has more info about Unity's use case and the impact; hope this can be investigated in order to make WebAssembly apps more powerful.
Comment 2 Radar WebKit Bug Importer 2024-02-22 12:07:53 PST
<rdar://problem/123461736>
Comment 3 Justin Michaud 2024-02-22 12:36:33 PST

*** This bug has been marked as a duplicate of bug 269937 ***