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

Detection of QR-Codes not working on Samsung A23 5G #698

Closed
tim-olbrich opened this issue Jul 26, 2023 · 28 comments
Closed

Detection of QR-Codes not working on Samsung A23 5G #698

tim-olbrich opened this issue Jul 26, 2023 · 28 comments

Comments

@tim-olbrich
Copy link

tim-olbrich commented Jul 26, 2023

Hello currently I am developing an app for android and iOS and this library works great and is really fast when detecting a QR Code. So kudos for this package. But i have one problem. On the Samsung A23 5G the scanner does not detect a code at all. I have some ideas about the cause of the problem but i have to check.

So here are some informations about my usage:

Device:

Samsung Galaxy A23 5G
Android 13

Flutter Version:

3.10.6

Package Version:

3.3.0

Issue:

Detection not working

Additional Information:

  • Working on Galaxy A21, looks like a problem with this specific device.
  • Camera stream is visible in the app.

Assumptions:

I am willing to help with this problem if i can get additional information or if someone has experienced similar problems with the same or different devices.

Thank you for your hard work on this library!

@guagnelz
Copy link

I noticed that works with front camera (only as workaround)

@tim-olbrich
Copy link
Author

On the A23? I've tried this as well but without success. But I will try it again later today. Thank you!

@guagnelz
Copy link

Our customer noticed that and after advised to use front camera he succeded to work: device is a SM-A236B

@pupubird
Copy link

pupubird commented Aug 1, 2023

Same goes to Xiaomi MI 11

@guagnelz
Copy link

guagnelz commented Aug 1, 2023

I tried on Xiaomi 11T (21081111RG) and works well

@rmyr
Copy link

rmyr commented Aug 15, 2023

Any idea on what the root cause may be?

@tim-olbrich
Copy link
Author

tim-olbrich commented Aug 15, 2023

No. I have no time to dig into this problem at the moment. But did anyone try if it works with the newest release? 3.4.1?

@tim-olbrich
Copy link
Author

Ok still not working. Even with version 3.4.1. @juliansteenbakker do you have any idea for what the reason for this error may be? If i rotate the device 30 degrees it sometimes works. Even looks like the device is switching cameras. I will try to help if we have a point to start from.

@rmyr
Copy link

rmyr commented Aug 17, 2023

I actually experience the same problem in React Native, using react-native-vision-camera, which is allowing you to use plugins to process frames (e.g. to look for QR-Codes).

After some debugging I saw that the images that the frame processor receives actually look like this:

Samsung A32 (QR-Code scanning is working fine, image is blurry cause of first frame while debugging I assume):
A32

Samsung A23:
A23

I don't know if this translates to this library as well. It is a strange coincidence that the same problem appears though, so maybe it is the same root cause. I don't wanna confuse this issue, but maybe this helps in some way.

@gunnardag
Copy link

I'm also having issues with two Samsung devices.
Samsung S20 Ultra & S10 lite.

They work sometimes but seem to stop working after a bit.

Also dragging the notification bar down makes the camera go white screen.

I have a feeling that these two problems are connected, something with the notification bar on these samsung devices that's interrupting something with the android lifecycle.

@dasprasky
Copy link

I'm facing the same issue on Samsung A23. It does not detect the QR code. My app is already on production so other devices are working fine but customers with Samsung A23 are facing this issue

@timbotimbo
Copy link

This appears to be caused by the output of the camera.
Similar issues mentioning this device (together with camera or MLKit) seem to resolve this by using the nv21 image format on android.

Corrupt camera stream:
flutter/flutter#118350
A23 needs NV21:
flutter-ml/google_ml_kit_flutter#287 (comment)
flutter-ml/google_ml_kit_flutter#285

If this is indeed the problem, this requires a fix in the plugin code, not something a user can change in their config.

I already see some nv21 references in this plugin, but I don't know this plugin well enough to see which format is used for an android device that I don't have.

@ViniciusSossela
Copy link

Facing the same issue with Samsung A23.

@ViniciusSossela
Copy link

This appears to be caused by the output of the camera. Similar issues mentioning this device (together with camera or MLKit) seem to resolve this by using the nv21 image format on android.

Corrupt camera stream: flutter/flutter#118350 A23 needs NV21: flutter-ml/google_ml_kit_flutter#287 (comment) flutter-ml/google_ml_kit_flutter#285

