Skip to content

[BUG] Flutter multi-threaded WASM web app cannot run as Chrome Extension #177974

@AlexDochioiu

Description

@AlexDochioiu

Steps to reproduce

I created a reproducible example here with all the info inside README:
https://github.com/AlexDochioiu/flutter-wasm-chrome-extension-bug

To fix this, I created (with AI) some patch script. This patch script modifies the flutter_bootstrap.js from the build/web and forces single-threaded WASM execution:
https://github.com/AlexDochioiu/flutter-wasm-chrome-extension-bug/blob/master/scripts/web/patch_flutter_bootstrap.sh

Expected results

WASM should work with chrome extensions

Actual results

SKWASM renderer fails to load with error.

Code sample

https://github.com/AlexDochioiu/flutter-wasm-chrome-extension-bug

Screenshots or Video

Screenshots / Video demonstration

Before my patch script

Image

After my patch script

Image

Logs

WEB Logs (Chrome Console)
Installing/Activating first service worker.
flutter_bootstrap.js:31 Exception while loading service worker: Error: prepareServiceWorker took more than 4000ms to resolve. Moving on.
    at flutter_bootstrap.js:1:3542
(anonymous) @ flutter_bootstrap.js:31Understand this warning
a32253ce-571b-4adc-aa21-3002e27ee8ed:12 Loading the script 'chrome-extension://aoagnldgoecncalmmahhgogmgghgahee/canvaskit/skwasm.js' violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback. The action has been blocked.
eventListener @ a32253ce-571b-4adc-aa21-3002e27ee8ed:12Understand this error
a32253ce-571b-4adc-aa21-3002e27ee8ed:1 Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: chrome-extension://aoagnldgoecncalmmahhgogmgghgahee/canvaskit/skwasm.js

Flutter Doctor output

Doctor output
flutter doctor -v


[✓] Flutter (Channel stable, 3.35.7, on macOS 26.0.1 25A362 darwin-arm64, locale en-US) [1,155ms]
    • Flutter version 3.35.7 on channel stable at /Users/alexandrudochioiu/.asdf/installs/flutter/3.35.7-stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision adc9010625 (2 weeks ago), 2025-10-21 14:16:03 -0400
    • Engine revision 035316565a
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-lldb-debugging

[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.1s]
    • Android SDK at /Users/alexandrudochioiu/Library/Android/sdk
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • ANDROID_HOME = /Users/alexandrudochioiu/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [1,959ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A400
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [8ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2025.1) [8ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)

[✓] Connected device (4 available) [6.1s]
    • Alexandru’s iPhone 15 (wireless) (mobile) • 00008120-001250E12250A01E • ios            • iOS 26.0.1 23A355
    • iPhone (wireless) (mobile)                • 00008120-001454811A62201E • ios            • iOS 18.1 22B83
    • macOS (desktop)                           • macos                     • darwin-arm64   • macOS 26.0.1 25A362 darwin-arm64
    • Chrome (web)                              • chrome                    • web-javascript • Google Chrome 142.0.7444.60

[✓] Network resources [662ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: buildBuilding flutter applications with the toole: wasmIssues related to the wasm build of Flutter Web.e: web_skwasmSkwasm rendering backend for webfound in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform teamtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions