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

System.NullReferenceException in BarcodeResult.GetHashCode() still an issue in 1.5.9 with iOS #106

Open
Cannedfood opened this issue Nov 4, 2024 · 4 comments

Comments

@Cannedfood
Copy link

Cannedfood commented Nov 4, 2024

I saw that there was a fix in 1.5.9. committed, but our App is still crashing at the same location.

*** Terminating app due to uncaught exception 'System.NullReferenceException', reason: 'Object reference not set to an instance of an object. (System.NullReferenceException)
   at BarcodeScanning.BarcodeResult.GetHashCode()
   at System.Collections.Generic.HashSet`1[[BarcodeScanning.BarcodeResult, BarcodeScanning.Native.Maui, Version=1.5.9.0, Culture=neutral, PublicKeyToken=null]].AddIfNotPresent(BarcodeResult value, Int32& location)
   at System.Collections.Generic.HashSet`1[[BarcodeScanning.BarcodeResult, BarcodeScanning.Native.Maui, Version=1.5.9.0, Culture=neutral, PublicKeyToken=null]].Add(BarcodeResult item)
   at BarcodeScanning.Methods.ProcessBarcodeResult(VNBarcodeObservation[] inputResults, HashSet`1 outputResults, AVCaptureVideoPreviewLayer previewLayer)
   at BarcodeScanning.BarcodeAnalyzer.<.ctor>b__4_0(VNRequest request, NSError error)
   at ObjCRuntime.Trampolines.SDVNRequestCompletionHandler.Invoke(IntPtr block, NativeHandle request, NativeHandle error) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/ObjCRuntime/Trampolines.g.cs:line 50766
   at Vision.VNSequenceRequestHandler.Perform(VNRequest[] requests, CMSampleBuffer sampleBuffer, NSError& error) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/Vision/VNSequenceRequestHandler.g.cs:line 355
   at BarcodeScanning.BarcodeAnalyzer.DidOutputSampleBuffer(AVCaptureOutput captureOutput, CMSampleBuffer sampleBuffer, AVCaptureConnection connection)
@afriscic
Copy link
Owner

afriscic commented Nov 4, 2024

I see the crash happens on iOS/MacOS.
Both DisplayValue and RawValue are bound to PayloadStringValue so i guess PayloadStringValue is null or empty, but this is very strange.
I'll update the code in next release to ignore this barcodes or to get the value from PayloadData.

Can you please share the barcode image and OS version where it crashes.

@markuspalme
Copy link

It happens when there are a lot of barcodes visible at the same time:

image

iOS 18.1.

@markuspalme
Copy link

I think that this fix #100 would still be of value - it makes the class BarcodeResult more robust.

@afriscic
Copy link
Owner

I'll do one more net8 release next week as there is a major AndroidX.Camera update so I have to update a few things.
What I have noticed is that I didn't have <Nullable>enable</Nullable> so I'll do a hardening on a dozen of possible null reference exceptions.

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

3 participants