Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: emit an error when CIImage cannot be created #1273

Merged

Conversation

navaronbracke
Copy link
Collaborator

@navaronbracke navaronbracke commented Jan 5, 2025

This PR adds the following changes:

  • adjusts the iOS / MacOS implementation to throw an error when the provided file path is not an image.
  • adjusts the Android implementation to throw an error when the provided file path is not an image. As reported in the issue, it was hanging previously (due to an unhandled IOException)
  • enables Swift Package Manager support in the example app

Fixes #1244

@@ -7,12 +7,10 @@ import android.graphics.Matrix
import android.graphics.Rect
import android.hardware.display.DisplayManager
import android.net.Uri
import android.os.Build
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports

val inputImage: InputImage

try {
inputImage = InputImage.fromFilePath(activity, image)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the docs of InputImage.fromFilePath it throws an IOException if the path is not an image (with the error message "The image Uri could not be resolved.")

I believe not handling this here is why the method was not returning (we get an unhandled error, instead of calling the callbacks that would resolve the method call)

@@ -7,7 +7,7 @@ version: 0.0.1

environment:
sdk: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"
flutter: ">=3.27.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Swift Package Manager support is now available on stable, I updated the constraint here

@@ -16,6 +16,7 @@
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
A277671F4E603C31E191FCBF /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB50C06655B1959BAA8EAF64 /* Pods_Runner.framework */; };
F8C489EFA0FC3A131EBA1838 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F20A7A668B7797BBB5443C1 /* Pods_RunnerTests.framework */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file were generated by the Swift Package manager project migrator, during a flutter run.

@@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was generated by the Swift Package manager project migrator, during a flutter run.

@navaronbracke navaronbracke merged commit 38eee0b into juliansteenbakker:ios-vision Jan 5, 2025
4 checks passed
@navaronbracke navaronbracke deleted the analyze_image_fixes branch January 5, 2025 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant