[stable] Cherry-pick change to CanvasKit build flags to fix double download (#164341)

## Stable Cherry Pick

Cherry-picks https://github.com/flutter/flutter/pull/162198 to stable to fix issue with double-downloading CanvasKit. 

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

Impacted Users: All Flutter Web users
Impact Description: `canvaskit.wasm` (a roughly 5 MB download) is double-downloaded. While some browsers may retrieve the second request from the cache, not all do.
Workaround: None
Risk: Low (a small change to the BUILD flags for CanvasKit that prevents `canvaskit.wasm` from being downloaded twice)
Test Coverage: We don't have a test that checks how many requests there are for `canvaskit.wasm`
Validation Steps: Build and run any Flutter Web app and check the network requests to see that `canvaskit.wasm` is only requested once.
This commit is contained in:
Harry Terkelsen 2025-03-07 09:56:19 -08:00 committed by GitHub
parent 09de023485
commit bfcf486a89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 8 deletions

View File

@ -24,8 +24,11 @@ docs/releases/Hotfix-Documentation-Best-Practices.md
INTERNAL NOTE
-->
## Flutter 3.29 Changes
## Flutter 3.29.1 Changes
### [3.29.2](https://github.com/flutter/flutter/releases/tag/3.29.2)
- [flutter/162198](https://github.com/flutter/flutter/issues/162198) Fixes double-download of canvaskit.wasm
### [3.29.1](https://github.com/flutter/flutter/releases/tag/3.29.1)
@ -49,8 +52,6 @@ glyphs.
- [flutter/163261](https://github.com/flutter/flutter/pull/163261) - Fixes for Impeller DrawVertices issues involving snapshots with empty sizes
- [flutter/163672](https://github.com/flutter/flutter/pull/163672) - Check for tracked engine.version before overriding
## Flutter 3.29 Changes
### [3.29.0](https://github.com/flutter/flutter/releases/tag/3.29.0)
Initial stable release.

View File

@ -930,6 +930,14 @@ config("no_optimize") {
cflags += [ "-fomit-frame-pointer" ]
}
ldflags = common_optimize_on_ldflags
} else if (is_wasm) {
# On WASM we don't want to fully deoptimize the debug build because the
# compiled binary will have some functions with too many local variables
# and Chrome will reject it.
cflags = [
"-O1",
]
ldflags = common_optimize_on_ldflags
} else {
cflags = [ "-O0" ]
}

View File

@ -62,8 +62,7 @@ canvaskit_wasm_lib("canvaskit") {
ldflags = []
if (is_debug) {
ldflags += [
"-O0",
"-sDEMANGLE_SUPPORT=1",
"-O1",
"-sASSERTIONS=1",
"-sGL_ASSERTIONS=1",
"-g3",
@ -111,14 +110,14 @@ canvaskit_wasm_lib("canvaskit") {
"--bind",
"--no-entry",
"--pre-js",
rebase_path("$_skia_root/modules/canvaskit/util.js"),
"--pre-js",
rebase_path("$_skia_root/modules/canvaskit/preamble.js"),
"--pre-js",
rebase_path("$_skia_root/modules/canvaskit/color.js"),
"--pre-js",
rebase_path("$_skia_root/modules/canvaskit/memory.js"),
"--pre-js",
rebase_path("$_skia_root/modules/canvaskit/util.js"),
"--pre-js",
rebase_path("$_skia_root/modules/canvaskit/interface.js"),
]
@ -165,7 +164,7 @@ canvaskit_wasm_lib("canvaskit") {
"-sEXPORT_NAME=CanvasKitInit",
"-sEXPORTED_FUNCTIONS=[_malloc,_free]",
"-sEXPORTED_RUNTIME_METHODS=HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPF32,HEAPU32,HEAPF64",
"-sINCOMING_MODULE_JS_API=onRuntimeInitialized",
"-sINCOMING_MODULE_JS_API=[instantiateWasm,onRuntimeInitialized,noExitRuntime]",
"-sFORCE_FILESYSTEM=0",
"-sFILESYSTEM=0",
"-sMODULARIZE",