The Android implementation of camera
.
This package is endorsed, which means you can simply use camera
normally. This package will be automatically included in your app when you do,
so you do not need to add it to your pubspec.yaml
.
However, if you import
this package to use any of its APIs directly, you
should add it to your pubspec.yaml
as usual.
camera_android package that fix crash issues.
````
Thread Name: 'CameraBackground'
Back traces starts.
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.camera2.CameraCaptureSession.close()' on a null object reference
at io.flutter.plugins.camera.Camera.closeCaptureSession(Camera.java:1228)
at io.flutter.plugins.camera.Camera$1.onClosed(Camera.java:348)
at android.hardware.camera2.impl.CameraDeviceImpl$5.run(CameraDeviceImpl.java:252)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:223)
at android.os.Looper.loop(Looper.java:324)
at android.os.HandlerThread.run(HandlerThread.java:67)
Back traces ends.
````
https://github.com/flutter/flutter/issues/114012
Continuously enter and exit the camera page, crash occurs between the 100th and 300th time.
- Set two breakpoints in
io.flutter.plugins.camera.Camera
Camera.java : - Push the camera view in then pop it out after the camera is working.
- Continue the thread from breakpoint 2 -> breakpoint 1, crash raised.
Just add synchronized
key to this three close method
synchronized void closeCaptureSession() {
// on Line 1224
...
synchronized public void close() {
// on Line 1233
...
synchronized private void stopAndReleaseCamera() {
// on Line 1256
...