If this is indeed the problem, this requires a fix in the plugin code, not something a user can change in their config.

I already see some nv21 references in this plugin, but I don't know this plugin well enough to see which format is used for an android device that I don't have.

@juliansteenbakker

@ViniciusSossela
Copy link

ViniciusSossela commented Sep 14, 2023

Hey guys.

I made some changes to the code, and it seems to now be working on our device model A3 which didn't work before.

Could you try to scan a QRCODE on your device too?

if it works on your devices too, I am gonna open a PR

Just add the mobile_scanner to my forked version into pubspec.yaml

  mobile_scanner:
    # path: ../mobile_scanner
    git: [email protected]:ViniciusSossela/mobile_scanner.git

@tim-olbrich
Copy link
Author

Thank you for your effort! Sadly it's still not working on the A23. I just tested your package in our app.

@ViniciusSossela
Copy link

Thank you for your effort! Sadly it's still not working on the A23. I just tested your package in our app.

Did you tryed to identify what happens on the native android side of the package on your device?

@nirbar89
Copy link

Any one test version 3.5.1

@qwadrox
Copy link
Contributor

qwadrox commented Dec 2, 2023

One of our user has just noticed an issue on this device, so it might be still an issue. Our version: mobile_scanner: 3.5.4

image

@nirbar89
Copy link

nirbar89 commented Dec 3, 2023

One of our user has just noticed an issue on this device, so it might be still an issue. Our version: mobile_scanner: 3.5.4

image

A temporary solution for us was to set camera resolution to something above the default but a better solution should be found.

@qwadrox
Copy link
Contributor

qwadrox commented Dec 5, 2023

One of our user has just noticed an issue on this device, so it might be still an issue. Our version: mobile_scanner: 3.5.4
image

A temporary solution for us was to set camera resolution to something above the default but a better solution should be found.

What resolution did you use?

Our user gave more information and indeed camera is being initialised but it does not detect.

@qwadrox
Copy link
Contributor

qwadrox commented Jan 9, 2024

Apparently, after setting resolutions manually solved for us.
We used:
height 4000
width 3000

@juliansteenbakker Is the new ResolutionSelector improvement on the version 3.5.6 aims to solve this issue as well? Isn't it?

@Lars-Sommer
Copy link

Facing the same problem on Samsung A23.

@theamorn
Copy link

I am encountering the same issue with the Samsung A23. My team decided to purchase a Samsung A23 for me to conduct testing. I took screenshots using mobile_scanner version 3.5.6.

Here are the results from a regular phone:
617
618

and From Samsung A23
IMG20244317024317
IMG20244320024320

I ensured that the camera distance between the two devices was the same (as shown in the first image) and moved in to position the QR code in the middle of the screen (as shown in the second image).

The problem seems to be that the Samsung A23 zooms in by itself. I retrieved these images by including the saving image code into the Gallery in MobileScanner.kt at line 80 using the captureOutput variables.

To address this issue, I find it strange that the default resolution is 640 x 480 and appears to be broken on the Samsung A23. Therefore, I suggest setting the cameraResolution explicitly in the MobileScannerController. For example, I just set it to Size(640, 480) that's it and it's work!!

Behind the scenes, this will set the resolution in Android and avoid using the default resolution, which seems to be causing the problem.

Hope this help

@WelliRigo
Copy link

WelliRigo commented Feb 22, 2024

Tested on version 4.0.0 and the error still happens.

Setting the resolution to 640 x 480 worked palliatively.

@gasparpd
Copy link

Tested on version 4.0.0 and the error still happens.

Setting the resolution to 640 x 480 worked palliatively.

Yeah, I added a workaround by setting: cameraResolution: const Size(640, 480) on MobileScannerController.
This changes the camera preview aspect, but at least, now reads.

@navaronbracke
Copy link
Collaborator

I think we do always use YUV and not NV21, per the comment in

val captureOutput = ImageAnalysis.Analyzer { imageProxy -> // YUV_420_888 format
and the conversion code that is applied for YUV.

@juliansteenbakker Do you remember why we were using YUV on Android? Specifically for the Samsung device that is affected here, we need NV21. I would investigate if we can just switch to NV21 on Android and drop the YUV format there.

@navaronbracke
Copy link
Collaborator

For easier tracking, and now that the root cause seems apparent, I am going to close this issue, in favor of #1116

Please comment on that issue if you have further comments / observations.

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