Closed talamaska closed 1 year ago
Yes cameraX is not working properly with emulators. We can't really do anything right now.
I just tested with an emulator with Android 10 and it's working.
However, when trying to take a picture with the back camera on Android 12 (API 31) on an emulator, I've got the following error:
D/DeferrableSurface( 5203): Surface no longer in use[total_surfaces=2, used_surfaces=0](androidx.camera.core.impl.ImmediateSurface@542c7f2}
D/Camera2CameraImpl( 5203): CameraDevice.onError(): 0 failed with ERROR_CAMERA_DEVICE while in OPENED state. Will attempt recovering from error.
D/Camera2CameraImpl( 5203): Attempt to reopen camera[0] after error[ERROR_CAMERA_DEVICE]
D/Camera2CameraImpl( 5203): {Camera@bbad2f0[id=0]} Transitioning camera internal state: OPENED --> REOPENING
D/CameraStateRegistry( 5203): Recalculating open cameras:
D/CameraStateRegistry( 5203): Camera State
D/CameraStateRegistry( 5203): -------------------------------------------------------------------
D/CameraStateRegistry( 5203): Camera@bbad2f0[id=0] OPENING
D/CameraStateRegistry( 5203): Camera@e122e1c[id=1] UNKNOWN
D/CameraStateRegistry( 5203): -------------------------------------------------------------------
D/CameraStateRegistry( 5203): Open count: 1 (Max allowed: 1)
D/CameraStateMachine( 5203): New public camera state CameraState{type=OPENING, error=StateError{code=3, cause=null}} from OPENING and StateError{code=3, cause=null}
D/CameraStateMachine( 5203): Publishing new public camera state CameraState{type=OPENING, error=StateError{code=3, cause=null}}
D/Camera2CameraImpl( 5203): {Camera@bbad2f0[id=0]} Resetting Capture Session
E/CameraCaptureSession( 5203): Session 0: Exception while stopping repeating:
E/CameraCaptureSession( 5203): android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): The camera device has encountered a serious error
E/CameraCaptureSession( 5203): at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:2350)
E/CameraCaptureSession( 5203): at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1277)
E/CameraCaptureSession( 5203): at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:579)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.SynchronizedCaptureSessionBaseImpl.close(SynchronizedCaptureSessionBaseImpl.java:476)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.CaptureSession.release(CaptureSession.java:489)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.Camera2CameraImpl.releaseSession(Camera2CameraImpl.java:528)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.Camera2CameraImpl.resetCaptureSession(Camera2CameraImpl.java:1243)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.Camera2CameraImpl.closeCamera(Camera2CameraImpl.java:442)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.Camera2CameraImpl$StateCallback.reopenCameraAfterError(Camera2CameraImpl.java:1719)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.Camera2CameraImpl$StateCallback.handleErrorOnOpen(Camera2CameraImpl.java:1671)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.Camera2CameraImpl$StateCallback.onError(Camera2CameraImpl.java:1647)
E/CameraCaptureSession( 5203): at androidx.camera.camera2.internal.CameraDeviceStateCallbacks$ComboDeviceStateCallback.onError(CameraDeviceStateCallbacks.java:121)
E/CameraCaptureSession( 5203): at android.hardware.camera2.impl.CameraDeviceImpl.notifyError(CameraDeviceImpl.java:1748)
E/CameraCaptureSession( 5203): at android.hardware.camera2.impl.CameraDeviceImpl.$r8$lambda$KBQCqQRdhVVn7uHI9Xdha6OqnsU(Unknown Source:0)
E/CameraCaptureSession( 5203): at android.hardware.camera2.impl.CameraDeviceImpl$$ExternalSyntheticLambda0.accept(Unknown Source:8)
E/CameraCaptureSession( 5203): at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:281)
E/CameraCaptureSession( 5203): at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:204)
E/CameraCaptureSession( 5203): at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:97)
E/CameraCaptureSession( 5203): at androidx.camera.core.impl.utils.executor.SequentialExecutor$1.run(SequentialExecutor.java:111)
E/CameraCaptureSession( 5203): at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
E/CameraCaptureSession( 5203): at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
E/CameraCaptureSession( 5203): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/CameraCaptureSession( 5203): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/CameraCaptureSession( 5203): at java.lang.Thread.run(Thread.java:920)
I also noted that the green square on the TV in the emulated camera doesn't move by default (it is a setting that can be enabled per emulator). I enabled it to see if it changes anything, but I still got the same error.
Interestingly, if I try with the front camera, it takes the picture with no error.
Since the issue seems to be related to an emulator problem on a specific camera and on a specific older Android version, I don't think it's worth investigating more and I'll close the issue.
If you disagree or can reproduce the issue on a real device, feel free to reopen the issue or open a new one.
@apalala-dev what is the minimum android version that the plugin should work on a device without issues? I have another S7 with Android 8. Is it suppose to work there. I can check if it works.
@apalala-dev what is the minimum android version that the plugin should work on a device without issues? I have another S7 with Android 8. Is it suppose to work there. I can check if it works.
minSdkVersion is 21, so it should work on your S7
Steps to Reproduce
I run the latest master example app in Android SDK 31 which is Android 12 OS. When I click the take photo button the small preview on the side never shows a preview. Instead it just shows a circular progress indicator running. Is it possible to make it work on emulator? On a device Samsung A53 with Android 13 I don't have such issues.
Expected results
I would expect to be able to take photos on the emulator
Actual results
An infinite progress indicator where the capture should show up.
About your device
After more testing I have figured out that the plugin is working in android emulator with android 13,
Your flutter version
Flutter 3.7.6 • channel stable • https://github.com/flutter/flutter.git Framework • revision 12cb4eb7a0 (7 days ago) • 2023-03-01 10:29:26 -0800 Engine • revision ada363ee93 Tools • Dart 2.19.3 • DevTools 2.20.1