Skip to content

[Android] Camera view fails on consecutive screens with barcode scanner #56

@timdoege

Description

@timdoege

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)

https://stackblitz.com/edit/nativescript-stackblitz-templates-pozdy1?file=src%2Fapp%2Fitem%2Fitem-detail.component.html

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions