fluttercandies / flutter_image_compress

flutter image compress
MIT License
642 stars 217 forks source link

[Bug report] compressAndGetFile() "Unexpectedly found nil ..." on macOS #314

Open eauw opened 3 months ago

eauw commented 3 months ago

Version

2.3.0

Platforms

macOS

Device Model

MacBook Pro M1 Pro (macOS Sonoma 14.5)

flutter info

[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale en-DE)
    • Flutter version 3.22.3 on channel stable at /Users/me/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (vor 8 Tagen), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/me/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/me/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode_15_4/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Chromium.app/Contents/MacOS/Chromium

[✓] Android Studio (version 2023.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 17.0.10+0-17.0.10b1087.21-11572160)

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

[✓] VS Code (version 1.74.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.58.0

[✓] Connected device (4 available)
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Chromium 110.0.5445.0

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

• No issues found!

How to reproduce?

I found a bug when I call the following code

final jpg = await FlutterImageCompress.compressAndGetFile(
      filePath,
      newPath,
      quality: 100,
    );

Where filePath is the path to an existing heic file and newPath something like ~/test/file.jpg or ~/Downloads/file.jpg. I also tried getDownloadsDirectory() (path_provider).

The error is always the same. The app is crashing with the following message. flutter_image_compress_macos/FlutterImageCompressMacosPlugin.swift:299: Fatal error: Unexpectedly found nil while unwrapping an Optional value

None of the used values is null which I tested with the debugger.

I'm using pretty much the same logic succesfully in an iOS app.

Logs

No response

Example code (optional)

No response

Contact

No response