CameraX force closed on Android under 10

228 views
Skip to first unread message

Permana

unread,
Aug 6, 2023, 11:53:04 PM8/6/23
to Android CameraX Discussion Group
Hi, I'm using cameraX version 1.2.2 Is there a bug in this version for Android 10 and below? if on android 11-13 there are no problems.
this is the logcat error when opening camere
E/CameraCaptureSession: Session 0: Exception while stopping repeating:
    android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): The camera device has encountered a serious error
        at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:2406)
        at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1104)
        at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:526)
        at androidx.camera.camera2.internal.SynchronizedCaptureSessionBaseImpl.close(SynchronizedCaptureSessionBaseImpl.java:463)
        at androidx.camera.camera2.internal.CaptureSession.release(CaptureSession.java:428)
        at androidx.camera.camera2.internal.Camera2CameraImpl.releaseSession(Camera2CameraImpl.java:489)
        at androidx.camera.camera2.internal.Camera2CameraImpl.resetCaptureSession(Camera2CameraImpl.java:1125)
        at androidx.camera.camera2.internal.Camera2CameraImpl.closeCamera(Camera2CameraImpl.java:403)
        at androidx.camera.camera2.internal.Camera2CameraImpl$StateCallback.reopenCameraAfterError(Camera2CameraImpl.java:1552)
        at androidx.camera.camera2.internal.Camera2CameraImpl$StateCallback.handleErrorOnOpen(Camera2CameraImpl.java:1505)
        at androidx.camera.camera2.internal.Camera2CameraImpl$StateCallback.onError(Camera2CameraImpl.java:1481)
        at androidx.camera.camera2.internal.CameraDeviceStateCallbacks$ComboDeviceStateCallback.onError(CameraDeviceStateCallbacks.java:119)
        at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.notifyError(CameraDeviceImpl.java:1900)
        at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.lambda$Sm85frAzwGZVMAK-NE_gwckYXVQ(Unknown Source:0)
        at android.hardware.camera2.impl.-$$Lambda$CameraDeviceImpl$CameraDeviceCallbacks$Sm85frAzwGZVMAK-NE_gwckYXVQ.accept(Unknown Source:8)
        at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:258)
        at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:182)
        at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:77)
        at androidx.camera.core.impl.utils.executor.SequentialExecutor$1.run(SequentialExecutor.java:109)
        at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:229)
        at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:171)

Scott Nien

unread,
Aug 7, 2023, 12:06:22 AM8/7/23
to Permana, Android CameraX Discussion Group
Thanks for reaching out !  

Could you provide the following information ? That would be helpful for us to find the root cause of it. 
1) Is it 100% reproducible or how frequently does it happen ?
2) on what devices were you using ?
3) Do you have more complete logs for the issue ?

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/958fc28a-ed4e-499a-8afb-c7163d26ba0an%40android.com.

Permana

unread,
Aug 7, 2023, 12:37:24 AM8/7/23
to Scott Nien, Android CameraX Discussion Group
1. this is alway happen, but for the first time opened the camera it will be normal, the bug with that logcat will be happen when btn take picture are clicked, after that when reopen the camera will be show black screen.
2. Oppo A3s, Xiaomi Mi A2 Lite, and emulator API 28 (Pixel 3a)
3. if already black screen when button take picture/flash/switch camera clicked will be show this log

    
    --------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: pool-43-thread-1
    Process: com.apps.debug, PID: 3755
    android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
        at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7753)
        at android.view.ViewRootImpl.focusableViewAvailable(ViewRootImpl.java:3773)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:917)
        at android.view.View.setFlags(View.java:14096)
        at android.view.View.setClickable(View.java:10476)
        at com.apps.core.phototaker.pages.CameraActivity$takePhoto$1.onError(CameraActivity.kt:267)
        at androidx.camera.core.ImageCapture$ImageCaptureRequest.lambda$notifyCallbackError$1$androidx-camera-core-ImageCapture$ImageCaptureRequest(ImageCapture.java:2481)
        at androidx.camera.core.ImageCapture$ImageCaptureRequest$$ExternalSyntheticLambda0.run(Unknown Source:8)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
2023-08-07 11:26:48.940 3755-3910/com.apps.debug D/CameraStateRegistry: Recalculating open cameras:
    Camera                                       State                
    -------------------------------------------------------------------
    Camera@53525a2[id=0]                         CLOSING              
    Camera@a63f9ee[id=1]                         UNKNOWN              
    -------------------------------------------------------------------
    Open count: 1 (Max allowed: 1)

Scott Nien

unread,
Aug 7, 2023, 12:40:35 AM8/7/23
to Permana, Android CameraX Discussion Group
Just to double check. 

You can reproduce this issue on Oppo A3s,Xiaomi Mi A2 Lite, and also emulator API 28, and it's 100%,  right ?
In this case, do you mind testing it again using the latest version 1.3.0-beta02 to see if it is fixed in the later version ?  


BTW,  the exception   "android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views." can be avoided by running the View-related codes in the UI thread.  For example, you can pass the main thread executor (e.g, ContextCompat.getMainExecutor(context)) in the takePicture() call or post the runnable via runOnUiThread.

Reply all
Reply to author
Forward
0 new messages