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

QR code Scanning doesn't work on some android phones #200

Open
trampster opened this issue Sep 19, 2024 · 6 comments
Open

QR code Scanning doesn't work on some android phones #200

trampster opened this issue Sep 19, 2024 · 6 comments

Comments

@trampster
Copy link

trampster commented Sep 19, 2024

QR code scanning doesn't work on the following android phones:

  • Motorola G84 5G
  • Sonim XP9900
  • Oppo A54

The camera view shows but it never detects the QR code.

The preloaded camera app on these phones can scan these code successfully. And the same QR code can be scanned by ZXing.Net.Maui on other android and iOS phone models.

image

I have attached logs from trying to scan with the Oppo A54. There are logs from when the scan page is loaded but there is nothing apart from GC collection stats while its actually trying to scan.

OPPO A54 QR code scan logs.txt

We are using:

  • ZXing.Net.Maui version 0.4.0
  • ZXing.Net.Maui.Controls version 0.4.0
  • net8.0
  • Maui version 8.0.80
@trampster
Copy link
Author

trampster commented Sep 19, 2024

After doing some debugging in ZXing.Net.Maui we have discovered that on the phones that don't work a camera frame is being retrieved and sent to ZXing.Net which is returning null on the line:

var b = zxingReader.Decode(ls)?.ToBarcodeResult();

I suspect that there is something wrong with the luminance data.

I have managed to dump the raw data from PixelBufferHolder.Data from working and not working phones.

Interestingly the data on the phone that isn't working is significantly larger, 491 kB instead of 307 kB . Given that both should be 640x480 then they should be exactly the same size.

I've attached the raw YUV data from both the working and the not working phones.

WorkingYUVData.zip
NotWorkingYUVData.zip

@thdigalakis
Copy link

Hi @trampster! Do you find any workaround for this issue?

@trampster
Copy link
Author

No, we have just finished switching to BarcodeScanning.Native.Maui. It uses native scanning on each platform, and it works on all the android and iPhones we have tested on so far, including the ones that fail with ZXing.Net.Maui.

@alex-kir
Copy link

Hi,
I created a pull_request to fix a similar issue
#202
Now it works like a charm for me.

Using platform decoders does not work for Amazon devices.

@trampster
Copy link
Author

Have you tried BarcodeScanning.Native.Maui on amazon devices, it doesn't require Google Play Services (I've tested with it disabled, as it bundles the code with your app). But I don't have access to an amazon device.

We have also found BarcodeScanning.Native.Maui to be a lot faster, if you look at the logs while ZXing.Net.Maui is running it causes a Garbage collection every few seconds because of the massive amounts of memory allocations it does for every single frame, I see that your merge request adds even more memory allocations.

@alex-kir
Copy link

I didn't try BarcodeScanning.Native.Maui but for several years I use my own solution based on Android.Gms.Vision.Barcodes.BarcodeDetector and on amazon devices detector.IsOperational always returns false.
As I understand the Google.MLKit.Vision.BarCode.BarcodeScanning is just a new API for the same functionality.

Now I believe that MLKit will not work too on Amazon devices. Here is an indirect confirmation (maybe in the future I will try to get direct confirmation, but now I don't have enough time)
https://developers.google.com/ml-kit/mobile-vision-migration/android#gmv
GMV uses the isOperational() call in the API surface to indicate whether a module has been downloaded successfully and is ready to use. ML Kit has no such method. ML Kit throws an MlKitException.UNAVAILABLE exception if a module hasn't been downloaded. You can catch this exception and process the next frame or set a timeout and retry with the current frame.

In my merge request tempBuffer allocated only once (if need) and reused in the next frames without any GC triggering.
I understand that the better solution is propagate stride outside but in this case, changes are needed in many places of the project, and can also affect user code

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