KillerInk / FreeDcam

FreeDcam is a CameraApp for Android >4.0(ics) wich try to enable stuff that is forgotten by the manufacturs
GNU General Public License v2.0
294 stars 45 forks source link

Frequent crashes after taking a picture #216

Open ScanuNicco opened 11 months ago

ScanuNicco commented 11 months ago

Describe the bug FreeDcam works as expected until I try to take a picture, at which point the app crashes. The picture is saved to the gallery and can be viewed once the app is re-opened. This happens about 70% of the time.

To Reproduce Steps to reproduce the behavior:

  1. Open FreeDcam
  2. Take a picture

Expected behavior FreeDcam takes a picture without crashing.

Smartphone

Additional context I found the following error in logcat during a crash

FATAL EXCEPTION: CaptureSessionHandler
Process: troop.com.freedcam, PID: 17051
java.lang.IllegalArgumentException: elements[0] is out of range of [1.000000, 340282346638528860000000000000000000000.000000] (too low)
    at com.android.internal.util.Preconditions.checkArrayElementsInRange(Preconditions.java:726)
    at android.hardware.camera2.params.LensShadingMap.<init>(LensShadingMap.java:81)
    at android.hardware.camera2.impl.CameraMetadataNative.getLensShadingMap(CameraMetadataNative.java:1044)
    at android.hardware.camera2.impl.CameraMetadataNative.-$$Nest$mgetLensShadingMap(Unknown Source:0)
    at android.hardware.camera2.impl.CameraMetadataNative$21.getValue(CameraMetadataNative.java:794)
    at android.hardware.camera2.impl.CameraMetadataNative.get(CameraMetadataNative.java:473)
    at android.hardware.camera2.impl.CameraMetadataNative.get(CameraMetadataNative.java:451)
    at android.hardware.camera2.CaptureResult.getProtected(CaptureResult.java:331)
    at android.hardware.camera2.CaptureResult.getProtected(CaptureResult.java:54)
    at android.hardware.camera2.CameraMetadata.getKeys(CameraMetadata.java:199)
    at android.hardware.camera2.CameraMetadata.getKeys(CameraMetadata.java:146)
    at android.hardware.camera2.CaptureResult.getKeys(CaptureResult.java:364)
    at freed.cam.apis.camera2.CameraValuesChangedCaptureCallback.processQcomAEValues(CameraValuesChangedCaptureCallback.java:450)
    at freed.cam.apis.camera2.CameraValuesChangedCaptureCallback.onCaptureCompleted(CameraValuesChangedCaptureCallback.java:219)
    at android.hardware.camera2.impl.CameraCaptureSessionImpl$1.lambda$onCaptureCompleted$4$android-hardware-camera2-impl-CameraCaptureSessionImpl$1(CameraCaptureSessionImpl.java:709)
    at android.hardware.camera2.impl.CameraCaptureSessionImpl$1$$ExternalSyntheticLambda1.run(Unknown Source:8)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.os.HandlerThread.run(HandlerThread.java:67)
KillerInk commented 11 months ago

Hi. Looks not like its a problem from freedcam. Looks more like a problem from lineage and their camera hal.

Thats the part where it crash. https://github.com/KillerInk/FreeDcam/blob/60682b2a086988f291725f8c9866a41350abda91/app/src/main/java/freed/cam/apis/camera2/CameraValuesChangedCaptureCallback.java#L450

a possible workaround would be to catch the IllegalArgumentException. but no idea if the cam dies anyway, also if the exception get catched