Skip to content

wasm: enforce WasmGC opt-in capability checks and Firefox < 147 guard - #193180

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
kevmoo:wasm-optin-fallback
Sep 26, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
kevmoo:wasm-optin-fallback

Conversation

@kevmoo

@kevmoo kevmoo commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Ensures that when an application opts into WebAssembly on Firefox or Safari via wasmAllowList in JS/JSON bootstrap configuration, FlutterLoader strictly enforces supportsDart2Wasm() capability checks and browser version guards before selecting any dart2wasm build:

  • Firefox < 147 WasmGC Version Guard: Guards supportsDart2Wasm() in browser_environment.js so Firefox < 147 falls back to dart2js even if wasmAllowList: { gecko: true } is configured.
  • Unify enableWasm Gating Across All dart2wasm Targets: Moves the !enableWasm check in loader.js from rendererIncompatibilityReason('skwasm') into buildIncompatibilityReason for build.compileTarget === 'dart2wasm', preventing dart2wasm + canvaskit builds from bypassing wasmAllowList opt-outs.
  • Explicit Opt-In Fallback Test: Adds test coverage in fallbacks_test.dart verifying that flutter.loader.load() with wasmAllowList explicitly enabled for all engines still rejects dart2wasm builds when supportsDart2Wasm is false.

Part of #143603

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 22, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request restricts Dart2Wasm support on Firefox to versions 147 and above, adds a try_table validation check to WebAssembly capability detection, and refactors the loader to verify the WebAssembly enablement configuration under the dart2wasm target. Additionally, a test is introduced to verify loader behavior on unsupported browsers. The review feedback suggests defensively guarding accesses to navigator and navigator.userAgent in the browser environment detection code to prevent runtime errors in non-browser or server-side rendering environments.

Comment thread engine/src/flutter/lib/web_ui/flutter_js/src/browser_environment.js Outdated
@kevmoo
kevmoo force-pushed the wasm-optin-fallback branch from 47e5993 to ff426fd Compare September 22, 2026 20:42
@kevmoo kevmoo changed the title wasm: update loader for try_table capabilities and WasmGC opt-in guard wasm: enforce WasmGC opt-in capability checks and Firefox < 147 guard Sep 22, 2026
Comment thread engine/src/flutter/lib/web_ui/test/fallbacks/fallbacks_test.dart Outdated
@kevmoo
kevmoo marked this pull request as draft September 22, 2026 20:54
@kevmoo

