flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.45k stars 27.12k forks source link

[Impeller] [Flutter 3.10]: Codec failed to produce an image #126768

Closed sinahamedi67 closed 1 year ago

sinahamedi67 commented 1 year ago

Is there an existing issue for this?

Steps to reproduce

  1. Create a new flutter project or open an existing one
  2. Try showing an image using Image.Network or Image.asset on iOS simulator

It happens on different ios simulator with any images from network or assets. Using cached_network_image package also produces the same result. This bug produced after upgrading from Flutter 3.3.0 to 3.10

Update: It works fine until 3.7.12

Expected results

Showing the image successfully

Actual results

Following exception throws:

======== Exception caught by image resource service ================================================
The following _Exception was thrown resolving an image frame:
Exception: Codec failed to produce an image, possibly due to invalid image data.

When the exception was thrown, this was the stack: 
Image provider: NetworkImage("https://picsum.photos/200/300", scale: 1.0)
Image key: NetworkImage("https://picsum.photos/200/300", scale: 1.0)
====================================================================================================

Code sample

Code sample ```dart import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( body: Center( child: Image.network( 'https://picsum.photos/200/300', ), ), ), ); } } ```

Screenshots or Video

Screenshots / Video demonstration ![image](https://github.com/flutter/flutter/assets/78305390/40f45b15-17da-4ec5-a311-d53fd1966f8f)

Logs

Logs ``` [ +816 ms] com.example.images: 64717 [ ] Waiting for VM Service port to be available... [ +899 ms] VM Service URL on device: http://127.0.0.1:55892/U1waQeMPT4c=/ [ +6 ms] Caching compiled dill [ +255 ms] Connecting to service protocol: http://127.0.0.1:55892/U1waQeMPT4c=/ [ +347 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:55892/U1waQeMPT4c=/. [ +256 ms] DDS is listening at http://127.0.0.1:55895/LMq3joqnDbk=/. [ +95 ms] Successfully connected to service protocol: http://127.0.0.1:55892/U1waQeMPT4c=/ [ +91 ms] DevFS: Creating new filesystem on the device (null) [ +95 ms] DevFS: Created new filesystem on the device (file:///Users/flutter/Library/Developer/CoreSimulator/Devices/D4909C3C-EA95-4F22-A52C-62D212410360/data/Containers/Data/Application/A70E296E-62C3-420B-849C-DF75398898BA/t mp/imagesgj5pit/images/) [ +2 ms] Updating assets [ +356 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for more information see #56466. [ +8 ms] Syncing files to device iPhone 13 Pro... [ +3 ms] Compiling dart to kernel with 0 updated files [ ] Processing bundle. [ +1 ms] <- recompile package:images/main.dart 7793d8de-8aba-442e-9871-f95e67dd6cd1 [ ] <- 7793d8de-8aba-442e-9871-f95e67dd6cd1 [ +11 ms] Bundle processing done. [ +154 ms] Updating files. [ ] DevFS: Sync finished [ +2 ms] Syncing files to device iPhone 13 Pro... (completed in 173ms) [ +1 ms] Synced 0.0MB. [ +2 ms] <- accept [ +18 ms] Connected to _flutterView/0x7ff36102ca20. [ +206 ms] Flutter run key commands. [ +15 ms] r Hot reload. πŸ”₯πŸ”₯πŸ”₯ [ +2 ms] R Hot restart. [ ] h List all available interactive commands. [ +91 ms] d Detach (terminate "flutter run" but leave application running). [ ] c Clear the screen [ ] q Quit (terminate the application on the device). [ +1 ms] A Dart VM Service on iPhone 13 Pro is available at: http://127.0.0.1:55895/LMq3joqnDbk=/ [ +53 ms] The Flutter DevTools debugger and profiler on iPhone 13 Pro is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:55895/LMq3joqnDbk=/ [+1704 ms] ══║ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• The following _Exception was thrown resolving an image frame: Exception: Codec failed to produce an image, possibly due to invalid image data. When the exception was thrown, this was the stack Image provider: NetworkImage("https://picsum.photos/200/300", scale: 1.0) Image key: NetworkImage("https://picsum.photos/200/300", scale: 1.0) ════════════════════════════════════════════════════════════════════════════════════════════════════ ``` Complete `flutter run --verbose`: https://pastebin.com/w1gyiz9M

Flutter Doctor output

Doctor output ```console [βœ“] Flutter (Channel stable, 3.10.0, on macOS 12.6 21G115 darwin-x64, locale en-US) β€’ Flutter version 3.10.0 on channel stable at /Users/flutter/Downloads/flutter β€’ Upstream repository https://github.com/flutter/flutter.git β€’ Framework revision 84a1e904f4 (5 days ago), 2023-05-09 07:41:44 -0700 β€’ Engine revision d44b5a94c9 β€’ Dart version 3.0.0 β€’ DevTools version 2.23.1 [βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.0) β€’ Android SDK at /Users/flutter/Library/Android/sdk β€’ Platform android-33, build-tools 33.0.0 β€’ Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 14.0) β€’ Xcode at /Users/flutter/Downloads/Xcode14/Xcode.app/Contents/Developer β€’ Build 14A309 β€’ CocoaPods version 1.12.1 [βœ“] Chrome - develop for the web β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [βœ“] Android Studio (version 2022.2) β€’ 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 17.0.6+0-17.0.6b802.4-9586694) [βœ“] Connected device (3 available) β€’ iPhone 13 Pro (mobile) β€’ D4909C3C-EA95-4F22-A52C-62D212410360 β€’ ios β€’ com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator) β€’ macOS (desktop) β€’ macos β€’ darwin-x64 β€’ macOS 12.6 21G115 darwin-x64 β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 113.0.5672.92 [βœ“] Network resources β€’ All expected network resources are available. β€’ No issues found! ```
EnduringBeta commented 1 year ago

I can echo that what I'm experiencing seems to be the same issue after upgrading to Flutter 3.10. I have yet to see it visually, but it's appearing in CI/CD logs of integration tests using the iOS simulator. I use AssetImage.

zrpra commented 1 year ago

this also happened to me on iOS, it seems to be caused by the impeller engine as it also happens on android when i enable it. it only occurs on debug mode, on profile and release seems to be okay

huycozy commented 1 year ago

Hi everyone. I can not reproduce this issue on the latest stable and master channels using iOS emulator 16.4. It does not happen even with asset or network image.

Demo
flutter doctor -v (stable and master) ```bash [βœ“] Flutter (Channel stable, 3.10.0, on macOS 13.0.1 22A400 darwin-x64, locale en-VN) β€’ Flutter version 3.10.0 on channel stable at /Users/huynq/Documents/GitHub/flutter β€’ Upstream repository https://github.com/flutter/flutter.git β€’ Framework revision 84a1e904f4 (35 hours ago), 2023-05-09 07:41:44 -0700 β€’ Engine revision d44b5a94c9 β€’ Dart version 3.0.0 β€’ DevTools version 2.23.1 [βœ“] Android toolchain - develop for Android devices (Android SDK version 32.0.0) β€’ Android SDK at /Users/huynq/Library/Android/sdk β€’ Platform android-33, build-tools 32.0.0 β€’ ANDROID_HOME = /Users/huynq/Library/Android/sdk β€’ Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 14.3) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ Build 14E222b β€’ CocoaPods version 1.11.3 [βœ“] Chrome - develop for the web β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [βœ“] Android Studio (version 2022.2) β€’ 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 17.0.6+0-17.0.6b802.4-9586694) [βœ“] VS Code (version 1.78.0) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension version 3.62.0 [βœ“] Connected device (2 available) β€’ macOS (desktop) β€’ macos β€’ darwin-x64 β€’ macOS 13.0.1 22A400 darwin-x64 β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 113.0.5672.92 [βœ“] Network resources β€’ All expected network resources are available. β€’ No issues found! ``` ```bash [!] Flutter (Channel master, 3.11.0-6.0.pre.63, on macOS 13.0.1 22A400 darwin-x64, locale en-VN) β€’ Flutter version 3.11.0-6.0.pre.63 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 7b8f7a2a64 (5 hours ago), 2023-05-14 17:42:29 -0400 β€’ Engine revision 326de1d849 β€’ Dart version 3.1.0 (build 3.1.0-110.0.dev) β€’ DevTools version 2.23.1 β€’ 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 32.0.0) β€’ Android SDK at /Users/huynq/Library/Android/sdk β€’ Platform android-33, build-tools 32.0.0 β€’ ANDROID_HOME = /Users/huynq/Library/Android/sdk β€’ Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 14.3) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ Build 14E222b β€’ CocoaPods version 1.11.3 [βœ“] Chrome - develop for the web β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [βœ“] Android Studio (version 2022.2) β€’ 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 17.0.6+0-17.0.6b802.4-9586694) [βœ“] VS Code (version 1.78.1) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension version 3.64.0 [βœ“] Connected device (2 available) β€’ macOS (desktop) β€’ macos β€’ darwin-x64 β€’ macOS 13.0.1 22A400 darwin-x64 β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 113.0.5672.92 [βœ“] Network resources β€’ All expected network resources are available. ! Doctor found issues in 1 category. ```

@sinahamedi67 Since it's related to picsum API, the image could not be existing. So, is there any percentage occurrence of the issue? Or does it occur everytime?

@zrpra Does the issue still persist if you disable Impeller?

HasanAlqaisi commented 1 year ago

I have the same issue on the IOS simulator. This happened after upgrading to v3.10.0. I ran the app with flutter run --no-enable-impeller and it worked.

dnfield commented 1 year ago

I tried this out and could not reproduce it on a simulator.

I do notice that the doctor output is showing you're on Xcode 14.0. Can you try upgrading to the latest Xcode and see if it still reproduces? I'm running on Xcode 14.3.

dryasbk commented 1 year ago

I have the same issue with the ios simulator. (Work fine with the Android emulator.)

I tried both Xcode 14.2 and Xcode 14.3

The same project worked fine with Flutter 2.7, then updated to Flutter 3.10 and got the same error!!

I searched for Hasan Alqaisi's above solution.

https://github.com/flutter/flutter/issues/126768#issuecomment-1547628866

Then follow the instruction :

To disable Impeller on iOS when deploying your app, add the following tags under the top-level tag in your app's Info.plist file.

from
https://docs.flutter.dev/perf/impeller#ios

<key>FLTEnableImpeller</key> <false />

This allows using flutter run. And it has worked fine.

EnduringBeta commented 1 year ago

I have the same issue on the IOS simulator. This happened after upgrading to v3.10.0. I ran the app with flutter run --no-enable-impeller and it worked.

This worked for me and my GitHub Actions error when testing on iOS simulator.

zrpra commented 1 year ago

@zrpra Does the issue still persist if you disable Impeller?

when impeller is disabled the image shows as normal

sinahamedi67 commented 1 year ago

@sinahamedi67 Since it's related to picsum API, the image could not be existing. So, is there any percentage occurrence of the issue? Or does it occur everytime?

Yes it occurs every time, it happened on my own website first, all of the online images had the same problem. I used picsum just to write a sample.

Does the issue still persist if you disable Impeller?

β€ŒNo, by disabling the impeller both my own project and sample works fine.

huycozy commented 1 year ago

@sinahamedi67 I also try on the same emulator as yours (iPhone 13 Pro, iOS 16.0) but still can not reproduce this. Can you try checking this on another emulator if any?

Maieldd commented 1 year ago

Meu smartphone tΓ‘ sendo monitorado e eu acho que Γ© por esse flutter ou sla, sei que tΓ‘ conectado ao ios 16 e nΓ£o sei o que fazer, tΓ΄ triste demais

msfstef commented 1 year ago

we're experiencing the same issue, seems to only occur on CI but cannot reproduce locally - is there a workaround other than disabling Impeller?

mmcdon20 commented 1 year ago

I am experiencing the same issue.

I made a github repo to reproduce this issue. (https://github.com/mmcdon20/displayimage/tree/master)

This error seems to happen on some iOS simulators but not others. For me specifically the iPhone 5s with iOS 12.4 is one simulator where this error occurs.

Screen Shot

In the screenshot above both simulators are running the same app.

The simulator on the right is producing this error.


======== Exception caught by image resource service ================================================
The following _Exception was thrown resolving an image frame:
Exception: Codec failed to produce an image, possibly due to invalid image data.

When the exception was thrown, this was the stack: 
Image provider: AssetImage(bundle: null, name: "images/bottle.jpg")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#5d83e(), name: "images/bottle.jpg", scale: 1.0)
====================================================================================================

The app runs on both if the --no-enable-impeller flag is passed, so appears to be directly related to impeller.

dnfield commented 1 year ago

Flutter does not support iPhone 5s anymore. Lowest version we support is 11.

mmcdon20 commented 1 year ago

@dnfield iOS 11? The simulator is running iOS 12.4 on the 5s. You can see it in the screenshot that its 12.4.

dnfield commented 1 year ago

No, iPhone 11 :)

The lowest iPhone simulator I can create is an 8 locally. I can't even get runtimes at this point for lower than that. On an iPhone 8 simulator your demo app works fine for me locally.

dnfield commented 1 year ago

https://docs.flutter.dev/reference/supported-platforms#deploying-flutter

mmcdon20 commented 1 year ago

@dnfield The table you are referencing appears to be iOS versions though, not iPhone versions (especially considering iPhone 16 doesn't exist yet). iOS 11-15 falls in the best effort category not the unsupported category.

dnfield commented 1 year ago

Ahh you are right.

Sorry about that. Let me check.

dnfield commented 1 year ago

I am unable to reproduce this on the oldest phone I can access. It still seems like this might be more of an issue on older simulators on older versions of macOS which I also don't currently have access to.

Juliotati commented 1 year ago

@sinahamedi67 🚨 Just a heads up, I think that this is not an impeller issue. I'm experiencing the same issue on both:

android & iOS on emulator and device debug, profile, and release mode

Extra info:

image

Screenshot

![image](https://github.com/flutter/flutter/assets/59662912/3ceb9c9b-efa9-44e5-af14-7a1c47a35e3f)

Logs

W/Parcel  (12476): Expecting binder but got null!
E/HeifDecoderImpl(12476): decode: videoFrame is a nullptr
E/FlutterJNI(12476): Failed to decode image
E/FlutterJNI(12476): java.io.IOException: getPixels failed with error invalid input
E/FlutterJNI(12476):    at android.graphics.ImageDecoder.nDecodeBitmap(Native Method)
E/FlutterJNI(12476):    at android.graphics.ImageDecoder.decodeBitmapInternal(ImageDecoder.java:1780)
E/FlutterJNI(12476):    at android.graphics.ImageDecoder.decodeBitmapImpl(ImageDecoder.java:1942)
E/FlutterJNI(12476):    at android.graphics.ImageDecoder.decodeBitmap(ImageDecoder.java:1927)
E/FlutterJNI(12476):    at io.flutter.embedding.engine.FlutterJNI.decodeImage(FlutterJNI.java:538)

Versions

Flutter 3.7.12 β€’ channel stable β€’ https://github.com/flutter/flutter.git
Framework β€’ revision 4d9e56e694 (4 weeks ago) β€’ 2023-04-17 21:47:46 -0400
Engine β€’ revision 1a65d409c7
Tools β€’ Dart 2.19.6 β€’ DevTools 2.20.1
dnfield commented 1 year ago

@Juliotati - you are seeing a similar exception message for a different reason. You are also on an older version of Flutter. AVIF support is platform specific in Flutter and not all platforms support it.

sinahamedi67 commented 1 year ago

@sinahamedi67 I also try on the same emulator as yours (iPhone 13 Pro, iOS 16.0) but still can not reproduce this. Can you try checking this on another emulator if any?

Yes it happens on other simulators too. Also I've upgraded my macos & xcode to the latest versions and still have this bug. New flutter doctor:


[βœ“] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E772610a darwin-x64, locale en-US)
    β€’ Flutter version 3.10.0 on channel stable at /Users/flutter/Downloads/flutter
    β€’ Upstream repository https://github.com/flutter/flutter.git
    β€’ Framework revision 84a1e904f4 (9 days ago), 2023-05-09 07:41:44 -0700
    β€’ Engine revision d44b5a94c9
    β€’ Dart version 3.0.0
    β€’ DevTools version 2.23.1

[βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    β€’ Android SDK at /Users/flutter/Library/Android/sdk
    β€’ Platform android-33, build-tools 33.0.2
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS (Xcode 14.3)
    β€’ Xcode at /Users/flutter/Downloads/Xcode14.3/Xcode.app/Contents/Developer
    β€’ Build 14E222b
    β€’ CocoaPods version 1.12.1

[βœ“] Chrome - develop for the web
    β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[βœ“] Android Studio (version 2022.2)
    β€’ 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 17.0.6+0-17.0.6b802.4-9586694)

[βœ“] Connected device (3 available)
    β€’ iPhone 14 Pro (mobile) β€’ 4B87186A-F646-430F-89EC-4A221B9C4CEB β€’ ios            β€’ com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    β€’ macOS (desktop)        β€’ macos                                β€’ darwin-x64     β€’ macOS 13.3.1 22E772610a darwin-x64
    β€’ Chrome (web)           β€’ chrome                               β€’ web-javascript β€’ Google Chrome 113.0.5672.126

[βœ“] Network resources
    β€’ All expected network resources are available.

β€’ No issues found!
huycozy commented 1 year ago

I still can not reproduce this issue on my end. The image is always shown as expected. If anyone is able to replicate this consistently and can find a pattern to replicate it, please write a comment.

eduardofcr commented 1 year ago

I have the same issues, for all pictures, with asset images, when using emulator.

sinahamedi67 commented 1 year ago

Not sure if that has anything to do with it, but I'm using macOS on a VMware virtual machine. It seems that other users in this thread also have this bug in their CI/CD process. So perhaps Impeller relies on a library or dependency that doesn't function well on virtual machines.

xonaman commented 1 year ago

Same issue here, using iOS simulator

fuzzybinary commented 1 year ago

This is failing for me on iOS in CI as well, but not every time. I haven't been able to reproduce locally. The differences between environments:

Both should be using iPhone 14 simulators on the latest versions of XCode and iOS.

Going go work around by using --no-enable-impeller on CI for now.

chinmaygarde commented 1 year ago

@sinahamedi67 @fuzzybinary The observation that this happens on CI that may have a virtualized environment is intriguing. And could also explain our difficulty in reproducing it.

W.r.t texture management, Impeller differs from the existing backend in one key way. Before Impeller, when decompressing images, the engine would create an uncompressed texture onto the heap before transferring this to GPU device memory and further modifying its usage there. Impeller elides this copy on the heap and directly decompresses into GPU device memory mapped into the process. This reduces memory usage spikes during texture decompression. But this also depends on carefully considering device capabilities. We thought we did our due diligence by testing on the devices and simulators but haven't considered the implications of a virtualized environment with GPU passthrough.

We still haven't reproduced this issue ourselves but we are speculatively disabling this optimization on the simulators in https://github.com/flutter/engine/pull/42161 while we investigate some more.

Some potential threads to keep pulling on:

dnfield commented 1 year ago
  • @jonahwilliams @dnfield Can we land and cherry-pick the speculative "fix" by Monday? Its low risk and simulator only. We can then get more feedback. With luck, folks won't have to work around this like @fuzzybinary had to.

I think it's a low risk cherry pick, but once it rolls into the framework it' dbe great if someone on this thread who's been able to reproduce the issue (e.g. on CI) can make sure the issue goes away with that change. Otherwise we're cherry picking a pretty speculative fix that might cause other issues and has no tests...

jonahwilliams commented 1 year ago

I would add that unless someone can confirm that the patch works (once it rolls into main) we will not cherry pick it.

jonahwilliams commented 1 year ago

The flutter commit d211dc141a98d21bb5ebb2baddc3cd4cc9e64f27 contains an updated version of image decoding for the simulators. Someone who can reproduce the issue will need to verify the change had an impact. We're also working on bubbling up the exact error message from the engine.

sinahamedi67 commented 1 year ago

The flutter commit d211dc1 contains an updated version of image decoding for the simulators. Someone who can reproduce the issue will need to verify the change had an impact. We're also working on bubbling up the exact error message from the engine.

I checked again with latest version Channel master, 3.11.0-10.0.pre.44 which had that commit, but didn't change the result.

baconcheese113 commented 1 year ago

This is happening on my test runs, not sure how to disable impeller using flutter test

https://github.com/baconcheese113/handle-it-app/actions/runs/5035266919/jobs/9030659451#step:14:18380

jonahwilliams commented 1 year ago

Flutter test does not use impeller

baconcheese113 commented 1 year ago

I no longer get the error in this thread (Codec failed to produce an image) during flutter test when I downgrade https://github.com/baconcheese113/handle-it-app/actions/runs/5041544099/jobs/9041331691

Downgrading from flutter 3.10.0 back to 3.7.7, dart 3.0.0 to 2.17.4, and collection 1.17.1 to 1.17.0

I tested with the iPhone 11 and iPhone 12 simulators

sdegroot commented 1 year ago
  • Seeking proof by contradiction, can anyone on this thread reproduce this in a known non-virtualized environment? If so, can you paste the information in the "About this Mac" and "System Information -> Graphics/Displays" sections?

I have this issue and am not working in a virtualised environment.

about this Mac

Apple M1 Pro:

  Chipset Model:    Apple M1 Pro
  Type: GPU
  Bus:  Built-In
  Total Number of Cores:    16
  Vendor:   Apple (0x106b)
  Metal Support:    Metal 3
  Displays:
Colour LCD:
  Display Type: Built-in Liquid Retina XDR Display
  Resolution:   3024x1964 Retina
  Main Display: Yes
  Mirror:   Off
  Online:   Yes
  Automatically Adjust Brightness:  Yes
  Connection Type:  Internal
C34H89x:
  Resolution:   3440x1440 (UWQHD - Ultra-Wide Quad HD)
  UI Looks like:    3440 x 1440 @ 100.00Hz
  Mirror:   Off
  Online:   Yes
  Rotation: Supported

Leading to

======== Exception caught by image resource service ================================================
The following _Exception was thrown resolving an image frame:
Exception: Codec failed to produce an image, possibly due to invalid image data.

When the exception was thrown, this was the stack: 
Image provider: AssetImage(bundle: null, name: "assets/logo/circular.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#686e0(), name: "assets/logo/circular.png", scale: 1.0)

On

Flutter 3.10.0 β€’ channel stable β€’ https://github.com/flutter/flutter.git
Framework β€’ revision 84a1e904f4 (13 days ago) β€’ 2023-05-09 07:41:44 -0700
Engine β€’ revision d44b5a94c9
Tools β€’ Dart 3.0.0 β€’ DevTools 2.23.1

How can I help?

Edit: After posting this, I upgraded to the latest Flutter and latest MacOS to see if that would make any chance and now it runs fine! Sorry, I guess I can no longer reproduce it. It had also been quite a long time since I restarted my Mac, so either it was due to the upgrade or due to simply restarting my machine.

fuzzybinary commented 1 year ago

@sinahamedi67 @fuzzybinary If possible, can you give us details on the kind of virtualization used by your CI providers? > @sinahamedi67 mentioned VMWare. @fuzzybinary Are you using the same?

We are using Bitrise's Mac OS Intel images. I'm not sure if they're using virtualization or not (likely yes).

@jonahwilliams Flutter test does not use impeller

So far as I can tell, Flutter integration tests do use Impeller. At least removing impeller with the below method fixed my issues

@baconcheese113 This is happening on my test runs, not sure how to disable impeller using flutter test

I could not figure out how to disable this in tests, so I disabled it in the app by adding the following to our plist:

  <key>FLTEnableImpeller</key>
  <false />

This worked for us because I work on a library and I have a separate app for integration tests, so I just disabled it there.

dnfield commented 1 year ago

Flutter test does not use impeller

flutter test can run integration tests now.

jason-simmons commented 1 year ago

Reproduced this in the iOS simulator within a VM running macOS Monterey.

In that environment ShouldUseMetalRenderer is returning false because the Metal device does not support the desired feature set. GetRenderingAPIForProcess then selects the Skia-based software renderer instead of the Impeller Metal renderer.

When an image is decoded ImageDecoder::Make selects the ImageDecoderImpeller based on the settings.enable_impeller flag. But if the engine is using the software renderer, then the ImageDecoderImpeller can not obtain an Impeller context and therefore fails.

chinmaygarde commented 1 year ago

TL;DR: Metal needs to be enabled on a virtualized macOS environment for Flutter simulators.

We discussed Jason's findings as a team and tried to reason about the observed behavior as it was extremely surprising to us.

Our understanding as of right now is as follows. Please disregard our initial hunch as that didn’t pan out and turned out to be the wrong line of investigation.

I’ll follow up on trying to figure out the impact of this as I’m not sure how many CI providers that use virtualization just flat out refuse Metal device creation.

chinmaygarde commented 1 year ago

Doing some more investigating on the impact of this on CI environments:

Since CI environments should support GPU passthrough. We are inclined to make the non-availability of Metal on simulators a fatal error since we weren't even aware folks were routinely running into this unsupported configuration.

Thanks everyone for help pinpointing this. Closing this as there are no pending action items.

chinmaygarde commented 1 year ago

xref the macOS Desktop CI issue.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.