-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4 Uncaught Fatal Exceptions in TakePictureTask & GetCapabilitiesTask on Galaxy Nexus #69
Comments
It looks like there is a racing condition and picture is being taken while the camera is stopping. Will dig deeper into that to check why it happens. |
+1 for catching these exceptions and return them to the caller via the cameraErrorCallback. Especially for calls on the camera instance like takePicture and getParameters. These often result in NPE's for no reason on some devices. I have the same crashes with 1.3.0, for example 1) described here and the one in issue #98 . Exception java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.Camera.takePicture([REDACTED_DOMAIN_NAME]$ShutterCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback)' on a null object reference Caused by java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.Camera.takePicture([REDACTED_DOMAIN_NAME]$ShutterCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback)' on a null object reference Caused by java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.Camera.takePicture([REDACTED_DOMAIN_NAME]$ShutterCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback)' on a null object reference Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.Camera.takePicture([REDACTED_DOMAIN_NAME]$ShutterCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback, [REDACTED_DOMAIN_NAME]$PictureCallback)' on a null object reference Happened on the following devices: Xiaomi
Oppo
Samsung
Lenovo
Intex
Coolpad
HTC
Motorola
Sony
Condor
Heres a crash similar to 2) from post above, trying to call getParameters: Exception java.lang.NullPointerException: Attempt to invoke virtual method '[REDACTED_DOMAIN_NAME]$Parameters android.hardware.Camera.getParameters()' on a null object reference Happened on the following devices: Xiaomi
Oppo
Coolpad
Sony
My fotoapparat initialization is pretty simple, i see the problem mostly on the named devices camera hardware: I solved these issues for me by catching NPEs on camera.getParameters and camera.takePicture calls, throw an CameraException and passing it later to CameraErrorCallback. It's not very elegant, but if i can help out i would gladly provide a PR. And thanks for the great camera library! |
I see same crash reports from our users. Could the suggested fix be included in next version, please? |
Hi @shtolik. Our time is pretty limited but we would be happy to merge a PR with the fix. |
I would provide a PR, but i would take some feedback on best way to handle errors related to routines with tasks. Currently CameraDevice implementations are catching RuntimeExceptions and throw a CameraException from that. The CameraException is than caught in the routine (currently only in StartCameraRoutine), which also has the CameraErrorCallback. In fact CameraErrorCallback is exclusivly passed to routines. But routines like TakePictureRoutine involve a task (FutureTask) and a result. For TakePictureRoutine i did it the same way as described before, but had to go on and handle failing to take a picture in the transformer classes (passing an empty Photo) and make PendingResults Callback onResult nullable. |
Hey guys, you may try Info: related reason: #104 |
I am still not convinced if we should suppress these exceptions completely as the developers might want to retry an action or inform the user. 🤔 |
Just for the sake of transparency:
|
Four fatal, uncaught exceptions were found while testing on the Galaxy Nexus. These crashes are occurring in background threads that the caller cannot catch. Can you please help catch these exceptions and return them to the caller via the cameraErrorCallback? Thank you.
1) Galaxy Nexus running 4.2.2 - Crash while taking picture:
07-21 14:55:24.170 3552-3580/? E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
Process: com.example.gbs131.fotoapparat, PID: 3552
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: takePicture failed
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:129)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: takePicture failed
at java.util.concurrent.FutureTask.report(FutureTask.java:93)
at java.util.concurrent.FutureTask.get(FutureTask.java:163)
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:127)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: takePicture failed
at java.util.concurrent.FutureTask.report(FutureTask.java:93)
at java.util.concurrent.FutureTask.get(FutureTask.java:163)
at io.fotoapparat.result.PendingResult$1.call(PendingResult.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.RuntimeException: takePicture failed
at android.hardware.Camera.native_takePicture(Native Method)
at android.hardware.Camera.takePicture(Camera.java:1436)
at io.fotoapparat.hardware.v1.Camera1.takePicture(Camera1.java:258)
at io.fotoapparat.routine.picture.TakePictureTask$1.call(TakePictureTask.java:24)
at io.fotoapparat.routine.picture.TakePictureTask$1.call(TakePictureTask.java:19)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
2) Galaxy Nexus running 4.2.2 - Crash when first launching MainActivity:
07-25 14:17:37.097 13588-13617/com.example.gbs131.fotoapparat E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-1
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:129)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:94)
at java.util.concurrent.FutureTask.get(FutureTask.java:160)
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:127)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at io.fotoapparat.hardware.v1.Camera1.getCapabilities(Camera1.java:237)
at io.fotoapparat.parameter.provider.GetCapabilitiesTask$1.call(GetCapabilitiesTask.java:18)
at io.fotoapparat.parameter.provider.GetCapabilitiesTask$1.call(GetCapabilitiesTask.java:15)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
3) Galaxy Nexus running 5.1.1 (Cyanogenmod) - Crash when returning to MainActivity after viewing image in separate Activity:
07-25 10:04:12.490 3030-3049/com.example.gbs131.fotoapparat E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
Process: com.example.gbs131.fotoapparat, PID: 3030
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: getParameters failed (empty parameters)
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:129)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: getParameters failed (empty parameters)
at java.util.concurrent.FutureTask.report(FutureTask.java:93)
at java.util.concurrent.FutureTask.get(FutureTask.java:163)
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:127)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.RuntimeException: getParameters failed (empty parameters)
at android.hardware.Camera.native_getParameters(Native Method)
at android.hardware.Camera.getParameters(Camera.java:1984)
at io.fotoapparat.hardware.v1.Camera1.getCapabilities(Camera1.java:237)
at io.fotoapparat.parameter.provider.GetCapabilitiesTask$1.call(GetCapabilitiesTask.java:18)
at io.fotoapparat.parameter.provider.GetCapabilitiesTask$1.call(GetCapabilitiesTask.java:15)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
4) Galaxy Nexus running 5.1.1 (Cyanogenmod) - Crash when taking a picture:
07-25 14:29:54.191 17530-22811/com.example.gbs131.fotoapparat E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-1
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:129)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:94)
at java.util.concurrent.FutureTask.get(FutureTask.java:160)
at io.fotoapparat.result.PendingResult.getResultUnsafe(PendingResult.java:127)
at io.fotoapparat.result.PendingResult.access$100(PendingResult.java:20)
at io.fotoapparat.result.PendingResult$2.run(PendingResult.java:98)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(FutureTask.java:94)
at java.util.concurrent.FutureTask.get(FutureTask.java:160)
at io.fotoapparat.result.PendingResult$1.call(PendingResult.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at io.fotoapparat.hardware.v1.Camera1.takePicture(Camera1.java:258)
at io.fotoapparat.routine.picture.TakePictureTask$1.call(TakePictureTask.java:24)
at io.fotoapparat.routine.picture.TakePictureTask$1.call(TakePictureTask.java:19)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
07-25 14:29:54.996 17530-17558/com.example.gbs131.fotoapparat D/Fotoapparat: stopPreview
07-25 14:29:54.996 17530-17558/com.example.gbs131.fotoapparat D/Fotoapparat: close
07-25 14:31:51.840 17530-22811/? I/Process: Sending signal. PID: 17530 SIG: 9
XML layout:
<io.fotoapparat.view.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Source code initialization:
Using library version 1.2.0
The text was updated successfully, but these errors were encountered: