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

analyzeImage not throw error when picking non-Qr image on iOS #1244

Open
congnguyen-prismtech opened this issue Nov 21, 2024 · 5 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@congnguyen-prismtech
Copy link

I'm using analyzeImage to read a non-QR after picking it on iOS. The app not throw any exception. So that i can't show the toast when picked failure. Please help me solve it.

@navaronbracke
Copy link
Collaborator

navaronbracke commented Nov 22, 2024

In that case you probably receive null as result? This is intentional behavior, though, so that users don't have to handle an extra error. You probably want to check that the file is an image file, before passing it to analyze image.

@congnguyen-prismtech
Copy link
Author

Hi @navaronbracke there is a different between Android and iOS.
in Android, after picking a non-QR code, it continue execute the next line. So that i can show a toast: "Your QR code is not valid".
Meanwhile, in iOS, the function is stopped at analyzeImage and not execute the next line whenever i pick a non-QR code. Therefore, it can't show the toast: "Your QR code is not valid".
My expectation is can show that toast whenever i pick a non-QR code in iOS.

@navaronbracke
Copy link
Collaborator

I see. Yes, this should not have behavioral differences between platforms.

@navaronbracke navaronbracke self-assigned this Nov 25, 2024
@navaronbracke navaronbracke added the bug Something isn't working label Nov 25, 2024
@navaronbracke
Copy link
Collaborator

On Android it returns the error from MLKit:
https://github.com/juliansteenbakker/mobile_scanner/blob/master/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScanner.kt#L487 and https://github.com/juliansteenbakker/mobile_scanner/blob/master/android/src/main/kotlin/dev/steenbakker/mobile_scanner/MobileScannerHandler.kt#L30-L35

But on the old iOS implementation, it does not: https://github.com/juliansteenbakker/mobile_scanner/blob/master/ios/Classes/MobileScanner.swift#L435-L447

On the new iOS/MacOS version (which uses the Vision API), we return nil:
https://github.com/juliansteenbakker/mobile_scanner/blob/ios-vision/darwin/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift#L652-L666

I'll probably fix this in the new implementation, as the Vision API generally outperforms the MLKit one.

Thanks for reporting!

@lpl-code-github
Copy link

Even though I selected an image with a QR code, I didn't analyze it? Always waiting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants