[Web][Canvaskit] Image decode crash on non-Blink browsers

This issue has been tracked since 2022-11-23.

Steps to Reproduce

  1. Clone the repo and run the web server
git clone https://github.com/umberto-sonnino/flutter_web_decode_bug.git
cd flutter_web_decode_bug
flutter run -d web-server --web-renderer canvaskit
  1. Open the app in a non-Blink browser (i.e. Firefox or Safari) and open up the Developer Console
  2. Click on 'Get Codecs' and wait for the console crash after a few images have been decoded

Expected results:
Decoding the images doesn't crash

Actual results:
I've seen different crashes depending on the browser.
Firefox Developer Edition v108.0b5:
Uncaught (in promise) Error: ImageCodecException: Failed to decode image data. Image source: encoded image bytes

StackTrace:

DartError dart_sdk.js:7028
    throw_ errors.dart:266
    createDefault image_wasm_codecs.dart:36
    new skia_object_cache.dart:222
    decodeFromBytes image_wasm_codecs.dart:21
    skiaInstantiateImageCodec image.dart:22
    instantiateImageCodec painting.dart:480
    runBody async_patch.dart:84
    _async async_patch.dart:123
    instantiateImageCodec painting.dart:473
    _initCodecs main.dart:47
    runUnary zone.dart:1653
    handleValue future_impl.dart:147
    handleValueCallback future_impl.dart:766
    _propagateToListeners future_impl.dart:795
    _completeWithValue future_impl.dart:566
    <anonymous> future_impl.dart:639
    _microtaskLoop schedule_microtask.dart:40
    _startMicrotaskLoop schedule_microtask.dart:49
    _scheduleImmediateWithPromise async_patch.dart:166
    promise callback*_scheduleImmediateWithPromise async_patch.dart:164
    _scheduleImmediate async_patch.dart:136
    _scheduleAsyncCallback schedule_microtask.dart:69
    _rootScheduleMicrotask zone.dart:1458
    scheduleMicrotask zone.dart:1673
    _asyncCompleteWithValue future_impl.dart:638
    _asyncComplete future_impl.dart:598
    complete future_impl.dart:36
    send binding.dart:366
    runUnaryGuarded zone.dart:1586
    _zonedPlatformMessageResponseCallback platform_dispatcher.dart:381
    replyToPlatformMessage platform_dispatcher.dart:1138
    runUnary zone.dart:1653
    handleValue future_impl.dart:147
    handleValueCallback future_impl.dart:766
    _propagateToListeners future_impl.dart:795
    _complete future_impl.dart:557
    delayed future.dart:421
    internalCallback isolate_helper.dart:48
    setTimeout handler*load__dart_sdk/_isolate_helper.TimerImpl.new isolate_helper.dart:55
    _createTimer async_patch.dart:186
    createTimer zone.dart:1677
    new timer.dart:51
    delayed future.dart:419
    replyToPlatformMessage platform_dispatcher.dart:1136
    <anonymous> platform_dispatcher.dart:437
    runUnary zone.dart:1653
    handleValue future_impl.dart:147
    handleValueCallback future_impl.dart:766
    _propagateToListeners future_impl.dart:795
    _completeWithValue future_impl.dart:566
    <anonymous> future_impl.dart:639
    _microtaskLoop schedule_microtask.dart:40
    _startMicrotaskLoop schedule_microtask.dart:49
    _scheduleImmediateWithPromise async_patch.dart:166
    promise callback*_scheduleImmediateWithPromise async_patch.dart:164
    _scheduleImmediate async_patch.dart:136
    _scheduleAsyncCallback schedule_microtask.dart:69
    _rootScheduleMicrotask zone.dart:1458
    scheduleMicrotask zone.dart:1673
    _asyncCompleteWithValue future_impl.dart:638
    _asyncComplete future_impl.dart:598
    complete future_impl.dart:36
    domHttpRequest dom.dart:733
    _checkAndCall operations.dart:334
    dcall operations.dart:339
    ret dart_sdk.js:62137
    callMethod$ js_util_patch.dart:80
    DomEventTargetExtension$124addEventListener dom.dart:136
    domHttpRequest dom.dart:726
    load assets.dart:61
    runBody async_patch.dart:84
    _async async_patch.dart:123
    load assets.dart:57
    _sendPlatformMessage platform_dispatcher.dart:436
    sendPlatformMessage platform_dispatcher.dart:326
    send binding.dart:364
    load asset_bundle.dart:256
    runBody async_patch.dart:84
    _async async_patch.dart:123
    load asset_bundle.dart:253
    _initCodecs main.dart:48
    moveNext iterable.dart:391
    next dart_sdk.js:7061
    wait future.dart:520
    _initCodecs main.dart:43
    _async async_patch.dart:45
    runUnary zone.dart:1653
    handleValue future_impl.dart:147
    handleValueCallback future_impl.dart:766
    _propagateToListeners future_impl.dart:795
    _completeWithValue future_impl.dart:566
    <anonymous> future_impl.dart:639
