Skip to content

Fix automatic JavaScript fallback for flutter run when WASM is not available #172002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

keyur2maru
Copy link

@keyur2maru keyur2maru commented Jul 11, 2025

When using flutter run -d chrome --wasm --web-hostname 0.0.0.0, I realized the JavaScript fallback mechanism was not kicking in on iOS browsers (Safari, Chrome, etc.), resulting in the app load failure. The issue was that ResidentWebRunner only provided a single compiler configuration when WASM was enabled.

This fix updates ResidentWebRunner to provide both WasmCompilerConfig and JsCompilerConfig when the --wasm flag is used, matching the behavior of flutter build web --wasm. The WebAssetServer's build configuration is also updated to include both dart2wasm and dart2js targets, enabling proper fallback to JavaScript when WASM is not supported.

The changes ensure that:

  • Both WASM and JavaScript targets are built during flutter run --wasm
  • The appropriate renderer is used for each target (skwasm for WASM, canvaskit for JS)
  • iOS browsers correctly fallback to JavaScript when WASM is not available

Fixes the following error -

[Error] Unhandled Promise Rejection: FlutterLoader could not find a build compatible with configuration and environment.
	(anonymous function) (flutter_bootstrap.js:35:995)
	load (flutter_bootstrap.js:35:1495)
	Global Code (flutter_bootstrap.js:43)

Fixes #172006
Relates to #160581

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

…lable

When using `flutter run --wasm`, the JavaScript fallback mechanism was not working on iOS browsers (Safari, Chrome, etc.) which don't support WASM. The issue was that ResidentWebRunner only provided a single compiler configuration when WASM was enabled.

This fix updates ResidentWebRunner to provide both WasmCompilerConfig and JsCompilerConfig when the --wasm flag is used, matching the behavior of `flutter build web --wasm`. The WebAssetServer's build configuration is also updated to include both dart2wasm and dart2js targets, enabling proper fallback to JavaScript when WASM is not supported.

The changes ensure that:
  - Both WASM and JavaScript targets are built during `flutter run --wasm`
  - The appropriate renderer is used for each target (skwasm for WASM, canvaskit for JS)
  - iOS browsers correctly fallback to JavaScript when WASM is not available

Fixes the error: "FlutterLoader could not find a build compatible with configuration and environment

Signed-off-by: Keyur Maru <kd2maru@gmail.com>
@flutter-dashboard
Copy link

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.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[web] flutter run with --wasm flag does not fallback to JS as it does with flutter build
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy