Fixed
Status Update
Comments
dw...@gmail.com <dw...@gmail.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
fu...@google.com <fu...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
dw...@gmail.com <dw...@gmail.com> #4
Hi, thanks for the response.
I don't know if it similar to that issue, because our issue reproduced only on Samsung SM-A300H android 5.0.2.
We does not have any other android with that api level and can't say is it depend on os version or just this device.
We tested on devises in android 5.1, 6.0, 9, 10 and averting work fine.
This crash only happen when taking photo when flashlight triggered. Without flash - it also work fine.
In this issuehttps://issuetracker.google.com/issues/154255641 android 9 I suppose and app crash every time when capture photo.
I don't know if it similar to that issue, because our issue reproduced only on Samsung SM-A300H android 5.0.2.
We does not have any other android with that api level and can't say is it depend on os version or just this device.
We tested on devises in android 5.1, 6.0, 9, 10 and averting work fine.
This crash only happen when taking photo when flashlight triggered. Without flash - it also work fine.
In this issue
fu...@google.com <fu...@google.com> #5
Hi, thanks for the update. Yes they may be different issues.
We have a Samsung A3, and I can confirm this bug is reproducible here running our test apps (coretestapp) as outlined in the report (flash set to auto, and metering is dark enough to trigger the flash).
We'll keep looking into this.
sc...@google.com <sc...@google.com> #6
Hi dwajot1,
I wonder if you keep the full logs ?
from the crash log, it crash in startPreview. that is kind of weird since you are doing an image capture.
Also the "Throwable occurred: androidx.camera.core.ImageCaptureException: Camera is closed." is not a crash, it is thrown in OnImageSavedCallback#onError to notify apps the image capture failure. That could happen when user takes a picture and leave the app quickly.
The full logs can help me know exactly what happen in time sequence.
PS: I am not able to reproduce it on our android 5.0.2 devices.
Scott
I wonder if you keep the full logs ?
from the crash log, it crash in startPreview. that is kind of weird since you are doing an image capture.
Also the "Throwable occurred: androidx.camera.core.ImageCaptureException: Camera is closed." is not a crash, it is thrown in OnImageSavedCallback#onError to notify apps the image capture failure. That could happen when user takes a picture and leave the app quickly.
The full logs can help me know exactly what happen in time sequence.
PS: I am not able to reproduce it on our android 5.0.2 devices.
Scott
dw...@gmail.com <dw...@gmail.com> #7
Hello, thanks for response. I does not have this device - it's my tester reproduce this bug.
The crash in startPreview I see on crashlytics.
In my own logcat i see exception that was catched Camera is closed.
I'll try to grab system logs and send you.
The crash in startPreview I see on crashlytics.
In my own logcat i see exception that was catched Camera is closed.
I'll try to grab system logs and send you.
dw...@gmail.com <dw...@gmail.com> #8
Hello, this is logcat of this crash Fatal Exception: java.lang.RuntimeException
startPreview failed
I hope it'll help, thanks
startPreview failed
I hope it'll help, thanks
sc...@google.com <sc...@google.com> #9
Yes. This is helpful. I am able to get more context about the problem .
E/RequestThread-0(28446): Hit timeout for jpeg callback!
W/CaptureCollector(28446): Jpeg buffers dropped for request: 1
This is probably a bug in android 5.0 framework. We'll see if we can workaround it.
E/RequestThread-0(28446): Hit timeout for jpeg callback!
W/CaptureCollector(28446): Jpeg buffers dropped for request: 1
This is probably a bug in android 5.0 framework. We'll see if we can workaround it.
sc...@google.com <sc...@google.com> #10
found same issue reported on samsung s4 android 5.0 using camear2 API.
https://cmsdk.com/android/taking-picture-with-flash--camera2.html
so we can be sure that cameraX does not cause the problem. and we are looking into whether it is possible to workaround it on behalf of apps.
so we can be sure that cameraX does not cause the problem. and we are looking into whether it is possible to workaround it on behalf of apps.
dw...@gmail.com <dw...@gmail.com> #11
Thanks for response! Okay, I think we will not enable this camera on android 5.0. Will start from 5.1. If you fix this somehow it would be awesome! Good luck!
ap...@google.com <ap...@google.com> #12
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 9216b72657b3fe5ff8cbe9db3255919fd67963cd
Author: Scott Nien <scottnien@google.com>
Date: Fri Oct 30 16:41:07 2020
Disable auto flash AE mode in Samsung A3 devices
Preview stops working after taking a photo in auto flash AE mode
in Samsung A3 devices. There is no solution to fix that issues.
For now we can only turn off the auto flash mode to workaround it.
Relnote:"Disabled auto flash on Samsung A3 devices to fix the crash
when taking a photo with auto flash AE mode on Samsung A3 devices."
Test: AutoFlashAEModeDisablerTest
Bug: 157535165
Change-Id: Ia5fe30075e4ec65abe4030e4589a35e3c30a607f
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraControlImpl.java
A camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/CrashWhenTakingPhotoWithAutoFlashAEModeQuirk.java
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/DeviceQuirksLoader.java
A camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/workaround/AutoFlashAEModeDisabler.java
A camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/AutoFlashAEModeDisablerTest.java
M camera/camera-core/src/main/java/androidx/camera/core/ImageCapture.java
https://android-review.googlesource.com/1481136
Branch: androidx-master-dev
commit 9216b72657b3fe5ff8cbe9db3255919fd67963cd
Author: Scott Nien <scottnien@google.com>
Date: Fri Oct 30 16:41:07 2020
Disable auto flash AE mode in Samsung A3 devices
Preview stops working after taking a photo in auto flash AE mode
in Samsung A3 devices. There is no solution to fix that issues.
For now we can only turn off the auto flash mode to workaround it.
Relnote:"Disabled auto flash on Samsung A3 devices to fix the crash
when taking a photo with auto flash AE mode on Samsung A3 devices."
Test: AutoFlashAEModeDisablerTest
Bug: 157535165
Change-Id: Ia5fe30075e4ec65abe4030e4589a35e3c30a607f
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/Camera2CameraControlImpl.java
A camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/CrashWhenTakingPhotoWithAutoFlashAEModeQuirk.java
M camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/quirk/DeviceQuirksLoader.java
A camera/camera-camera2/src/main/java/androidx/camera/camera2/internal/compat/workaround/AutoFlashAEModeDisabler.java
A camera/camera-camera2/src/test/java/androidx/camera/camera2/internal/compat/workaround/AutoFlashAEModeDisablerTest.java
M camera/camera-core/src/main/java/androidx/camera/core/ImageCapture.java
sc...@google.com <sc...@google.com> #13
Hi dwajot1
FYI, starting from beta12 (to be released in November), CameraX will disable the auto flash on Samsung A3 devices to workaround the issue at CameraX side. It would be nice if you can check that after beta12 is release.
FYI, starting from beta12 (to be released in November), CameraX will disable the auto flash on Samsung A3 devices to workaround the issue at CameraX side. It would be nice if you can check that after beta12 is release.
al...@gmail.com <al...@gmail.com> #14
Fatal Exception: java.lang.RuntimeException
startPreview failed
Reported in crashlytics after integrating camerax.
Device: Galaxy Note 4
Android build : 5.0.1
startPreview failed
Reported in crashlytics after integrating camerax.
Device: Galaxy Note 4
Android build : 5.0.1
sc...@google.com <sc...@google.com> #15
Thanks for reporting this !
+ Wenhung,
Please help disabling FLASH_MODE_AUTO on Galaxy Note 4 as well
+ Wenhung,
Please help disabling FLASH_MODE_AUTO on Galaxy Note 4 as well
we...@google.com <we...@google.com> #16
Hi ali,
It seems like Galaxy Note 4 has multiple chipsets.
Would you mind providing the device model or type id? We'd like to set a list of devices to workaround this issue.
It seems like Galaxy Note 4 has multiple chipsets.
Would you mind providing the device model or type id? We'd like to set a list of devices to workaround this issue.
Description
ANDROID OS BUILD NUMBER: (Samsung SM-A300H version 5.0.2)
DEVICE NAME: (Samsung Galaxy A3)
DESCRIPTION:
I'm adding camerax to app and my tester find issue on one device - when use ImageCapture.FLASH_MODE_AUTO and capture image in dark when flash triggered - app crashed
Fatal Exception: java.lang.RuntimeException
startPreview failed
android.hardware.Camera.startPreview (Camera.java)
android.hardware.camera2.legacy.RequestThreadManager.startPreview (RequestThreadManager.java:275)
android.hardware.camera2.legacy.RequestThreadManager.doPreviewCapture (RequestThreadManager.java:317)
android.hardware.camera2.legacy.RequestThreadManager.access$1600 (RequestThreadManager.java:61)
android.hardware.camera2.legacy.RequestThreadManager$5.handleMessage (RequestThreadManager.java:756)
android.os.Handler.dispatchMessage (Handler.java:98)
android.os.Looper.loop (Looper.java:135)
android.os.HandlerThread.run (HandlerThread.java:61)
STEPS TO REPRODUCE:
1. use Samsung Galaxy A3
2. set ImageCapture.FLASH_MODE_AUTO
3. take a picture in dark
OBSERVED RESULTS:
app crashed
EXPECTED RESULTS:
taking picture or handle exception
REPRODUCIBILITY: (5 of 5, 1 of 100, etc)
5 of 5
ADDITIONAL INFORMATION:
In our log I see different crash:
Throwable occurred: androidx.camera.core.ImageCaptureException: Camera is closed.
at androidx.camera.core.ImageCapture$ImageCaptureRequest.lambda$notifyCallbackError$1$ImageCapture$ImageCaptureRequest(ImageCapture.java:1963)
at androidx.camera.core.-$$Lambda$ImageCapture$ImageCaptureRequest$1G7WSvt8TANxhZtOyewefm68pg4.run(lambda)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5536)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1397)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1192)
Caused by: androidx.camera.core.CameraClosedException: Camera is closed.
at androidx.camera.core.ImageCapture.abortImageCaptureRequests(ImageCapture.java:703)
at androidx.camera.core.ImageCapture.onStateOffline(ImageCapture.java:699)
at androidx.camera.camera2.internal.Camera2CameraImpl.lambda$notifyStateOfflineToUseCases$12(Camera2CameraImpl.java:689)
at androidx.camera.camera2.internal.-$$Lambda$Camera2CameraImpl$hp2EIAmfp4eGOX-qpuivXiBeeMA.run(lambda)
CODE FRAGMENTS (this will help us troubleshoot your issues):
this is how I bindCameraUseCases
val metrics = DisplayMetrics().also { viewFinder.display.getRealMetrics(it) }
val screenAspectRatio = aspectRatio(metrics.widthPixels, metrics.heightPixels)
val rotation = viewFinder.display.rotation
val cameraSelector = CameraSelector.Builder().requireLensFacing(lensFacing).build()
val cameraProviderFuture = ProcessCameraProvider.getInstance(this)
cameraProviderFuture.addListener(Runnable {
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
preview = Preview.Builder()
.setTargetAspectRatio(screenAspectRatio)
.setTargetRotation(rotation)
.build()
imageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
.setTargetAspectRatio(screenAspectRatio)
.setTargetRotation(rotation)
.setFlashMode(ImageCapture.FLASH_MODE_AUTO)
.build()
cameraProvider.unbindAll()
try {
camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture)
preview?.setSurfaceProvider(viewFinder.createSurfaceProvider(camera?.cameraInfo))
} catch (exc: Exception) {
}
}, ContextCompat.getMainExecutor(this))
private fun aspectRatio(width: Int, height: Int): Int {
val previewRatio = max(width, height).toDouble() / min(width, height)
if (abs(previewRatio - RATIO_4_3_VALUE) <= abs(previewRatio - RATIO_16_9_VALUE)) {
return AspectRatio.RATIO_4_3
}
return AspectRatio.RATIO_16_9
}
This is how I set imageCaptureLitener
imageCapture?.let { imageCapture ->
val photoFile = createFile()
val metadata = ImageCapture.Metadata().apply {
isReversedHorizontal = lensFacing == CameraSelector.LENS_FACING_FRONT
}
val outputOptions = ImageCapture.OutputFileOptions.Builder(photoFile)
.setMetadata(metadata)
.build()
imageCapture.takePicture(outputOptions, cameraExecutor, object : ImageCapture.OnImageSavedCallback {
override fun onError(exc: ImageCaptureException) {
}
override fun onImageSaved(output: ImageCapture.OutputFileResults) {
setGalleryThumbnail(photoFile.path)
valuesList.add(0, photoFile.path)
}
})
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
container.postDelayed({
container.foreground = ColorDrawable(Color.WHITE)
container.postDelayed(
{ container.foreground = null }, ANIMATION_FAST_MILLIS)
}, ANIMATION_SLOW_MILLIS)
}
}