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

iOS 15.4 - Xamarin.iOS - Crash when scanning with AVCaptureEngine #1035

Open
Koub96 opened this issue Mar 24, 2022 · 6 comments
Open

iOS 15.4 - Xamarin.iOS - Crash when scanning with AVCaptureEngine #1035

Koub96 opened this issue Mar 24, 2022 · 6 comments

Comments

@Koub96
Copy link

Koub96 commented Mar 24, 2022

Hello.

Once I updated my device to iOS 15.4, I get the following runtime exception when trying to scan using the AVCaptureEngine.
I use the latest available stable version 2.4.1.

System.Exception: System.NotSupportedException: Codabar has no associated enum value on this platform.
at AVFoundation.AVMetadataObjectTypeExtensions.GetValue (Foundation.NSString constant) [0x0015b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/AVFoundation/AVMetadataObjectType.g.cs:420
at AVFoundation.AVMetadataObject.ArrayToEnum (Foundation.NSString[] arr) [0x00016] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/AVFoundation/AVMetadataObject.cs:51
at AVFoundation.AVCaptureMetadataOutput.get_AvailableMetadataObjectTypes () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/AVFoundation/AVCaptureMetadataOutput.cs:39
at ZXing.Mobile.AVCaptureScannerView.SetupCaptureSession () [0x0041b] in <04e0b9ffeac840b494808f043a3ab5ba>:0
at ZXing.Mobile.AVCaptureScannerView.b__36_0 () [0x00001] in <04e0b9ffeac840b494808f043a3ab5ba>:0
at Foundation.NSActionDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:62
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr_bool(intptr,intptr,intptr,intptr,bool)
at Foundation.NSObject.InvokeOnMainThread (System.Action action) [0x00007] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:619
at ZXing.Mobile.AVCaptureScannerView.StartScanning (System.Action`1[T] scanResultHandler, ZXing.Mobile.MobileBarcodeScanningOptions options) [0x00047] in <04e0b9ffeac840b494808f043a3ab5ba>:0
at ZXing.Mobile.AVCaptureScannerViewController.ViewDidAppear (System.Boolean animated) [0x0006a] in <04e0b9ffeac840b494808f043a3ab5ba>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)

@MFinkBK
Copy link

MFinkBK commented Mar 29, 2022

I also got this, and the a workaround would be to explicitly set the PossibleFormats options value to the list of iOS-supported barcode formats. Then the else block that accesses AvailableMetadataObjectTypes isn't called:

var availableMetaObjTypes = metadataOutput.AvailableMetadataObjectTypes;

I don't know what the solution would be, since the crash happens inside AVCaptureMetadataOutput.cs, which is a Xamarin.iOS project, and isn't contained in ZXing.Net.Mobile.

@Glorfindel83
Copy link

I had a similar problem (not using ZXing but rather iOS built-in scanning) with the same error message (Codabar has no associated enum value on this platform) but I could solve it by simply rebuilding the application with the latest version of Xamarin.iOS (15.8).

@MFinkBK
Copy link

MFinkBK commented Mar 30, 2022

Thanks for the update! It seems the Xamarin.iOS - Xcode 13.3 update added some other barcodes with AVFoundation as well:
xamarin/xamarin-macios#14325

@Koub96
Copy link
Author

Koub96 commented Mar 30, 2022

Thanks for the update! It seems the Xamarin.iOS - Xcode 13.3 update added some other barcodes with AVFoundation as well: xamarin/xamarin-macios#14325

Thank you all for your quick replies.

To overcome this issue, I stopped using the AVCaptureEngine through the scan(bool useAVCaptureEngine) method.
Instead, I now set this method parameter to false and I am using the (custom I suppose) implementation of the ZXing.Net.Mobile, so I can keep scanning codabar barcodes.

To your knowledge, is there any downside to not use the AVCaptureEngine through the scan(bool useAVCaptureEngine) method?

@MFinkBK
Copy link

MFinkBK commented Mar 30, 2022

I have the impression that the AVCaptureEngine is faster than the ZXing library when specifying all barcodes, so I try to continue using it.

@imsam67
Copy link

imsam67 commented May 10, 2022

I'm using this library on an Xamarin Forms 5 app and everything works fine on Android. But if I connect my iPhone Xs to my PC via USB for debug, it doesn't scan at all. It simply doesn't do anything! I then packaged the app for TestFlight testing and installed it on my iPhone Xs, and it crashed the whole app. Here's my SO question about this issue: https://stackoverflow.com/questions/71977226/zxing-scanner-not-scanning-on-ios-in-xamarin-forms-app

Does anyone have a solution for this issue?

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

No branches or pull requests

4 participants