kevmoo commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Waiting on @sorensp-goog PR to land first

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Sep 22, 2026
- Checks Firefox versions under 147 and forces fallback to JS for dart2wasm (flutter#186619)
- Fixes loader.js where wasmAllowList configs were only checked for skwasm rather than all dart2wasm builds
- Adds fallbacks_test.dart coverage for explicit wasmAllowList opt-in when WasmGC capabilities are missing
@kevmoo
kevmoo force-pushed the wasm-optin-fallback branch from 857832e to fc42d72 Compare September 24, 2026 00:46
@kevmoo
kevmoo marked this pull request as ready for review September 24, 2026 00:46

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a Firefox version check for Gecko browsers in supportsDart2Wasm, refactors the loader to check wasmAllowList within the dart2wasm compile target block, and adds a test to verify that WasmGC capability is strictly honored. A critical issue was identified in loader.js where supportsDart2Wasm is referenced as a variable instead of being invoked as a function, which bypasses the capability check.

Comment thread engine/src/flutter/lib/web_ui/flutter_js/src/loader.js
…asm in load()

- Evaluates browserEnvironment.supportsDart2Wasm via getter inside FlutterLoader.load() rather than module top-level constant
- Isolates _flutter.buildConfig to a dart2wasm/canvaskit candidate and stubs WebAssembly.validate in fallbacks_test.dart so firefox-fallbacks and safari-fallbacks do not match the fallback dart2js build
@kevmoo
kevmoo requested a review from mdebbar September 24, 2026 19:49
mdebbar
mdebbar previously approved these changes Sep 24, 2026
Comment thread engine/src/flutter/lib/web_ui/flutter_js/src/browser_environment.js
Comment thread engine/src/flutter/lib/web_ui/flutter_js/src/loader.js
@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 25, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 26, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 26, 2026
@auto-submit

auto-submit Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/193180, Failed to enqueue flutter/flutter/193180 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected..

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 26, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 26, 2026
Merged via the queue into flutter:master with commit 8db5526 Sep 26, 2026
29 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 26, 2026
@kevmoo
kevmoo deleted the wasm-optin-fallback branch September 26, 2026 23:29
DanTup pushed a commit to DanTup/flutter that referenced this pull request Sep 28, 2026
…flutter#193180)

Ensures that when an application opts into WebAssembly on Firefox or
Safari via `wasmAllowList` in JS/JSON bootstrap configuration,
`FlutterLoader` strictly enforces `supportsDart2Wasm()` capability
checks and browser version guards before selecting any `dart2wasm`
build:

- **Firefox `< 147` WasmGC Version Guard**: Guards `supportsDart2Wasm()`
in `browser_environment.js` so Firefox `< 147` falls back to `dart2js`
even if `wasmAllowList: { gecko: true }` is configured.
- **Unify `enableWasm` Gating Across All `dart2wasm` Targets**: Moves
the `!enableWasm` check in `loader.js` from
`rendererIncompatibilityReason('skwasm')` into
`buildIncompatibilityReason` for `build.compileTarget === 'dart2wasm'`,
preventing `dart2wasm` + `canvaskit` builds from bypassing
`wasmAllowList` opt-outs.
- **Explicit Opt-In Fallback Test**: Adds test coverage in
`fallbacks_test.dart` verifying that `flutter.loader.load()` with
`wasmAllowList` explicitly enabled for all engines still rejects
`dart2wasm` builds when `supportsDart2Wasm` is false.

Part of flutter#143603
DanTup pushed a commit to DanTup/flutter that referenced this pull request Sep 28, 2026
…flutter#193180)

Ensures that when an application opts into WebAssembly on Firefox or
Safari via `wasmAllowList` in JS/JSON bootstrap configuration,
`FlutterLoader` strictly enforces `supportsDart2Wasm()` capability
checks and browser version guards before selecting any `dart2wasm`
build:

- **Firefox `< 147` WasmGC Version Guard**: Guards `supportsDart2Wasm()`
in `browser_environment.js` so Firefox `< 147` falls back to `dart2js`
even if `wasmAllowList: { gecko: true }` is configured.
- **Unify `enableWasm` Gating Across All `dart2wasm` Targets**: Moves
the `!enableWasm` check in `loader.js` from
`rendererIncompatibilityReason('skwasm')` into
`buildIncompatibilityReason` for `build.compileTarget === 'dart2wasm'`,
preventing `dart2wasm` + `canvaskit` builds from bypassing
`wasmAllowList` opt-outs.
- **Explicit Opt-In Fallback Test**: Adds test coverage in
`fallbacks_test.dart` verifying that `flutter.loader.load()` with
`wasmAllowList` explicitly enabled for all engines still rejects
`dart2wasm` builds when `supportsDart2Wasm` is false.

Part of flutter#143603
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 29, 2026
…#13060)

Manual roll Flutter from 4fcd90be0045 to c5a061b18fa2 (222 revisions)

Manual roll requested by [email protected]

flutter/flutter@4fcd90b...c5a061b

2026-09-28 [email protected] [cross imports] navigator_test.dart (flutter/flutter#190954)
2026-09-28 [email protected] Revert: Reland: Only render views that need to be rendered  (flutter/flutter#193360)
2026-09-28 [email protected] ci(bringup): android_intent_security_test is green (flutter/flutter#193469)
2026-09-28 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#193020)
2026-09-28 [email protected] Roll Fuchsia Linux SDK from ukukV5lEkKabtOATk... to QdgqP02_cYpRQQQNN... (flutter/flutter#193454)
2026-09-28 [email protected] Roll pub packages (flutter/flutter#193460)
2026-09-28 [email protected] Un-nest sceneBuildDuration and windowRenderDuration in web SceneBuilderRecorder (flutter/flutter#193260)
2026-09-28 [email protected] Fix unresolved doc comment references in dev/integration_tests and dev/benchmarks (flutter/flutter#193433)
2026-09-28 [email protected] Roll Packages from e55e7ac to ba0364a (9 revisions) (flutter/flutter#193450)
2026-09-28 [email protected] [tool] Require explicit dependency injection for FlutterDevice and FlutterDevice.create (flutter/flutter#192830)
2026-09-28 [email protected] Roll pub packages (flutter/flutter#193442)
2026-09-28 [email protected] [flutter_tools] Include data assets from hooks when pubspec.yaml is empty (flutter/flutter#193434)
2026-09-28 [email protected] Roll pub packages (flutter/flutter#193438)
2026-09-28 [email protected] Fix unresolved doc comment references in Material and Cupertino (flutter/flutter#193283)
2026-09-28 [email protected] Fix doc references to Material and Cupertino in the widgets library and its tests (flutter/flutter#193334)
2026-09-26 [email protected] wasm: enforce WasmGC opt-in capability checks and Firefox < 147 guard (flutter/flutter#193180)
2026-09-26 [email protected] [Android] Refuse external setters of engine entrypoint and cached engine arguments via `Intent`s (flutter/flutter#190249)
2026-09-26 [email protected] [web] Unskip TextPainter.getWordBoundary test (flutter/flutter#193378)
2026-09-26 [email protected] Specify non-obvious types in pattern variable declarations (flutter/flutter#192632)
2026-09-26 [email protected] Removes feedback loop from advanced filters without offscreen msaa and framebufferfetch (flutter/flutter#193306)
2026-09-26 [email protected] [web] Unskip 8 passing image tests in painting and rendering (flutter/flutter#193377)
2026-09-26 [email protected] Revert: Allow resetting test invariants in `addTearDown` (flutter/flutter#193383)
2026-09-25 [email protected] [tool] Migrate CoverageCollector to modular dependency injection (flutter/flutter#192924)
2026-09-25 [email protected] Fix more unresolved doc comment references (flutter/flutter#193336)
2026-09-25 [email protected] Allow resetting test invariants in `addTearDown` (flutter/flutter#192082)
2026-09-25 [email protected] [a11y] Add a semantics role for slider (flutter/flutter#193324)
2026-09-25 [email protected] Fix plugin tests after Pigeon plugin template changes (flutter/flutter#193302)
2026-09-25 [email protected] [Android 17] Bump Standard Test Apps in flutter/flutter to AGP 9.3.1 (flutter/flutter#193263)
2026-09-25 [email protected] SSBO-based gradients in UberSDF (flutter/flutter#192962)
2026-09-25 [email protected] [Linux] Handle FlView being destroyed before rendering is complete. (flutter/flutter#193268)
2026-09-25 [email protected] [flutter_tools] Handle Windows reserved characters in test target path (flutter/flutter#191900)
2026-09-25 [email protected] docs(tools): nit: say hook/build.dart in CMake native assets comment (flutter/flutter#192205)
2026-09-25 [email protected] [web] Enable Firefox Skwasm UI CI suites, configure COI configs, and fail fast on loader rejections (flutter/flutter#193187)
2026-09-25 [email protected] [Android 17] Bumped Engine Dependencies to 9.3.1 (flutter/flutter#193265)
2026-09-25 [email protected] [web] Omit group role on menu scrollables and assign region role to named routes (flutter/flutter#192965)
2026-09-25 [email protected] Roll Skia from 8eedeed98e79 to f441ca223b2b (5 revisions) (flutter/flutter#193353)
2026-09-25 [email protected] Roll Fuchsia Linux SDK from EbPpoJW-Lnsu-8dyZ... to ukukV5lEkKabtOATk... (flutter/flutter#193326)
2026-09-25 [email protected] Roll Packages from 431ea69 to e55e7ac (6 revisions) (flutter/flutter#193351)
2026-09-25 [email protected] Support DynamicLibrary.codeAsset in Flutter (flutter/flutter#188947)
2026-09-25 [email protected] Roll Dart SDK from 75d9e87d4e3d to 0e7642b85457 (1 revision) (flutter/flutter#193346)
2026-09-25 [email protected] Exclude iOS PRs from macOS link (flutter/flutter#193315)
2026-09-25 [email protected] Roll Skia from 6357608543ec to 8eedeed98e79 (4 revisions) (flutter/flutter#193341)
2026-09-25 [email protected] Roll Dart SDK from d3aedb186aab to 75d9e87d4e3d (3 revisions) (flutter/flutter#193335)
2026-09-25 [email protected] Cache the paint offset adjusted line metrics in TextPainter (flutter/flutter#191223)
...
kevmoo added a commit to kevmoo/flutter that referenced this pull request Oct 1, 2026
- 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)`.
jesswrd pushed a commit to jesswrd/flutter that referenced this pull request Oct 2, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants