Skip to content

Update browser_environment.js to require try_table - #193090

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
sorensp-goog:patch-1
Sep 24, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
sorensp-goog:patch-1

Conversation

@sorensp-goog

@sorensp-goog sorensp-goog commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

An upcoming change to the dart2wasm compiler will make it generate try_table instructions, so this prepares flutter to fall back to JS if it runs on a browser without such support.

See https://dart-review.googlesource.com/c/sdk/+/551200?tab=checks for the Dart compiler change.

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

An upcoming change to the dart2wasm compiler will make it generate try_table instructions, so this prepares flutter to fall back to JS if it runs on a browser without such support.
@github-actions

Copy link
Copy Markdown

This pull request targets the main branch, but the primary branch for this repository is master.

Please change the base branch of this pull request to master.

See: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request

@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 21, 2026
@sorensp-goog
sorensp-goog changed the base branch from main to master September 21, 2026 12:59
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@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 updates the supportsDart2Wasm function in browser_environment.js to include an additional WebAssembly validation check for try_table support. The review feedback recommends refactoring the long, single-line expression into descriptive boolean variables to improve readability, and updating the accompanying inline comment to document this new check and correct a typo.

Comment thread engine/src/flutter/lib/web_ui/flutter_js/src/browser_environment.js
@kevmoo kevmoo added the CICD Run CI/CD label Sep 22, 2026

@kevmoo kevmoo 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.

LGTM! Verified that the 31-byte try_table (0x1F, catch_all $0) validation sequence is byte-for-byte identical to supportsTryTable in pkg/dart2wasm/lib/compile.dart (https://dart-review.googlesource.com/c/sdk/+/551200) and empirically verified supportsDart2Wasm() across our local Playwright WebKit (621.1.11..625.1.21 / Safari 18.4 -> 26.6) and Firefox (153.0..155.0) browser matrix:

Engine WasmGC JsStringBuiltins TryTable (0x1F) WasmSimd supportsDart2Wasm
WebKit 621.1.11 (Safari 18.4) yes no yes yes no
WebKit 622.1.35..625.1.21 (Safari 26.0..26.6) yes yes yes yes yes
Firefox 153.0..155.0 (SpiderMonkey) yes yes yes yes yes

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

@mdebbar mdebbar 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.

From @kevmoo's agent:

Which Chrome versions are affected: Chrome 130 through 136

  • Chrome <= 129: Already fell back to JS because wasm:js-string shipped in Chrome 130 (Oct 2024).
  • Chrome 130 - 136 (Oct 2024 - Apr 2025): Shipped wasm:js-string (supportsJsStringBuiltins: true), but V8 kept Wasm exnref / try_table (0x1F) behind --experimental-wasm-exnref. On Playwright Chromium 136.0.7103.25, supportsTryTable is false under default flags and flips to true only when launched with --js-flags=--experimental-wasm-exnref.
  • Chrome 137+ (May 2025+): Unflagged try_table (0x1F) by default (supportsTryTable: true, supportsDart2Wasm: true).

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 23, 2026
@auto-submit

auto-submit Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/193090, because - The status or check suite Mac_arm64_verify_binaries has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Tree_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 23, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 23, 2026
@auto-submit

auto-submit Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/193090, because - The status or check suite Mac_arm64_verify_binaries has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Tree_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 23, 2026
Merged via the queue into flutter:master with commit 104d0fb Sep 24, 2026
43 of 45 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 24, 2026
kevmoo added a commit to kevmoo/flutter that referenced this pull request Oct 1, 2026
…trap.js (flutter#193271)

Synchronizes Flutter Web's Wasm feature detection with the Dart SDK's
`dart2wasm` compiler output (`main.dart.support.js`) and automates
keeping `supportsDart2Wasm()` in sync during Dart SDK rolls.

Follows up on flutter#193090.

### Background

When `dart2wasm` compiles a Wasm module
(`pkg/dart2wasm/lib/compile.dart`), it emits `<output>.support.js`
(`main.dart.support.js` in 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-string` builtins, `try_table`, and
conditional `requiresMultiMemory`).

Previously,
`engine/src/flutter/lib/web_ui/flutter_js/src/browser_environment.js`
maintained a manual copy of this byte array check inside
`supportsDart2Wasm()`. Whenever `dart2wasm` added or modified a required
Wasm feature probe in the Dart SDK, `flutter_js` had to be manually
updated in a separate PR. Additionally, `main.dart.support.js` emitted
by `dart2wasm` during `flutter build web --wasm` was never read by
`flutter_tools`.

### Changes

1. **Consume `main.dart.support.js` in `flutter_tools` bootstrap
generation**:
- `generateFlutterBootstrapScript` reads `main.dart.support.js` when
present in the build output directory and emits
`_flutter.supportsDart2Wasm = <expr>;` immediately after
`_flutter.buildConfig = ...;` (preserving strict JSON parsing in
`--web-content-hash`).
- `supportsDart2Wasm()` in `browser_environment.js` evaluates
`window._flutter?.supportsDart2Wasm ?? defaultSupportsDart2Wasm()` after
enforcing the Firefox `< 147` guard, so standard `flutter build web
--wasm` apps use the exact feature probe emitted by the active
`dart2wasm` compiler (including conditional flags such as
`--extra-compiler-option=--import-shared-memory`), while custom HTML
embeddings using standalone `flutter.js` fall back to
`defaultSupportsDart2Wasm()` from `supports_dart2wasm.js`.
2. **Automate `supports_dart2wasm.js` generation during Dart SDK
rolls**:
- Moves the default `supportsDart2Wasm` probe into a standalone
generated module
`engine/src/flutter/lib/web_ui/flutter_js/src/supports_dart2wasm.js`
imported by `browser_environment.js`.
- `engine/src/tools/dart/create_updated_flutter_deps.py`
(`SyncSupportsDart2WasmJs`) parses `_generateSupportJs` from
`pkg/dart2wasm/lib/compile.dart` (from local `third_party/dart` or
`dart.googlesource.com` when `--dart_revision` is specified) and
generates `supports_dart2wasm.js`.
- `.github/workflows/roll-dart-dependencies.yml` stages
`engine/src/flutter/lib/web_ui/flutter_js/src/supports_dart2wasm.js`
alongside `DEPS` when rolling Dart dependencies.
3. **CI Parity Guard**:
- `engine/src/tools/dart/create_updated_flutter_deps_tests.py` verifies
`ExtractDart2WasmSupportExpression` across historical `dart2wasm` epochs
and asserts that `supports_dart2wasm.js` matches
`third_party/dart/pkg/dart2wasm/lib/compile.dart` whenever
`third_party/dart` is present.

## 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] 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.

4 participants