From 8da579925c952cecea3bf0b8b1f72b46f3489b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 28 Aug 2024 20:00:51 +0200 Subject: [PATCH] Compile dart2wasm modules using the JS runtime exported compileStreaming (flutter/engine#51488) With [1] dart2wasm started using the new Wasm built-in string import `wasm:js-string`. With [2] dart2wasm started exporting `compile` and `compileStreaming` from the generated JS runtime to compile dart2wasm-generated modules with the `wasm:js-string` built-in, polyfilling it when not available. Update Wasm compilation code in Flutter to use `compileStreaming` from the JS runtime, enabling fast `jwasm:js-string` module when available. [1]: https://github.com/dart-lang/sdk/commit/44c2e17600458efbbff947372370d23ae9c3a73f [2]: https://github.com/dart-lang/sdk/commit/4cd6096da42740c4a7ac27174b75eba097b63a3a --- .../flutter/lib/web_ui/flutter_js/src/entrypoint_loader.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/lib/web_ui/flutter_js/src/entrypoint_loader.js b/engine/src/flutter/lib/web_ui/flutter_js/src/entrypoint_loader.js index dfc769d12a..2c9fe15619 100644 --- a/engine/src/flutter/lib/web_ui/flutter_js/src/entrypoint_loader.js +++ b/engine/src/flutter/lib/web_ui/flutter_js/src/entrypoint_loader.js @@ -152,11 +152,11 @@ export class FlutterEntrypointLoader { let jsSupportRuntimeUri = resolveUrlWithSegments(entrypointBaseUrl, jsSupportRuntimePath); if (this._ttPolicy != null) { jsSupportRuntimeUri = this._ttPolicy.createScriptURL(jsSupportRuntimeUri); - } - const dartModulePromise = WebAssembly.compileStreaming(fetch(moduleUri)); - + } const jsSupportRuntime = await import(jsSupportRuntimeUri); + const dartModulePromise = jsSupportRuntime.compileStreaming(fetch(moduleUri)); + let imports; if (build.renderer === "skwasm") { imports = (async () => {