google_ml_kit_flutter icon indicating copy to clipboard operation
google_ml_kit_flutter copied to clipboard

Not Working on Android 11 and 12

Open arsallion313786 opened this issue 2 years ago • 11 comments

I have added latest google ml kit version in our flutter app its working fine for Android 9 but for higher versions Android 11 and 12 not working even i tested google ml kit example app and same behaviour for Android 11 and 12. I also tried this for IOS and there its working fine. On Android 11 and developer all feature are not working properly.

If any one try google ml kit features for Android 11 and 12 then please share solution or even share their problem

arsallion313786 avatar Jun 25 '22 17:06 arsallion313786

@arsallion313786 : what do you mean with "not working"? which API are you using: face detection, barcode, text recognition, etc? I used a Pixel 4 with Android 12 to test our example app, and so far all the APIs are working. So, could you be more specific what is not working for you Android 12 testing device? Also, thanks for trying Google's native app, if you are getting the same behavior in Google's native app, then you should open an issue there. We are just consuming and wrapping their APIs in this plugins, doing the same processing they have in their documentation. We won't be able to fix that, but them. If you find that we are consuming and exposing incorrectly their APIs then come and let us know, or contribute with a PR.

fbernaly avatar Jun 26 '22 05:06 fbernaly

@fbernaly Thanks to comment. I have Samsung A23 Testing device and i have tested Barcode and Text detection API its working fine on all iOS devices and on Android Devices which they have version upto 9 but same code not working for Android 11 and 12. I really wonder if all things working fine for all iOS devices and also for Android 9 then why not for Android 11 and 12

arsallion313786 avatar Jun 26 '22 05:06 arsallion313786

Possibly related, google_mlkit_barcode_scanning doesn't work for me on Pixel 3, Android 12. The camera switches on, but nothing happens when pointed at a barcode. Barcode detection works fine on iOS. Flutter logs:

I/Camera (20069): close W/Camera (20069): The selected imageFormatGroup is not supported by Android. Defaulting to yuv420 I/Camera (20069): startPreview I/Camera (20069): CameraCaptureSession onConfigured I/Camera (20069): Updating builder settings D/Camera (20069): Updating builder with feature: ExposureLockFeature D/Camera (20069): Updating builder with feature: ExposurePointFeature I/Camera (20069): closeCaptureSession D/Camera (20069): Updating builder with feature: ZoomLevelFeature D/Camera (20069): Updating builder with feature: AutoFocusFeature D/Camera (20069): Updating builder with feature: NoiseReductionFeature I/Camera (20069): updateNoiseReduction | currentSetting: fast D/Camera (20069): Updating builder with feature: FocusPointFeature D/Camera (20069): Updating builder with feature: ResolutionFeature D/Camera (20069): Updating builder with feature: SensorOrientationFeature D/Camera (20069): Updating builder with feature: FlashFeature D/Camera (20069): Updating builder with feature: ExposureOffsetFeature D/Camera (20069): Updating builder with feature: FpsRangeFeature I/Camera (20069): refreshPreviewCaptureSession I/Camera (20069): refreshPreviewCaptureSession: captureSession not yet initialized, skipping preview capture session refresh. I/Camera (20069): CameraCaptureSession onClosed I/Camera (20069): startPreviewWithImageStream I/Camera (20069): CameraCaptureSession onConfigured I/Camera (20069): Updating builder settings D/Camera (20069): Updating builder with feature: ExposureLockFeature D/Camera (20069): Updating builder with feature: ExposurePointFeature D/Camera (20069): Updating builder with feature: ZoomLevelFeature D/Camera (20069): Updating builder with feature: AutoFocusFeature D/Camera (20069): Updating builder with feature: NoiseReductionFeature I/Camera (20069): updateNoiseReduction | currentSetting: fast D/Camera (20069): Updating builder with feature: FocusPointFeature D/Camera (20069): Updating builder with feature: ResolutionFeature D/Camera (20069): Updating builder with feature: SensorOrientationFeature D/Camera (20069): Updating builder with feature: FlashFeature D/Camera (20069): Updating builder with feature: ExposureOffsetFeature D/Camera (20069): Updating builder with feature: FpsRangeFeature I/Camera (20069): refreshPreviewCaptureSession W/System (20069): A resource failed to call release. W/System (20069): A resource failed to call release. D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, VERY_LOW, 90bzNc) is already scheduled. Returning... D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=DEFAULT, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, DEFAULT, 90bzNc) is already scheduled. Returning... D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, VERY_LOW, 90bzNc) is already scheduled. Returning... D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, VERY_LOW, 90bzNc) is already scheduled. Returning...

