Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

payfazz/camera_android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

camera_android

The Android implementation of camera.

Usage

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 Plugin

camera_android package that fix crash issues.

Only On Android

````
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.
````

Issue

https://github.com/flutter/flutter/issues/114012

Occasionally reproduce this crash:

Continuously enter and exit the camera page, crash occurs between the 100th and 300th time.

100% Re-Produce the issue steps:

  1. Set two breakpoints in io.flutter.plugins.camera.Camera Camera.java :
    • breakpoint 1: Line 1228 captureSession.close();
    • breakpoint 2: Line 1263 captureSession = null;
  2. Push the camera view in then pop it out after the camera is working.
  3. Continue the thread from breakpoint 2 -> breakpoint 1, crash raised.

How-to fix:

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
...

About

Flutter Camera Android to fix crash issues

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published