Repository navigation
Synchronize dart2wasm feature probes in roll script and flutter_bootstrap.js - #193271
Conversation
…trap.js - Automatically synchronize supportsDart2Wasm() in browser_environment.js from pkg/dart2wasm/lib/compile.dart during create_updated_flutter_deps.py and roll-dart-dependencies.yml. - Add unit tests across historical dart2wasm epochs and a live parity guard in create_updated_flutter_deps_tests.py and engine/src/flutter/ci/test/. - Emit _flutter.supportsDart2Wasm from main.dart.support.js in WebTemplatedFiles.buildConfigString and prefer it in FlutterLoader.load().
There was a problem hiding this comment.
Code Review
This pull request automates synchronizing the supportsDart2Wasm expression in browser_environment.js with pkg/dart2wasm/lib/compile.dart using create_updated_flutter_deps.py, and updates the Flutter web build system to inject this expression during compilation. Feedback suggests improving the robustness of the Python parsing logic with a brace-counting approach, ensuring cross-platform compatibility in the Dart test by dynamically selecting the Python executable, and logging a warning if the compilation file cannot be resolved.
- Prioritize --dart_revision over local third_party/dart when resolving compile.dart, and fall back to flutter_vars['dart_revision'] when no local SDK checkout exists. - Support both single-quoted and double-quoted feature constants in ExtractDart2WasmSupportExpression. - Log a warning to stderr when compile.dart cannot be resolved. - Exclude dry-run Dart2WasmTarget instances from WebTemplatedFiles.inputs and select python on Windows in create_updated_flutter_deps_test.dart.
mdebbar
left a comment
There was a problem hiding this comment.
What if we move supportsDart2Wasm to its own file, and auto-generated the entire file? I'd like to avoid doing complex regex manipulation to insert some code into an existing, hand-written file.
- Extracts `supportsDart2Wasm` out of `browser_environment.js` into a dedicated generated file `engine/src/flutter/lib/web_ui/flutter_js/src/supports_dart2wasm.js`, avoiding regex splicing of hand-written JS. - Registers `src/supports_dart2wasm.js` in `flutter_js/sources.gni` and updates `.github/workflows/roll-dart-dependencies.yml` and `create_updated_flutter_deps.py` to generate it directly.
|
Good call, @mdebbar — done in 09cd716:
|
Addressed feedback in commit 17fb4bc and updated PR description.
- Merges origin/master (resolving conflict with flutter#193180 by checking `window._flutter?.supportsDart2Wasm ?? defaultSupportsDart2Wasm()` after the Firefox < 147 guard in `browser_environment.js`). - Raises `RuntimeError` in `create_updated_flutter_deps.py` when fetching `compile.dart` at `--dart_revision` fails or when `compile.dart` cannot be resolved. - Updates `Skwasm` and `dart2wasm` incompatibility messages in `loader.js` to list `(WasmGC, SIMD, js-string builtins, try_table)`.
…13104) Manual roll requested by [email protected] flutter/flutter@d649d2b...e89fd0a 2026-10-01 [email protected] Manual roll ICU from 6ebb40c59477 to 5aa526207171 (2 revisions) (flutter/flutter#193661) 2026-10-01 [email protected] fix(web): hash source maps before rewriting sourceMappingURL with --web-content-hash (flutter/flutter#193614) 2026-10-01 [email protected] [flutter_tools] Bootstrap DeviceManager in ToolDependencies (flutter/flutter#193524) 2026-10-01 [email protected] [wasm] Set flutter_runtime_mode in tools/gn to_gn_wasm_args (flutter/flutter#193407) 2026-10-01 [email protected] Remove remaining `download_jdk` references (flutter/flutter#193562) 2026-10-01 [email protected] Synchronize dart2wasm feature probes in roll script and flutter_bootstrap.js (flutter/flutter#193271) 2026-10-01 [email protected] [web] Unskip web tests that now pass in gestures, services, and widgets (flutter/flutter#193512) 2026-10-01 [email protected] Roll Fuchsia Test Scripts from whZAV1mfT-Rdc0rQ8... to fCNknap4ZI0AMcvIf... (flutter/flutter#193640) 2026-10-01 [email protected] Roll Skia from 0575a37d0619 to f2d68e0b8863 (2 revisions) (flutter/flutter#193621) 2026-10-01 [email protected] perf(widgets): use const <Never>{} in InheritedModelElement and avoid redundant casts in RenderObjectElement.update (flutter/flutter#192913) 2026-10-01 [email protected] [web] Unskip and strengthen missing glyph tofu test on Wimp (flutter/flutter#193426) 2026-10-01 [email protected] [flutter_tools] Fix `flutter drive -d chrome` hanging on web (flutter/flutter#193459) 2026-10-01 [email protected] [web] Fix hang when Chromium cannot bind remote debugging port (flutter/flutter#193461) 2026-10-01 [email protected] [flutter_tools] Bundle data assets from hooks in flutter test (flutter/flutter#193435) 2026-10-01 [email protected] Roll Packages from 0ba9a82 to d5ec6db (11 revisions) (flutter/flutter#193641) 2026-10-01 [email protected] Revert: [flutter_tools] Fix DTD "Stream already subscribed" error and wait for analysis over DTD in widget preview (flutter/flutter#193637) 2026-10-01 [email protected] Roll Skia from 6182a3cf8f98 to 0575a37d0619 (5 revisions) (flutter/flutter#193613) 2026-10-01 [email protected] [flutter_tools] Fix DTD "Stream already subscribed" error and wait for analysis over DTD in widget preview (flutter/flutter#192930) 2026-09-30 [email protected] [Impeller] Sample the render target rect in offscreen advanced blends (flutter/flutter#192988) 2026-09-30 [email protected] Roll Skia from 01524014dff5 to 6182a3cf8f98 (11 revisions) (flutter/flutter#193594) 2026-09-30 [email protected] [web] Use Xvfb -displayfd and clean up Xvfb after Firefox test suites (flutter/flutter#193510) 2026-09-30 [email protected] Fixes bug where sibling node fail to update size (flutter/flutter#191220) 2026-09-30 [email protected] Roll Skia from c7b323126bf0 to 01524014dff5 (3 revisions) (flutter/flutter#193577) 2026-09-30 [email protected] Remove some Undefined Behavior from run_customer_testing_tests.dart. (flutter/flutter#193582) 2026-09-30 [email protected] Fix pointer id/coordinate mismatch in Android platform view multi-touch (flutter/flutter#191631) 2026-09-30 [email protected] Roll Packages from 3c6ce59 to 0ba9a82 (11 revisions) (flutter/flutter#193578) 2026-09-30 [email protected] Fix unresolved doc comment references in dev/ tooling (flutter/flutter#193501) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…y checks (flutter#193667) Adds a regression test in `fallbacks_test.dart` (`firefox-fallbacks` suite) verifying the `Firefox < 147` version gate added in flutter#193180 (and its precedence over `_flutter.supportsDart2Wasm` in flutter#193271): 1. **Firefox 146 (`< 147`)**: Even when `wasmAllowList: { gecko: true }` is configured, `_flutter.supportsDart2Wasm` is `true`, and `WebAssembly.validate` returns `true`, `FlutterLoader.load` rejects `dart2wasm` builds before invoking `WebAssembly.validate` (`validateCalls == 0`). 2. **Firefox 147 (`>= 147`)**: Passes the Firefox version gate and proceeds to evaluate `WebAssembly.validate` (`validateCalls > 0`). Related to flutter#143603 and flutter#186619 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
Synchronizes Flutter Web's Wasm feature detection with the Dart SDK's
dart2wasmcompiler output (main.dart.support.js) and automates keepingsupportsDart2Wasm()in sync during Dart SDK rolls.Follows up on #193090.
Background
When
dart2wasmcompiles a Wasm module (pkg/dart2wasm/lib/compile.dart), it emits<output>.support.js(main.dart.support.jsin Flutter Web builds), containing a JavaScript boolean expression that checks whether the current browser supports all WebAssembly features required by the compiled module (WasmGC, relaxed/standard SIMD,js-stringbuiltins,try_table, and conditionalrequiresMultiMemory).Previously,
engine/src/flutter/lib/web_ui/flutter_js/src/browser_environment.jsmaintained a manual copy of this byte array check insidesupportsDart2Wasm(). Wheneverdart2wasmadded or modified a required Wasm feature probe in the Dart SDK,flutter_jshad to be manually updated in a separate PR. Additionally,main.dart.support.jsemitted bydart2wasmduringflutter build web --wasmwas never read byflutter_tools.Changes
main.dart.support.jsinflutter_toolsbootstrap generation:generateFlutterBootstrapScriptreadsmain.dart.support.jswhen present in the build output directory and emits_flutter.supportsDart2Wasm = <expr>;immediately after_flutter.buildConfig = ...;(preserving strict JSON parsing in--web-content-hash).supportsDart2Wasm()inbrowser_environment.jsevaluateswindow._flutter?.supportsDart2Wasm ?? defaultSupportsDart2Wasm()after enforcing the Firefox< 147guard, so standardflutter build web --wasmapps use the exact feature probe emitted by the activedart2wasmcompiler (including conditional flags such as--extra-compiler-option=--import-shared-memory), while custom HTML embeddings using standaloneflutter.jsfall back todefaultSupportsDart2Wasm()fromsupports_dart2wasm.js.supports_dart2wasm.jsgeneration during Dart SDK rolls:supportsDart2Wasmprobe into a standalone generated moduleengine/src/flutter/lib/web_ui/flutter_js/src/supports_dart2wasm.jsimported bybrowser_environment.js.engine/src/tools/dart/create_updated_flutter_deps.py(SyncSupportsDart2WasmJs) parses_generateSupportJsfrompkg/dart2wasm/lib/compile.dart(from localthird_party/dartordart.googlesource.comwhen--dart_revisionis specified) and generatessupports_dart2wasm.js..github/workflows/roll-dart-dependencies.ymlstagesengine/src/flutter/lib/web_ui/flutter_js/src/supports_dart2wasm.jsalongsideDEPSwhen rolling Dart dependencies.engine/src/tools/dart/create_updated_flutter_deps_tests.pyverifiesExtractDart2WasmSupportExpressionacross historicaldart2wasmepochs and asserts thatsupports_dart2wasm.jsmatchesthird_party/dart/pkg/dart2wasm/lib/compile.dartwheneverthird_party/dartis present.Pre-launch Checklist
///).