From d8b1e81c1f055e3758804086ae58b04005d8af70 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Wed, 23 Aug 2023 10:07:41 -0700 Subject: [PATCH] Add `--experimental-wasm-type-reflection` and support newer emscripten builds. (#133084) This makes two changes to prepare for incoming changes to skwasm in the web engine: * We will (at least for now) be depending on the `WebAssembly.Function` constructor in `skwasm`, which is hidden behind the `--experimental-wasm-type-reflection` flag. We need to pass that when running skwasm benchmarks. * We are going to be upgrading the skwasm build to a newer version of emscripten, which exposes the wasm exports via the `wasmExports` property instead of the `asm` property. Make sure to support either, if passed. --- dev/devicelab/lib/framework/browser.dart | 7 +++++-- .../lib/src/web/file_generators/wasm_bootstrap.dart | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/devicelab/lib/framework/browser.dart b/dev/devicelab/lib/framework/browser.dart index 9d4581faec00..a35f6ac0d85d 100644 --- a/dev/devicelab/lib/framework/browser.dart +++ b/dev/devicelab/lib/framework/browser.dart @@ -87,6 +87,10 @@ class Chrome { print('Launching Chrome...'); } + final String jsFlags = options.enableWasmGC ? [ + '--experimental-wasm-gc', + '--experimental-wasm-type-reflection', + ].join(' ') : ''; final bool withDebugging = options.debugPort != null; final List args = [ if (options.userDataDirectory != null) @@ -108,8 +112,7 @@ class Chrome { '--no-default-browser-check', '--disable-default-apps', '--disable-translate', - if (options.enableWasmGC) - '--js-flags=--experimental-wasm-gc', + if (jsFlags.isNotEmpty) '--js-flags=$jsFlags', ]; final io.Process chromeProcess = await _spawnChromiumProcess( diff --git a/packages/flutter_tools/lib/src/web/file_generators/wasm_bootstrap.dart b/packages/flutter_tools/lib/src/web/file_generators/wasm_bootstrap.dart index c2ee17b49602..0d1a755c0f2c 100644 --- a/packages/flutter_tools/lib/src/web/file_generators/wasm_bootstrap.dart +++ b/packages/flutter_tools/lib/src/web/file_generators/wasm_bootstrap.dart @@ -46,7 +46,7 @@ String generateImports(bool isSkwasm) { const skwasmInstance = await skwasm(); window._flutter_skwasmInstance = skwasmInstance; resolve({ - 'skwasm': skwasmInstance.asm, + 'skwasm': skwasmInstance.asm ?? skwasmInstance.wasmExports, 'ffi': { 'memory': skwasmInstance.wasmMemory, }