umangsh avatar Jun 27 '22 21:06 umangsh

From the linked bug, there is likely an issue with some Android 12 devices (emulators are okay) and google_mlkit_barcode_scanning:

  1. Works on emulators - Pixel 3, Pixel5 with Android 12, Pixel 3 with Android 9.
  2. Works on device - lenovo Tab with Android 10.
  3. Works on Samsung Galaxy Tab S6 Lite, Android 12.
  4. Does NOT work on Pixel 3 and Pixel 5 with Android 12.
  5. Does NOT work on Nokia x20, with google services, Android version unknown.

umangsh avatar Jul 01 '22 21:07 umangsh

From the linked bug, there is likely an issue with some Android 12 devices (emulators are okay) and google_mlkit_barcode_scanning:

  1. Works on emulators - Pixel 3, Pixel5 with Android 12, Pixel 3 with Android 9.
  2. Works on device - lenovo Tab with Android 10.
  3. Works on Samsung Galaxy Tab S6 Lite, Android 12.
  4. Does NOT work on Pixel 3 and Pixel 5 with Android 12.
  5. Does NOT work on Nokia x20, with google services, Android version unknown.

nokia x20 android 12

sorgfal avatar Jul 02 '22 20:07 sorgfal

Not working on Vivo Y33T having android 12

mahbubabbas avatar Jul 08 '22 16:07 mahbubabbas

I am using this plugin together with the camera plugin to create a barcode scanner. The imageSream on the CameraController delivers CameraImage's which will be used for barcode detection while using the mlkit BarcodeScanner. On some devices like Pixel 6 everything works good and fast. But on the Pixel 5 the detection doesn't work at all. I am holding the camera over the barcode but nothing happens.

But I changed something which made it work. Surprisingly it's the "ResolutionPreset" in the CameraController constructor. First I set it to medium which works on the pixel 6 but not pixel 5. Then I changed it to high and after that it also works on the pixel 5.

Maybe there is some kind of correlation between the resolution of the images and the detector(s).

ErrorCode-404 avatar Jul 14 '22 07:07 ErrorCode-404

But I changed something which made it work. Surprisingly it's the "ResolutionPreset" in the CameraController constructor. First I set it to medium which works on the pixel 6 but not pixel 5. Then I changed it to high and after that it also works on the pixel 5.

I can confirm that changing the ResolutionPreset results in different behavior. Setting ResolutionPreset to ResolutionPreset.max seems to work, but slows down the camera framerate. Maybe this bug have something to do with the camera package not finding the asked camera resolution and sending wrong metadata or MLKit can't process images with low resolution (setting a low ResolutionPreset).

I don't think this problem is Android Version related since I can reproduce this on Android 10 (Xiaomi Redmi 9S) using ResolutionPreset.medium.

rubenferreira97 avatar Jul 14 '22 11:07 rubenferreira97

Guys I have created one new plugin for face detection using CameraX which will solve the mentioned issues in sha Allaah. Please visit https://pub.dev/packages/camerax2.

On Thu, Jul 14, 2022 at 4:41 PM Rúben Ferreira @.***> wrote:

But I changed something which made it work. Surprisingly it's the "ResolutionPreset" in the CameraController constructor. First I set it to medium which works on the pixel 6 but not pixel 5. Then I changed it to high and after that it also works on the pixel 5.

