Repository navigation
Closed
Description
Describe the bug
When I was trying to read a specific image file that contains a valid QR code, the scanner throws an NPE or is unable to read the data.
D/VisionProcessorBase: Failed to process. Error: Internal error has occurred when executing ML Kit tasks
W/System.err: com.google.mlkit.common.MlKitException: Internal error has occurred when executing ML Kit tasks
W/System.err: at com.google.mlkit.common.sdkinternal.ModelResource.zza(com.google.mlkit:common@@18.5.0:9)
W/System.err: at com.google.mlkit.common.sdkinternal.zzn.run(Unknown Source:10)
W/System.err: at com.google.mlkit.common.sdkinternal.zzt.run(com.google.mlkit:common@@18.5.0:2)
W/System.err: at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(com.google.mlkit:common@@18.5.0:4)
W/System.err: at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(com.google.mlkit:common@@18.5.0:1)
W/System.err: at com.google.mlkit.common.sdkinternal.zzk.run(Unknown Source:2)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err: at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(com.google.mlkit:common@@18.5.0:2)
W/System.err: at com.google.mlkit.common.sdkinternal.zzi.run(Unknown Source:2)
W/System.err: at java.lang.Thread.run(Thread.java:923)
W/System.err: Caused by: java.lang.NullPointerException: Attempt to get length of null array
W/System.err: at com.google.android.gms.internal.mlkit_vision_barcode_bundled.zzec.zzJ(com.google.mlkit:barcode-scanning@@17.0.2:1)
W/System.err: at com.google.photos.vision.barhopper.BarhopperProto$BarhopperResponse.zzb(com.google.mlkit:barcode-scanning@@17.0.2:1)
W/System.err: at com.google.android.libraries.barhopper.BarhopperV3.toProto(com.google.mlkit:barcode-scanning@@17.0.2:1)
W/System.err: at com.google.android.libraries.barhopper.BarhopperV3.recognize(com.google.mlkit:barcode-scanning@@17.0.2:11)
W/System.err: at com.google.mlkit.vision.barcode.bundled.internal.zza.zzb(com.google.mlkit:barcode-scanning@@17.0.2:5)
W/System.err: at com.google.android.gms.internal.mlkit_vision_barcode_bundled.zzbk.zza(com.google.mlkit:barcode-scanning@@17.0.2:3)
W/System.err: at com.google.android.gms.internal.mlkit_vision_barcode_bundled.zzb.onTransact(com.google.mlkit:barcode-scanning@@17.0.2:3)
W/System.err: at android.os.Binder.transact(Binder.java:1054)
W/System.err: at com.google.android.gms.internal.mlkit_vision_barcode.zza.zzb(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.0.0:2)
W/System.err: at com.google.android.gms.internal.mlkit_vision_barcode.zzox.zzd(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.0.0:4)
W/System.err: at com.google.mlkit.vision.barcode.internal.zzl.zza(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.0.0:14)
W/System.err: at com.google.mlkit.vision.barcode.internal.zzi.zzc(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.0.0:3)
W/System.err: at com.google.mlkit.vision.barcode.internal.zzi.run(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.0.0:1)
W/System.err: at com.google.mlkit.vision.common.internal.MobileVisionBase.zza(com.google.mlkit:vision-common@@17.2.1:2)
W/System.err: at com.google.mlkit.vision.common.internal.zza.call(Unknown Source:4)
W/System.err: at com.google.mlkit.common.sdkinternal.ModelResource.zza(com.google.mlkit:common@@18.5.0:8)
W/System.err: ... 10 more
E/BarcodeProcessor: Barcode detection failed com.google.mlkit.common.MlKitException: Internal error has occurred when executing ML Kit tasks
To Reproduce
The image contains some personal private info, if it's applicable, please leave an email address then I can send the original image.
Example Steps to reproduce the behavior in the sample app:
- Run the "ML Kit Vision Quickstart" example.
- Click on 'Run the ML kit quickstart written in Kotlin'
- Click on 'StillImageActivity'
- Change "Object Detection" to "Barcode Scanning"
- Choose the image from the album.
SDK Info:
- com.google.mlkit:barcode-scanning:17.0.2
- GoogleMLKit/BarcodeScanning ~3.2.0
Smartphone:
- Device/Simulator: All devices (including Android and iOS)
Metadata
Metadata
Assignees
Labels
No labels
Activity
zhouyiself commentedon Sep 28, 2022
Thanks for the report! Can you share your image with zhouyiself@gmail.com?
AlexV525 commentedon Sep 29, 2022
@zhouyiself Sure. The image has been sent.
zeroDivider commentedon Oct 6, 2022
This happened to me too, will it be considered a d fixed soon?
I am using
18.1.0. It worked well when we were using16.2.1.SilverDestiny commentedon Oct 7, 2022
Contacted @AlexV525 by email. Please share the image with me to reproduce this issue. Thanks!
zhouyiself commentedon Oct 7, 2022
@AlexV525 Hi, I didn't see your image in the email list.
AlexV525 commentedon Oct 7, 2022
Can you check again?

SilverDestiny commentedon Oct 7, 2022
The root cause is the input Bitmap config is not ARGB_8888, and our engine only supports config ARGB_8888 for Bitmap underneath: https://developer.android.com/reference/android/graphics/Bitmap.Config
It works well for streaming mode, i.e. LivePreviewActivity and CameraXLivePreviewActivity
We'll consider converting Bitmap config to ARGB_8888 if not internally to fix this issue in later releases. Thanks for reporting this bug!
SilverDestiny commentedon Oct 8, 2022
BTW, the original input Bitmap config is RGBA_F16
AlexV525 commentedon Oct 11, 2022
BitmapFactory.Options.outConfig(link) only supported from API 26, so it'll be good if we can convert theBitmapif it's notARGB_8888in the ML Kit internally.SilverDestiny commentedon Oct 11, 2022
https://developer.android.com/reference/android/graphics/Bitmap#getConfig() could be used to get the config from bitmap?
AlexV525 commentedon Oct 11, 2022
Yes, and it requires a memory allocation to read the actual data in IIRC.
AlexV525 commentedon Oct 11, 2022
Workaround with an actual allocation:
AlexV525 commentedon Nov 2, 2022
@miworking3 @SilverDestiny This also happened on iOS, so iOS should provide the same ability to convert if images are not
ARGB_8888.AlexV525 commentedon Nov 2, 2022
iOS workaround (I don't use unwrapping here, feel free to modify if it's worth in your code):
SilverDestiny commentedon Dec 6, 2022
The latest ML Kit release fixed this issue: https://developers.google.com/ml-kit/release-notes#december_6_2022