Closed
Description
Steps to Reproduce
- get the camera package
- Initialize a
CameraController()
with aCameraDescription
that you get from theawait availableCameras()
method - Call the
controller.dispose()
inside theonDispose()
method - Wait that your Android phone automatically goes to the locked mode (inactivity) and you get the error.
Expected results: No error shown in the logs.
Actual results:
E/CameraCaptureSession(26501): Session 0: Exception while stopping repeating:
E/CameraCaptureSession(26501): android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): The camera device has encountered a serious error
E/CameraCaptureSession(26501): at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:2578)
E/CameraCaptureSession(26501): at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1137)
E/CameraCaptureSession(26501): at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:527)
E/CameraCaptureSession(26501): at io.flutter.plugins.camera.Camera.closeCaptureSession(Camera.java:1171)
E/CameraCaptureSession(26501): at io.flutter.plugins.camera.Camera.close(Camera.java:1177)
E/CameraCaptureSession(26501): at io.flutter.plugins.camera.Camera$1.onError(Camera.java:252)
E/CameraCaptureSession(26501): at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.notifyError(CameraDeviceImpl.java:2067)
E/CameraCaptureSession(26501): at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.lambda$Sm85frAzwGZVMAK-NE_gwckYXVQ(Unknown Source:0)
E/CameraCaptureSession(26501): at android.hardware.camera2.impl.-$$Lambda$CameraDeviceImpl$CameraDeviceCallbacks$Sm85frAzwGZVMAK-NE_gwckYXVQ.accept(Unknown Source:8)
E/CameraCaptureSession(26501): at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:271)
E/CameraCaptureSession(26501): at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:195)
E/CameraCaptureSession(26501): at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:86)
E/CameraCaptureSession(26501): at android.os.Handler.handleCallback(Handler.java:883)
E/CameraCaptureSession(26501): at android.os.Handler.dispatchMessage(Handler.java:100)
E/CameraCaptureSession(26501): at android.os.Looper.loop(Looper.java:241)
E/CameraCaptureSession(26501): at android.app.ActivityThread.main(ActivityThread.java:7617)
E/CameraCaptureSess
6587
ion(26501): at java.lang.reflect.Method.invoke(Native Method)
E/CameraCaptureSession(26501): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/CameraCaptureSession(26501): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Output of flutter doctor -v:
[✓] Flutter (Channel stable, 2.0.5, on macOS 11.3 20E232 darwin-x64, locale fr-FR)
• Flutter version 2.0.5 at /Users/foxtom/Desktop/flutter
• Framework revision adc687823a (2 weeks ago), 2021-04-16 09:40:20 -0700
• Engine revision b09f014e96
• Dart version 2.12.3
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/foxtom/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] Connected device (3 available)
• moto g 8 power (mobile) • ZY22BNDW2C • android-arm64 • Android 10 (API 29)
• iPhone (mobile) • 00008020-001204401E78002E • ios • iOS 14.4.2
• Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.93
• No issues found!
Can't test it on IOS as Xcode doesn't allow the Auto-Lock screen mode while debugging so I can't get the output...
The issue happened on all my Android 10 devices (Motorola, OPPO, Samsung).
I was posting on this issue #55434 and was asked to create a new one instead.
This error ONLY happens in the auto-lock screen mode as weird as it seems :
- If I lock the screen myself, no error is shown (on IOS it's also working in this case).
- If I put the app in background and come back, no error is shown either on both Platforms.
- I have tested all combination of these 2 tests above, and when manually interacting with the app or the Lock Screen, no problems are detected.
I also add that I am using the version 0.8.1
of the camera package.