When does this error occur? ImageCaptureException: Camera is closed

157 views
Skip to first unread message
Assigned to scot...@google.com by me

Ishank Nijhawan

unread,
Oct 17, 2024, 3:40:52 AMOct 17
to Android CameraX Discussion Group
Hey, we introduced CameraX on our production app few months ago. It's working fine, but few of our users are constantly facing the following error while capturing an image.

       Non-fatal Exception: androidx.camera.core.ImageCaptureException: Camera is closed.
       at androidx.camera.core.imagecapture.TakePictureManager.abortRequests(TakePictureManager.java:161)
       at androidx.camera.core.ImageCapture.abortImageCaptureRequests(ImageCapture.java:787)
       at androidx.camera.core.ImageCapture.onStateDetached(ImageCapture.java:781)
       at androidx.camera.camera2.internal.Camera2CameraImpl.notifyStateDetachedToUseCases(Camera2CameraImpl.java:879)
       at androidx.camera.camera2.internal.Camera2CameraImpl.detachUseCases(Camera2CameraImpl.java:898)
       at androidx.camera.core.internal.CameraUseCaseAdapter.detachUseCases(CameraUseCaseAdapter.java:603)
       at androidx.camera.lifecycle.LifecycleCamera.onStop(LifecycleCamera.java:97)
       at androidx.camera.lifecycle.LifecycleCamera.suspend(LifecycleCamera.java:140)
       at androidx.camera.lifecycle.LifecycleCameraRepository.suspendUseCases(LifecycleCameraRepository.java:472)
       at androidx.camera.lifecycle.LifecycleCameraRepository.setInactive(LifecycleCameraRepository.java:417)


Due to this they're not able to move forward. My question is, when exactly does this error occur? I've also attached user's device screen recording, and as you can see he's not able to capture anything. But if I reproduce this on my device, it works just fine. 

Below are the device details for which users are facing issue

Samsung Galaxy S23 FE, Android version 14
Google Pixel 6a, Android 14
Redmi Note 8, Android 11
Oneplus Nord CE2, Android 14
Redmi Note 7 pro, Android 10

Any help would be greatly appreciated. Let me know if any further information is provided. Thanks!
WhatsApp Video 2024-10-01 at 5.10.19 PM.mp4

Scott Nien

unread,
Oct 17, 2024, 3:53:28 AMOct 17
to Ishank Nijhawan, Android CameraX Discussion Group
Hi, thanks for reaching out to report the issue.  
Is there any chance that you can get the adb logcat files for us to analyze further ? 

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/c0c75aa3-2e87-4ff9-980b-d5c9e0c39ee5n%40android.com.

Ishank Nijhawan

unread,
Oct 17, 2024, 3:59:08 AMOct 17
to Android CameraX Discussion Group, scot...@google.com, Android CameraX Discussion Group, Ishank Nijhawan
Hi Scott, unfortunately this exception is occurring for a production users so I don't have the exact logs. Plus, I'm not able to reproduce this issue on my device as well
I checked this github forum and the issue seems to be similar to mine https://github.com/android/camera-samples/issues/410
Kindly let me know if I can do anything to help you here

Christian Deschenes

unread,
Oct 17, 2024, 9:39:17 AMOct 17
to Ishank Nijhawan, Android CameraX Discussion Group, scot...@google.com

Christian Deschenes

unread,
Oct 17, 2024, 9:41:55 AMOct 17
to Ishank Nijhawan, Android CameraX Discussion Group, scot...@google.com

Scott Nien

unread,
Nov 26, 2024, 2:51:26 AMNov 26
to Ishank Nijhawan, Android CameraX Discussion Group
Hi Ishank, 

Sorry for the late reply!   Can you possibly tell if the issue is caused by takePicture being interrupted by lifecycleOwner stop event such as activity or fragment is stopped or destroyed ?  
I mean, if you log every takePicture onError event,  the takePicture interruption is also logged but it's not an actual issue that we have to worry about.  

But if it is not ,  then it's a real issue that we need to investigate further.  In our experience,  there are some devices having issue that takePicture will hang when using some certain resolutions. 

Scott
Message has been deleted

Scott Nien

unread,
Nov 27, 2024, 4:47:52 AM (14 days ago) Nov 27
to Stanislav Sobolevskii, Android CameraX Discussion Group, Ishank Nijhawan
> The same issue happens to me for pixel 8 and 1280x720 (Preview+Video+ImageCapture+ImageAnalysis)
Thanks for sharing !   May I know what CameraX version you were using ? 

On Wed, Nov 27, 2024 at 5:09 PM Stanislav Sobolevskii <stanislav....@revolut.com> wrote:
The same issue happens to me for pixel 8 and 1280x720 (Preview+Video+ImageCapture+ImageAnalysis)

CONFIDENTIAL

This  e-mail  and  any  attachments  are  confidential  and  intended  solely  for  the  addressee  and  may  also  be privileged or exempt from disclosure under applicable law. If you are not the addressee, or have received this e-mail in error, please notify the sender immediately, delete it from your system and do not copy, disclose or otherwise act upon any part of this e-mail or its attachments. Internet communications are not guaranteed to be secure or virus-free. Revolut does not accept responsibility for any loss arising from unauthorised access to, or interference with, any Internet communications by any third party, or from the transmission of any viruses. Replies to this e-mail may be monitored by Revolut for operational or business reasons. Any  opinion  or  other  information  in  this  e-mail  or  its  attachments  that  does  not  relate  to  the  business  of Revolut is personal to the sender and is not given or endorsed by Revolut. Registered  Office: 7  Westferry  Circus,  Canary  Wharf, London,  E14  4HD,  United  Kingdom.  Main  Office: 7 Westferry  Circus,  Canary  Wharf, London,  E14  4HD, United  Kingdom. Revolut  Ltd  is  authorised  and regulated by the Financial Conduct Authority under the Electronic Money Regulations 2011, Firm Reference 900562.

Stanislav Sobolevskii

unread,
Nov 27, 2024, 6:52:09 AM (14 days ago) Nov 27
to Android CameraX Discussion Group, scot...@google.com, Android CameraX Discussion Group, Ishank Nijhawan, Stanislav Sobolevskii
Sorry. I think I missed the thread, that is why I deleted my message. I use 1.4.0
https://groups.google.com/a/android.com/g/camerax-developers/c/2se55aTrZCk

Scott Nien

unread,
Nov 28, 2024, 8:57:49 PM (12 days ago) Nov 28
to Stanislav Sobolevskii, Android CameraX Discussion Group, Ishank Nijhawan
No worries !  Thanks for letting us know Pixel 8 also has the issue. I think it is very helpful and we will keep you posted if we have any findings.  
Reply all
Reply to author
Forward
0 new messages