KBarcode
KBarcode copied to clipboard
[BUG] Detection stops working when toggling flash
Describe the bug The barcode detection stops working when i toggle the flash via setCameraFlashMode(). This is what i see in the error logs:
2022-10-15 12:20:57.008 23489-23489/hu.egis.greta E/BarcodeImageProcessor: Barcode processing error
com.google.mlkit.common.MlKitException: This detector is already closed!
at com.google.mlkit.vision.common.internal.MobileVisionBase.processBase(com.google.mlkit:vision-common@@16.3.0:3)
at com.google.mlkit.vision.barcode.internal.BarcodeScannerImpl.process(com.google.android.gms:play-services-mlkit-barcode-scanning@@16.1.5:1)
at uk.co.brightec.kbarcode.processor.BarcodeImageProcessor.detectInImage$kbarcode_release(BarcodeImageProcessor.kt:1)
at uk.co.brightec.kbarcode.processor.base.ImageProcessorBase.startDetection$kbarcode_release(ImageProcessorBase.kt:30)
at uk.co.brightec.kbarcode.processor.base.ImageProcessorBase$startDetection$1.invokeSuspend(Unknown Source:12)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
I went through your code and i saw that the updateCameraFeature closes the BarcodeScanner, and it is not recreated. I saw that if i call setBarcodeFormats() then it will trigger a createScanner() so the barcode detection continues, but with this solution sometimes i get a crash:
2022-10-15 12:32:53.847 3210-26680/? E/DropBoxUtil: [AppErrors] null InputStream [CONTEXT service_id=254 ]
java.io.IOException: null InputStream
at bupm.c(:com.google.android.gms@[email protected] (190408-480654083):23)
at buno.apply(:com.google.android.gms@[email protected] (190408-480654083):5)
at jxy.apply(:com.google.android.gms@[email protected] (190408-480654083):0)
at jym.apply(:com.google.android.gms@[email protected] (190408-480654083):5)
at clsc.a(:com.google.android.gms@[email protected] (190408-480654083):0)
at ctwm.a(:com.google.android.gms@[email protected] (190408-480654083):2)
at cztz.d(:com.google.android.gms@[email protected] (190408-480654083):2)
at czub.run(:com.google.android.gms@[email protected] (190408-480654083):9)
at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
at czub.g(:com.google.android.gms@[email protected] (190408-480654083):0)
at clro.a(:com.google.android.gms@[email protected] (190408-480654083):4)
at ctwk.a(:com.google.android.gms@[email protected] (190408-480654083):2)
at czvr.a(:com.google.android.gms@[email protected] (190408-480654083):4)
at czxt.a(:com.google.android.gms@[email protected] (190408-480654083):2)
at czwu.run(:com.google.android.gms@[email protected] (190408-480654083):3)
at czxv.run(:com.google.android.gms@[email protected] (190408-480654083):0)
at czvt.run(:com.google.android.gms@[email protected] (190408-480654083):7)
at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
at czvt.execute(:com.google.android.gms@[email protected] (190408-480654083):9)
at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
at czvv.c(:com.google.android.gms@[email protected] (190408-480654083):5)
at clrt.h(:com.google.android.gms@[email protected] (190408-480654083):4)
at clsd.a(:com.google.android.gms@[email protected] (190408-480654083):0)
at ctwm.a(:com.google.android.gms@[email protected] (190408-480654083):2)
at cztz.d(:com.google.android.gms@[email protected] (190408-480654083):2)
at czub.run(:com.google.android.gms@[email protected] (190408-480654083):9)
at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
at czub.g(:com.google.android.gms@[email protected] (190408-480654083):0)
at clsa.a(:com.google.android.gms@[email protected] (190408-480654083):4)
at ctwk.a(:com.google.android.gms@[email protected] (190408-480654083):2)
at czvr.a(:com.google.android.gms@[email protected] (190408-480654083):4)
at czxt.a(:com.google.android.gms@[email protected] (190408-480654083):2)
at czwu.run(:com.google.android.gms@[email protected] (190408-480654083):3)
at czxv.run(:com.google.android.gms@[email protected] (190408-480654083):0)
at czvt.run(:com.google.android.gms@[email protected] (190408-480654083):7)
at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
at czvt.execute(:com.google.android.gms@[email protected] (190408-480654083):9)
at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
at czvv.c(:com.google.android.gms@[email protected] (190408-480654083):5)
at clsi.c(:com.google.android.gms@[email protected] (190408-480654083):5)
at clsi.b(:com.google.android.gms@[email protected] (190408-480654083):2)
at com.google.android.gms.stats.service.DropBoxEntryAddedChimeraService.a(:com.google.android.gms@[email protected] (190408-480654083):32)
2022-10-15 12:32:53.847 3210-26680/? E/DropBoxUtil: at com.google.android.gms.framework.tracing.wrapper.TracingIntentService.onHandleIntent(:com.google.android.gms@[email protected] (190408-480654083):1)
at gjl.handleMessage(:com.google.android.gms@[email protected] (190408-480654083):0)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.os.HandlerThread.run(HandlerThread.java:67)