[Android] Camera view fails on consecutive screens with barcode scanner
timdoege opened this issue · 0 comments
timdoege commented
Hi,
Since MLKit versions 1.06 (still in v2.0.):
Due a requirement in my app where two consecutive screens with an active QR scanner are present (you scan a QR on the first screen and from there you can navigate to the second screen to scan a different QR code).
This works fine until you navigate back from screen 2 to screen 1 and this app crash happens:
System.err: Error: java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0.
May be attempting to bind too many use cases. Existing surfaces: [AttachedSurfaceInfo{surfaceConfig=SurfaceConfig{configType=PRIV, configSize=PREVIEW}, imageFormat=34,
size=1440x1080, targetFrameRate=null}, AttachedSurfaceInfo{surfaceConfig=SurfaceConfig{configType=YUV, configSize=VGA}, imageFormat=35, size=640x480, targetFrameRate=null}]
New configs: [androidx.camera.core.impl.ImageAnalysisConfig@2d5ee0b, androidx.camera.core.impl.PreviewConfig@c55a9da]
System.err:
System.err: StackTrace:
System.err: startPreview(file: src/webpack:/ns-mlkit/node_modules/@nativescript/mlkit-core/index.android.js:440:0)
System.err: at onLoaded(file: src/webpack:/ns-mlkit/node_modules/@nativescript/mlkit-core/index.android.js:423:0)
System.err: at (file: src/webpack:/ns-mlkit/node_modules/@nativescript/core/ui/core/view-base/index.js:392:0)
A tiny sample of the above is found in this Stackblitz (which works on iOS)
I have also seen this happen when the scanner view is inside a BottomNavigation tab, but the stack trace is a bit different:
System.err: Caused by: java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0. May be attempting to bind too many use cases. Existing surfaces: [AttachedSurfaceInfo{surfaceConfig=SurfaceConfig{configType=PRIV, configSize=PREVIEW}, imageFormat=34, size=1440x1080, targetFrameRate=null}, AttachedSurfaceInfo{surfaceConfig=SurfaceConfig{configType=YUV, configSize=VGA}, imageFormat=35, size=640x480, targetFrameRate=null}] New configs: [androidx.camera.core.impl.ImageAnalysisConfig@ddc2d3d, androidx.camera.core.impl.PreviewConfig@8f17e94]
System.err: at androidx.camera.lifecycle.LifecycleCameraRepository.bindToLifecycleCamera(LifecycleCameraRepository.java:285)
System.err: at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:538)
System.err: at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:363)
System.err: at io.github.triniwiz.fancycamera.Camera2.initPreview(Camera2.kt:909)
System.err: at io.github.triniwiz.fancycamera.Camera2.refreshCamera(Camera2.kt:984)
System.err: at io.github.triniwiz.fancycamera.Camera2.startPreview(Camera2.kt:1035)
System.err: at io.github.triniwiz.fancycamera.FancyCamera.startPreview(FancyCamera.kt:365)
System.err: ... 34 more