afriscic / BarcodeScanning.Native.Maui

Barcode scanning library for .NET MAUI
https://www.nuget.org/packages/BarcodeScanning.Native.Maui
MIT License
157 stars 30 forks source link

The application sometimes quits unexpectedly #48

Open profsoft opened 5 months ago

profsoft commented 5 months ago

The application sometimes quits unexpectedly without messages when scanning multiple EAN8 codes, if barcodes are scanned at an angle or are partially obscured by thin objects such as wires.

Last messages from output:

[me.scanmauitest] Explicit concurrent mark compact GC freed 23594(1205KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 6627KB/12MB, paused 124us,1.180ms total 21.234ms [OplusStatistics--] IllegalArgumentException:java.lang.IllegalArgumentException: Unknown URL content://com.oplus.statistics.provider/track_event [native] F0000 00:00:1711725226.632530 28971 oned_decoder_client.cc:630] Check failed: recognition_options.HasBarcodeFormat(CODE_39) [native] terminating. [native] F0000 00:00:1711725226.632530 28971 oned_decoder_client.cc:630] Check failed: recognition_options.HasBarcodeFormat(CODE_39) [native] terminating. [libc] Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 28971 (pool-4-thread-3), pid 20585 (me.scanmauitest)

My device: Realme GT Neo 5 RMX3709 Android 14

        <scanner:CameraView
                            OnDetectionFinished="CameraView_OnDetectionFinished"
                            CaptureQuality="High"
                            ForceInverted="False"
                            TapToFocusEnabled="True"
                            AimMode="False"
                            ViewfinderMode="True"
                            BarcodeSymbologies="Ean8"
                            x:Name="Barcode" />
afriscic commented 4 months ago

Hello.

Can you provide some images of barcodes that produce a crash?

profsoft commented 4 months ago

Can you provide some images of barcodes that produce a crash?

IMG20240404165842~2.jpg

afriscic commented 4 months ago

Sorry I couldn't replicate your problem, at least not on my device (Oneplus 7 Pro).

I've observed that in your scenario a lot of System.ObjectDisposedException exceptions is thrown, but it got caught every time and got resolved by camera restarting.

profsoft commented 4 months ago

Before crash, we always have message: oned_decoder_client.cc:630] Check failed: recognition_options.HasBarcodeFormat(CODE_39) But my codes is EAN8, not CODE 39!

afriscic commented 4 months ago

This seems to be an issue with device + MLKit combination, so the only option is to file a bug report here. Have you maybe tried enabling CODE 39 just to see if the crash continues? And does ti happen also if you only scan one code? I'll double check if barcode type flags get propagated through the code properly.

profsoft commented 4 months ago

I try run it on another mobile phone Xiaomi Redmi Note 10 Pro, MIUI 14.0.9, Android 13, result is same. I scan from screen picture on this webpage.

[me.scanmauitest] Explicit concurrent copying GC freed 43778(1757KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 7411KB/14MB, paused 51us,29us total 25.098ms [native] F0000 00:00:1713630347.962242 21040 oned_decoder_client.cc:630] Check failed: recognition_options.HasBarcodeFormat(CODE_39) [native] terminating. [native] F0000 00:00:1713630347.962242 21040 oned_decoder_client.cc:630] Check failed: recognition_options.HasBarcodeFormat(CODE_39) [native] terminating. [libc] Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 21040 (pool-5-thread-1), pid 13023 (me.scanmauitest) [SmartPower.com.companyname.scanmauitest] 1988): visible->died(231653ms) R(process died ) adj=0.

johannes-steurer commented 1 month ago

I had a very similar issue on iOS. My problem was that I navigated away form the Page (GoToAsync("..")) as soon as I got a barcode.

The fix was to set CameraEnabled to false as soon as the first barcode was deteced and only navigated away from the page after 100ms: _ = Task.Delay(100).ContinueWith((t) => ...)

Now it seems solid (not yet tested in production).

PS: @afriscic : Really nice Package and insanely fast detection. Well done

NcaDev1 commented 4 weeks ago

We have the same issue when scanning QR-Codes on iOS. We only want to scan a single QR-code, so we navigate away from the page directly after we receive the first code. The workaround from @johannes-steurer worked for us.