yekeskin / flutter_avif

A flutter plugin to view and encode avif images.
https://pub.dev/packages/flutter_avif
MIT License
53 stars 15 forks source link

FfiException(PANIC_ERROR, Decoder connection lost. sending on a closed channel, null) #11

Closed cruvie closed 1 year ago

cruvie commented 1 year ago

Hi, thanks for your work about the pkg, but I encounter an err just a simple use of AvifImage.file,

AvifImage.file(
                File(filePath),
                width: width,
                height: height,
                fit: BoxFit.cover,
              )
E/flutter ( 4349): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FfiException(PANIC_ERROR, Decoder connection lost. sending on a closed channel, null)
E/flutter ( 4349): #0      FlutterRustBridgeBase._transformRust2DartMessage (package:flutter_rust_bridge/src/basic.dart:129:9)
E/flutter ( 4349): #1      FlutterRustBridgeBase.executeNormal.<anonymous closure> (package:flutter_rust_bridge/src/basic.dart:70:9)
E/flutter ( 4349): <asynchronous suspension>
yekeskin commented 1 year ago

On which platform are you receiving this error? Can you also check your file here to verify it is in compliance with the avif spec?

cruvie commented 1 year ago

On which platform are you receiving this error? Can you also check your file here to verify it is in compliance with the avif spec?

image in Android Studio on MacOS 13.1 M2

Hi , I tried again and get other err iShot_2023-04-25_20.59.40.avif.zip

I/FilePickerUtils( 5154): Caching from URI: content://com.android.providers.downloads.documents/document/msf%3A1000000025
E/SurfaceSyncer( 5154): Failed to find sync for id=0
E/SurfaceSyncer( 5154): Failed to find sync for id=1
E/SurfaceSyncer( 5154): Failed to find sync for id=2
E/SurfaceSyncer( 5154): Failed to find sync for id=3
E/SurfaceSyncer( 5154): Failed to find sync for id=4
E/SurfaceSyncer( 5154): Failed to find sync for id=5
E/SurfaceSyncer( 5154): Failed to find sync for id=6
E/SurfaceSyncer( 5154): Failed to find sync for id=7
E/SurfaceSyncer( 5154): Failed to find sync for id=8
D/FilePickerUtils( 5154): File loaded and cached at:/data/user/0/cmk.insonetui.in_so_net_ui/cache/file_picker/iShot_2023-04-25_20.59.40.avif
D/FilePickerDelegate( 5154): File path:[com.mr.flutter.plugin.filepicker.FileInfo@59e5e3a]
I/FilePickerUtils( 5154): Caching from URI: content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FiShot_2023-04-25_20.59.40.avif
D/FilePickerUtils( 5154): File loaded and cached at:/data/user/0/cmk.insonetui.in_so_net_ui/cache/file_picker/iShot_2023-04-25_20.59.40.avif
D/FilePickerDelegate( 5154): File path:[com.mr.flutter.plugin.filepicker.FileInfo@c57bd31]
E/SurfaceSyncer( 5154): Failed to find sync for id=0
E/SurfaceSyncer( 5154): Failed to find sync for id=1
E/SurfaceSyncer( 5154): Failed to find sync for id=2
E/SurfaceSyncer( 5154): Failed to find sync for id=3
E/SurfaceSyncer( 5154): Failed to find sync for id=4
E/SurfaceSyncer( 5154): Failed to find sync for id=5
E/SurfaceSyncer( 5154): Failed to find sync for id=6
E/SurfaceSyncer( 5154): Failed to find sync for id=7
E/SurfaceSyncer( 5154): Failed to find sync for id=8
E/SurfaceSyncer( 5154): Failed to find sync for id=9
E/SurfaceSyncer( 5154): Failed to find sync for id=10
E/SurfaceSyncer( 5154): Failed to find sync for id=11
E/SurfaceSyncer( 5154): Failed to find sync for id=12
E/SurfaceSyncer( 5154): Failed to find sync for id=13
E/flutter ( 5154): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FfiException(PANIC_ERROR, called `Result::unwrap()` on an `Err` value: PoisonError { .. }, null)
E/flutter ( 5154): #0      FlutterRustBridgeBase._transformRust2DartMessage (package:flutter_rust_bridge/src/basic.dart:129:9)
E/flutter ( 5154): #1      FlutterRustBridgeBase.executeNormal.<anonymous closure> (package:flutter_rust_bridge/src/basic.dart:70:9)
E/flutter ( 5154): <asynchronous suspension>
yekeskin commented 1 year ago

