CamerAwesome icon indicating copy to clipboard operation
CamerAwesome copied to clipboard

unlockFocus crashes the app

Open anamauad opened this issue 4 years ago • 5 comments

Steps to Reproduce

  • Open the camera to take a still picture with the rear camera

Expected results

  • The screen displays the image captured by the mobile phone camera, and it updates the image with autofocus
  • The shutter button is clicked

Actual results

  • The app crashes

About your device

Brand Model OS Notes
Xiaomi Redmi 9A Android 10 sdk 29 98 times in the last 7 days
Xiaomi Redmi 9 Android 10 sdk 29 60 times in the last 7 days
Xiaomi Redmi 6A Android 9 sdk 28 2 times in the last 7 days
Google Play Console Log
java.lang.IllegalStateException: 
  at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed (CameraCaptureSessionImpl.java:834)
  at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture (CameraCaptureSessionImpl.java:164)
  at com.apparence.camerawesome.CameraPreview.unlockFocus (CameraPreview.java:31)
  at com.apparence.camerawesome.CameraPreview.a (CameraPreview.java:36)
  at com.apparence.camerawesome.CameraSession.a (CameraSession.java:22)
  at com.apparence.camerawesome.CameraPicture$2.onCaptureCompleted (CameraPicture.java:47)
  at android.hardware.camera2.impl.CameraCaptureSessionImpl$1.lambda$onCaptureCompleted$3$CameraCaptureSessionImpl$1 (CameraCaptureSessionImpl.java:640)
  at android.hardware.camera2.impl.-$$Lambda$CameraCaptureSessionImpl$1$OA1Yz_YgzMO8qcV8esRjyt7ykp4.run (Unknown Source:8)
  at android.os.Handler.handleCallback (Handler.java:914)
  at android.os.Handler.dispatchMessage (Handler.java:100)
  at android.os.Looper.loop (Looper.java:225)
  at android.app.ActivityThread.main (ActivityThread.java:7563)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:994)

anamauad avatar Jan 08 '21 02:01 anamauad

unlockFocus cannot be called if you didn't take a photo. So I think the scenario is wrong. Can you double-check the scenario, please?

g-apparence avatar Jan 08 '21 10:01 g-apparence

@anamauad

  • what is your compileSdkVersion in your build.gradle
  • what is your targetSdkVersion in your build.gradle

g-apparence avatar Jan 08 '21 10:01 g-apparence

I've updated the scenario.

  • compileSdkVersion 29
  • minSdkVersion 23
  • targetSdkVersion 29
* what is your compileSdkVersion in your build.gradle

* what is your targetSdkVersion in your  build.gradle

anamauad avatar Jan 08 '21 17:01 anamauad

It is crashing also on the following devices:

Brand Model OS Notes
Samsung Galaxy A10, A21s, J4, J6, S9 Android 10 20 times in the last 7 days
Samsung Galaxy A10, S8, S8+ Android 9 10 times in the last 7 days
Motorola E6 plus, Z Play Android 9 2 times in the last 7 days

In response to your question "unlockFocus cannot be called if you didn't take a photo.", it crashes the app right after pressing the shutter button.

anamauad avatar Feb 08 '21 21:02 anamauad

We are having this error on Xiaomi Redmi 9A

Fatal Exception: java.lang.IllegalStateException: Session has been closed; further changes are illegal. at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:834) at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture(CameraCaptureSessionImpl.java:164) at com.apparence.camerawesome.CameraPreview.unlockFocus(CameraPreview.java:31) at com.apparence.camerawesome.CameraPreview.onStateChanged(CameraPreview.java:36) at com.apparence.camerawesome.CameraSession.setState(CameraSession.java:22) at com.apparence.camerawesome.CameraPicture$2.onCaptureCompleted(CameraPicture.java:47) at android.hardware.camera2.impl.CameraCaptureSessionImpl$1.lambda$onCaptureCompleted$3$CameraCaptureSessionImpl$1(CameraCaptureSessionImpl.java:640) at android.hardware.camera2.impl.-$$Lambda$CameraCaptureSessionImpl$1$OA1Yz_YgzMO8qcV8esRjyt7ykp4.run(-.java:8) at android.os.Handler.handleCallback(Handler.java:914) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:225) at android.app.ActivityThread.main(ActivityThread.java:7563) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)

mwvarela avatar May 24 '22 12:05 mwvarela

This should be fixed with the reworked version #150

g-apparence avatar Nov 25 '22 14:11 g-apparence