mobile_scanner
mobile_scanner copied to clipboard
Detection of QR-Codes not working on Samsung A23 5G
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!
I noticed that works with front camera (only as workaround)
On the A23? I've tried this as well but without success. But I will try it again later today. Thank you!
Our customer noticed that and after advised to use front camera he succeded to work: device is a SM-A236B
Same goes to Xiaomi MI 11
I tried on Xiaomi 11T (21081111RG) and works well
Any idea on what the root cause may be?
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?
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.
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):
Samsung 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.
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.
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
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.
Facing the same issue with Samsung A23.
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
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
Thank you for your effort! Sadly it's still not working on the A23. I just tested your package in our app.
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?
Any one test version 3.5.1
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
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
![]()
A temporary solution for us was to set camera resolution to something above the default but a better solution should be found.
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
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.
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?
Facing the same problem on Samsung A23.
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:
and From Samsung A23
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
Tested on version 4.0.0 and the error still happens.
Setting the resolution to 640 x 480 worked palliatively.
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.