I can confirm that changing the ResolutionPreset results in different behavior. Setting ResolutionPreset to ResolutionPreset.max seems to work, but slows down the camera framerate. Maybe this bug have something to do with the camera package not finding the asked camera resolution and sending wrong metadata or MLKit can't process images with low resolution (setting a low ResolutionPreset setting like ResolutionPreset.medium).

— Reply to this email directly, view it on GitHub https://github.com/bharat-biradar/Google-Ml-Kit-plugin/issues/285#issuecomment-1184315840, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2R3SYE76JUHQUBWF4CDP3VT7YVBANCNFSM5Z2TRYVQ . You are receiving this because you commented.Message ID: @.***>

mahbubabbas avatar Jul 14 '22 17:07 mahbubabbas

Hi guys, sorry for the delay. Thanks for using our plugin. @bharat-biradar and I have been maintaining this plugin, but sometimes we cannot provide all the support you need. Both of us are busy with school, work and family. We created this plugin as an open source project. We do not have an ETA for this fix, too busy with so many things, but you are welcome to fork our repo, fix whatever is broken and sent the PR. We will review PRs as soon as possible and release a new version.

I think that @rubenferreira97 is right, during my initial testing I found issues with the camera plugin similar to whar @rubenferreira97 reported: issues when changing the resolution.

ML Kit has these guidelines for input image resolution: https://developers.google.com/ml-kit/vision/face-detection/ios#input-image-guidelines

Unfortunately, because most of us are using the camera plugin, some how the out of that plugin does not conform with what ML Kit expects as input image, and therefore our plugin is failing. Basically we are passing the native camera output to Flutter (with camera plugin), then we are sending it back using FlutterMethodChannel to the native layer to be processed by ML Kit, in all that process there is a big delay, also compressing and decompressing issues. A better approach would be something like @mahbubabbas did: capture the image in the native layer and send it directly to ML Kit for processing without passing for Flutter.

I would appreciate if someone takes the time to fork our repo and starts leading that effort. I think we are going to continue seeing this issues related to using camera plugin, until we refactor the plugin to process the camera directly in the native layer.

fbernaly avatar Jul 21 '22 23:07 fbernaly

Hey, im having the same issue as you all, on some Android devices face recognition is not working. I did get to make it work on a lot of previusly affected devices by seting the camera quality to "High", sacrificing some performance. But still i have some devices affected. The list of the ones i know they are directly affected: Xiaomi Redmi 2201117TG, Motorola G71 G5. I did a lot of development with this Google package, hope it gets fixed soon.

PD: I tryed @mahbubabbas package, and it works fine with this still affected devices. But the integration with my allready developed code would be painfull. For example, im getting a photo from the image stream, to use it after biometrics, without having to use the function "take photo" wich requieres the stream to stop and take a photo ( in wich time a hacker of biometrics could put a photo of the real user, to fake the biometrics). Also i dont have lavel detector, wich i use to detect if user has lenses on or photos wich can affect the biometrics process.

Nemasio avatar Sep 22 '22 15:09 Nemasio

Hello, i have a list of devices where the library is NOT working (Ranked from TOP to BOTTOM in amount of devices that have my app, and none of the users with this devices could do face detection.)

motorola, moto g(30) 553 motorola, moto g(9) power 547 motorola, moto g(9) play 545 motorola, moto g51 5G 538 motorola, moto g52 401 motorola, moto e(7) plus 396 samsung, SM-A235M 377 samsung, SM-G975F 157 motorola, motorola one hyper 139 motorola, moto g82 5G 124 lge, LM-X540 116 TCL, T671E 111 motorola, Moto G (5S) Plus 102 samsung, SM-A750G 100 samsung, SM-J701M 92 lge, LM-X525 77 motorola, motorola one 72 samsung, SM-G991B 69 samsung, SM-N975F 66 samsung, SM-J700M 62 lge, LM-X210 57 lge, LM-X430 57 lge, LM-X520 55

Still waiting on a fix for face detection, or for the camera library fix to start detecting faces. Anyone has any news about this ??

Nemasio avatar Oct 31 '22 13:10 Nemasio