mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

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

Open tim-olbrich opened this issue 1 year ago • 26 comments

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:

  • Set Resolution to max (I've read, that this could be a problem with the ml lib from google https://github.com/flutter-ml/google_ml_kit_flutter/issues/285
  • Using wrong camera (The A23 has 4 different cameras on the back)
  • Maybe the image stream is rotated

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!

tim-olbrich avatar Jul 26 '23 12:07 tim-olbrich

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

guagnelz avatar Jul 31 '23 08:07 guagnelz

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

tim-olbrich avatar Jul 31 '23 09:07 tim-olbrich

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

guagnelz avatar Jul 31 '23 09:07 guagnelz

Same goes to Xiaomi MI 11

pupubird avatar Aug 01 '23 07:08 pupubird

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

guagnelz avatar Aug 01 '23 07:08 guagnelz

Any idea on what the root cause may be?

rmyr avatar Aug 15 '23 10:08 rmyr

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 avatar Aug 15 '23 10:08 tim-olbrich

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.

tim-olbrich avatar Aug 17 '23 12:08 tim-olbrich

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.

rmyr avatar Aug 17 '23 21:08 rmyr

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.

gunnardag avatar Sep 06 '23 19:09 gunnardag

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

dasprasky avatar Sep 13 '23 10:09 dasprasky

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: https://github.com/flutter/flutter/issues/118350 A23 needs NV21: https://github.com/flutter-ml/google_ml_kit_flutter/issues/287#issuecomment-1549828057 https://github.com/flutter-ml/google_ml_kit_flutter/issues/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.

timbotimbo avatar Sep 14 '23 10:09 timbotimbo

Facing the same issue with Samsung A23.

ViniciusSossela avatar Sep 14 '23 13:09 ViniciusSossela

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 avatar Sep 14 '23 13:09 ViniciusSossela

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

ViniciusSossela avatar Sep 14 '23 14:09 ViniciusSossela

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

tim-olbrich avatar Sep 14 '23 15:09 tim-olbrich

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?

ViniciusSossela avatar Sep 14 '23 16:09 ViniciusSossela

Any one test version 3.5.1

nirbar89 avatar Oct 29 '23 06:10 nirbar89

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

qwadrox avatar Dec 02 '23 17:12 qwadrox

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.

nirbar89 avatar Dec 03 '23 14:12 nirbar89

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 avatar Dec 05 '23 11:12 qwadrox

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?

qwadrox avatar Jan 09 '24 21:01 qwadrox

Facing the same problem on Samsung A23.

Lars-Sommer avatar Jan 19 '24 08:01 Lars-Sommer

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

theamorn avatar Jan 22 '24 08:01 theamorn

Tested on version 4.0.0 and the error still happens.

Setting the resolution to 640 x 480 worked palliatively.

WelliRigo avatar Feb 22 '24 15:02 WelliRigo

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.

gasparpd avatar Feb 23 '24 14:02 gasparpd