The image you sent is in PNG format not AVIF. It cannot be viewed with this plugin.

cruvie commented 1 year ago

The image you sent is in PNG format not AVIF. It cannot be viewed with this plugin.

oh, sorry it's my fault ,I upload the wrong file, I have updated the file above .

yekeskin commented 1 year ago

I tested the file you sent on an x86 android emulator and an arm64 physical device. Rendered fine on both. I think the problem might be related to flutter_avif binaries not running correctly on your emulator setup. I cannot run the exact same setup because your setup requires an arm based mac and mine is an intel one. I will investigate further and in the meantime you can try to test your project on a physical android device.

cruvie commented 1 year ago

I have fully tested today Build env MacOS 13.1 M2, flutter 3.7.8, flutter_avif: ^1.1.0, shared_preferences: ^2.1.0 1 on Android (emulator/physical) and MacOS error like this

flutter: `flutter_avif_macos` threw an error: Invalid argument(s): Failed to load dynamic library 'libflutter_avif.dylib': dlopen(libflutter_avif.dylib, 0x0001): tried: 'libflutter_avif.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibflutter_avif.dylib' (no such file), '/Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/build/macos/Build/Products/Debug/InSo.app/Contents/Frameworks/FlutterMacOS.framework/Versions/A/./libflutter_avif.dylib' (no such file), '/Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/build/macos/Build/Products/Debug/InSo.app/Contents/Frameworks/FlutterMacOS.framework/Versions/A/../../../libflutter_avif.dylib' (no such file), '/usr/lib/swift/libflutter_avif.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libflutter_avif.dylib' (no such file), '/Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/build/macos/Build/Products/Debug/InSo.app/Contents/Frameworks/libflutter_avif.dylib' (no such file), '/Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/build/macos/Build/Products/Debug/InSo.app/Contents/MacOS/Frameworks/libflutter_avif.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libflutter_avif.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libflutter_avif.dylib' (no such file), '/Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/build/macos/Build/Products/Debug/InSo.app/Contents/MacOS/../Frameworks/flutter_avif_macos.framework/Resources/libflutter_avif.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/usr/lib/swift/libflutter_avif.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libflutter_avif.dylib' (no such file), '/Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/build/macos/Build/Products/Debug/InSo.app/Contents/Frameworks/libflutter_avif.dylib' (no such file), '/usr/lib/libflutter_avif.dylib' (no such file, not in dyld cache), 'libflutter_avif.dylib' (no such file), '/usr/local/lib/libflutter_avif.dylib' (no such file), '/usr/lib/libflutter_avif.dylib' (no such file, not in dyld cache). The app may not function as expected until you remove this plugin from pubspec.yaml
Debug service listening on ws://127.0.0.1:55785/77j9PheCAug=/ws
Syncing files to device macOS...
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

for Android if I build a release-app before running in debug mode (emulator/physical), it will work fine, I don't know why, and the release-app works fine ,too.

for IOS emulator, this error like this, and cannot build

Failed to build iOS app
Error (Xcode): In /Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/ios/Pods/../.symlinks/plugins/flutter_avif_ios/ios/libflutter_avif.a(flutter_avif-9a73c8cc82382679.flutter_avif.0423e485-cgu.0.rcgu.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/xhkang/KangXH/Coding/Uncomplete-Projects/my_app/my_app_ui/ios/Pods/../.symlinks/plugins/flutter_avif_ios/ios/libflutter_avif.a' for architecture arm64

Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)

Could not build the application for the simulator.
Error launching application on iPhone 14 Pro Max.

for shared_preferences , I think it caused by flutter_avif(because if I remove the plugin the error disappeared)

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

Btw, I found that if I use this plugin, the app will increase by approximately 10MB

iShot_2023-04-27_00 36 06
yekeskin commented 1 year ago

It is normal that the size increases because the flutter_avif binaries being added to your app. You can use abi splitting to reduce the impact.

You are getting the errors on ios and mac builds because we don't ship the required binaries for arm based macs yet. Will try to add them to the next release.