[web] Start with a smaller memory allocation for CanvasKit (flutter/engine#56900)

Confirmed that a sample Flutter app starts with a 32MB memory allocation for CanvasKit instead of 128MB.

| Before | After|
|-|-|
| ![image](https://github.com/user-attachments/assets/5f6f2d4d-9155-499e-b20e-a15e3d8b53ab) | ![image](https://github.com/user-attachments/assets/bf1956c4-2d2a-44a8-b781-b110be93bc6a) |

Fixes https://github.com/flutter/flutter/issues/159499

<hr>

Relevant emscripten settings:
- [`INITIAL_MEMORY`](https://emscripten.org/docs/tools_reference/settings_reference.html#initial-memory)
- [`ALLOW_MEMORY_GROWTH`](https://emscripten.org/docs/tools_reference/settings_reference.html#allow-memory-growth)
- [`MEMORY_GROWTH_GEOMETRIC_STEP`](https://emscripten.org/docs/tools_reference/settings_reference.html#memory-growth-geometric-step)
- [`MEMORY_GROWTH_GEOMETRIC_CAP`](https://emscripten.org/docs/tools_reference/settings_reference.html#memory-growth-geometric-cap)
- [`ABORTING_MALLOC`](https://emscripten.org/docs/tools_reference/settings_reference.html#aborting-malloc)

Relevant emscripten code:
- 58889f9f20/src/library.js (L290)
- Emscripten tries to grow memory by the provided growth factor. If it fails, it tries to grow by 50% of that amount. If it fails, it tries 25%. Then it gives up and fails gracefully.
This commit is contained in:
Mouad Debbar 2024-12-04 16:41:50 -05:00 committed by GitHub
parent f5c2897a70
commit 111ba5aae9

View File

@ -170,7 +170,10 @@ canvaskit_wasm_lib("canvaskit") {
"-sFILESYSTEM=0",
"-sMODULARIZE",
"-sNO_EXIT_RUNTIME=1",
"-sINITIAL_MEMORY=128MB",
"-sINITIAL_MEMORY=32MB",
# Grow memory by +100% i.e. double the size each time we run out of memory.
"-sMEMORY_GROWTH_GEOMETRIC_STEP=1.0",
"-sWASM",
"-sSTRICT=1",
]