[dart_sdk.js:7028:7](http://localhost:57101/dart_sdk.js)
    _startMicrotaskLoop schedule_microtask.dart:54
    _scheduleImmediateWithPromise async_patch.dart:166
    (Async: promise callback)
    _scheduleImmediateWithPromise async_patch.dart:164
    _scheduleImmediate async_patch.dart:136
    _scheduleAsyncCallback schedule_microtask.dart:69
    _rootScheduleMicrotask zone.dart:1458
    scheduleMicrotask zone.dart:1673
    _asyncCompleteWithValue future_impl.dart:638
    _asyncComplete future_impl.dart:598
    complete future_impl.dart:36
    send binding.dart:366
    runUnaryGuarded zone.dart:1586
    _zonedPlatformMessageResponseCallback platform_dispatcher.dart:381
    replyToPlatformMessage platform_dispatcher.dart:1138
    runUnary zone.dart:1653
    handleValue future_impl.dart:147
    handleValueCallback future_impl.dart:766
    _propagateToListeners future_impl.dart:795
    _complete future_impl.dart:557
    delayed future.dart:421
    internalCallback isolate_helper.dart:48
    (Async: setTimeout handler)
    new isolate_helper.dart:55
    _createTimer async_patch.dart:186
    createTimer zone.dart:1677
    new timer.dart:51
    delayed future.dart:419
    replyToPlatformMessage platform_dispatcher.dart:1136
    <anonymous> platform_dispatcher.dart:437
    runUnary zone.dart:1653
    handleValue future_impl.dart:147
    handleValueCallback future_impl.dart:766
    _propagateToListeners future_impl.dart:795
    _completeWithValue future_impl.dart:566
    <anonymous> future_impl.dart:639
    _microtaskLoop schedule_microtask.dart:40
    _startMicrotaskLoop schedule_microtask.dart:49
    _scheduleImmediateWithPromise async_patch.dart:166
    (Async: promise callback)
    _scheduleImmediateWithPromise async_patch.dart:164
    _scheduleImmediate async_patch.dart:136
    _scheduleAsyncCallback schedule_microtask.dart:69
    _rootScheduleMicrotask zone.dart:1458
    scheduleMicrotask zone.dart:1673
    _asyncCompleteWithValue future_impl.dart:638
    _asyncComplete future_impl.dart:598
    complete future_impl.dart:36
    domHttpRequest dom.dart:733
    _checkAndCall operations.dart:334
    dcall operations.dart:339
    ret dart_sdk.js:62137
    (Async: EventListener.handleEvent)
    callMethod$ js_util_patch.dart:80
    DomEventTargetExtension$124addEventListener dom.dart:136
    domHttpRequest dom.dart:726
    load assets.dart:61
    next self-hosted:1740
    runBody async_patch.dart:84
    _async async_patch.dart:123
    load assets.dart:57
    _sendPlatformMessage platform_dispatcher.dart:436
    sendPlatformMessage platform_dispatcher.dart:326
    send binding.dart:364
    load asset_bundle.dart:256
    next self-hosted:1740
    runBody async_patch.dart:84
    _async async_patch.dart:123
    load asset_bundle.dart:253
    _initCodecs main.dart:48
    moveNext iterable.dart:391
    next dart_sdk.js:7061
    wait future.dart:520
    _initCodecs main.dart:43
    InterpretGeneratorResume self-hosted:1819
    next self-hosted:1740
    _async async_patch.dart:45
    runUnary zone.dart:1653
    handleValue future_impl.dart:147
    handleValueCallback future_impl.dart:766
    _propagateToListeners future_impl.dart:795
    _completeWithValue future_impl.dart:566
    <anonymous> future_impl.dart:639

Safari v16.1:
Unhandled Promise Rejection Error

StackTrace:

throw _ -- errors.dart:266
  collectSkiaObjectsNow -- canvaskit_api.dart:2376
  (anonymous function) -- canvaskit_api:2324
  internalCallback -- isolate helper:48

This is running on macOS 13.0.1
Flutter version 3.3.7
Dart 2.18.4

huycozy wrote this answer on 2022-11-24

@umberto-sonnino, thanks for filing the issue. This issue is reproducible on the latest stable and master channels with provided sample code.
It's only reproducible when running with canvaskit renderer.

  • Canvaskit:
  • HTML:

: No Issue : Issue reproduced

flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.3.9, on macOS 13.0 22A380 darwin-x64, locale en-VN)
    • Flutter version 3.3.9 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (31 hours ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.3)
    • 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 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 70.0.5
    • Dart plugin version 222.4167.21

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • 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

[✓] VS Code (version 1.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 12 (API 31)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 13.0 22A380 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 107.0.5304.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
[!] Flutter (Channel master, 3.6.0-7.0.pre.45, on macOS 13.0 22A380 darwin-x64, locale en-VN)
    • Flutter version 3.6.0-7.0.pre.45 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d0352f55db (3 hours ago), 2022-11-23 20:01:26 -0500
    • Engine revision 9b2895724c
    • Dart version 2.19.0 (build 2.19.0-424.0.dev)
    • DevTools version 2.19.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.3)
    • 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 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 70.0.5
    • Dart plugin version 222.4167.21

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • 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

[✓] VS Code (version 1.73.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 12 (API 31)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 13.0 22A380 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 107.0.5304.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
yjbanov wrote this answer on 2022-12-01

Is it the 100000x100000 one by any chance?

caudetgit wrote this answer on 2022-12-02

@yjbanov The issue isn't specific to that sample image, if that's the question. And that image is actually 4000x1080 and not 100k x 100k (unfortunate filename).

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-12-07
Star Count 147031
Watcher Count 3560
Fork Count 23915
Issue Count 11300

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date