CameraX photo capture freeze (frequently)

536 views
Skip to first unread message

Mohammad Sajib Al Seraj

unread,
Mar 4, 2022, 2:35:54 PM3/4/22
to Android CameraX Discussion Group

Hello,
I am facing a similar problem (https://stackoverflow.com/questions/70706754/camerax-video-recording-freezes-and-generates-empty-video-file/71356133#71356133) for capturing photo. I am trying to take multiple photos using our app. Preview and taking the first photo is always fine. But when I try to take a second or third photo, camera stops taking photos. 
Log is attached here. Thanks in advance.

imageCapture.takePicture(image, ContextCompat.getMainExecutor(this),

                new ImageCapture.OnImageSavedCallback() {

                    @Override

                    public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {

                        runOnUiThread(() -> {

                            onPictureTakenOption(photoFilePath);

                        });

                    }

 

                    @Override

                    public void onError(@NonNull ImageCaptureException exception) {

                    }

                }

        );

logcat1646418855298[1].txt

Android CameraX Discussion Group

unread,
Mar 4, 2022, 4:55:16 PM3/4/22
to Android CameraX Discussion Group, Mohammad Sajib Al Seraj
Hi Mohammad,

Can you tell us what device and OS this is seen on? Have you tried it on any other devices?

Thanks,
-Eric

Mohammad Sajib Al Seraj

unread,
Mar 4, 2022, 5:00:25 PM3/4/22
to Android CameraX Discussion Group
I have faced this problem with Samsung A71 5G (Android 11) and Samsung S10+(Android 11). I have implemented night mode in this application, so I only tried with only CameraX vendor extension supported devices.

Thanks
Mohammad

Charcoal Chen

unread,
Mar 7, 2022, 1:20:41 AM3/7/22
to Mohammad Sajib Al Seraj, Android CameraX Discussion Group
Hi,

I tried to run the extensionstestapp with NIGHT mode on Samsung S10+ (sm-g975u1, Android 11) and A71 (sm-a715f, Android 11) devices in our test lab, but I can't reproduce the problem.

By checking the log, it looks the issue is related to the following log. But it is unclear to know what caused the issue since I can't reproduce the problem.

03-04 13:24:44.454  8506 10413 W System  : A resource failed to call release.
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: RuntimeException while executing runnable CallbackListener,androidx.camera.core.ProcessingImageReader$3@4a46dae with executor java.util.concurrent.ThreadPoolExecutor@601e74f[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 4]
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: java.util.concurrent.RejectedExecutionException: Task CallbackListener,androidx.camera.core.ProcessingImageReader$3@4a46dae rejected from java.util.concurrent.ThreadPoolExecutor@601e74f[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 4]
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2086)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1394)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at androidx.concurrent.futures.AbstractResolvableFuture.executeListener(AbstractResolvableFuture.java:1053)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at androidx.concurrent.futures.AbstractResolvableFuture.complete(AbstractResolvableFuture.java:902)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at androidx.concurrent.futures.AbstractResolvableFuture.setException(AbstractResolvableFuture.java:712)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at androidx.concurrent.futures.CallbackToFutureAdapter$SafeFuture.setException(CallbackToFutureAdapter.java:184)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at androidx.concurrent.futures.CallbackToFutureAdapter$Completer.finalize(CallbackToFutureAdapter.java:337)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at java.lang.Daemons$Daemon.run(Daemons.java:139)
03-04 13:24:44.457  8506 10413 E bstractResolvableFuture: at java.lang.Thread.run(Thread.java:923)

Could you help to provide more information to help us clarify this issue?
  1. Could you provide the model number (SM-XXXX) of the devices which you can reproduce the issue?
  2. What is the issue occurrence rate?
  3. Are there any reproduce steps that is easier to reproduce the issue?
  4. Is it possible to provide a sample project with the source code to reproduce the issue? Or, could you help to check whether the issue can be reproduced by enabling NIGHT mode in the CameraXBasic sample app?
If there is any other information which you think it might related to the issue, please also provide it. Thanks.



--
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/CAHDOb3n0dY-E2Esrf_5GPSZRqbNP8qUt4LffQ7-uXuvtgC2aRg%40mail.gmail.com.

Mohammad Sajib Al Seraj

unread,
Mar 7, 2022, 1:07:03 PM3/7/22
to Charcoal Chen, Android CameraX Discussion Group
Thank you so much for the analysis. 

1.    Could you provide the model number (SM-XXXX) of the devices which you can reproduce the issue? Samsung S10+ (SM-G975U1) and A71 5G (SM-A716V)

2.    What is the issue occurrence rate? – The occurrence rate is very high (one per 2-3 events).

3.    Are there any reproduce steps that is easier to reproduce the issue? – In our app(I have attached one screenshot of our app) we need to take multiple photos. This issue is only happening for either the second or third capture, not the first capture.

4.    Is it possible to provide a sample project with the source code to reproduce the issue? Or, could you help to check whether the issue can be reproduced by enabling NIGHT mode in the CameraXBasic sample app? – I checked with CameraXBasic sample app which is working fine. I have attached a java file from my project where I have implemented image capture.

NB: I have tested our app with the CameraX vendor extension not supported devices(Pixel 4a and other devices) where I didn’t face this issue(not a single time).

Thanks 
Mohamamd

Screenshot_20220307-124159_Biometric_ID[1].jpg
CaptureImage.java

Charcoal Chen

unread,
Mar 7, 2022, 10:47:04 PM3/7/22
to Mohammad Sajib Al Seraj, Android CameraX Discussion Group
Hi,

I might need more time to reproduce the issue. But I have one question after checking the code. I found you always call the InitCamera() function to unbind all and recreate use cases after capturing an image. I'm thinking whether it is necessary. It seems there is no change related to the uses' case settings. Maybe you can try to NOT unbind all and recreate use cases after capturing an image. This might be a faster approach to fix the issue before I reproduce it and find a solution for it.

Mohammad Sajib Al Seraj

unread,
Mar 8, 2022, 9:56:55 AM3/8/22
to Charcoal Chen, Android CameraX Discussion Group
I did it and I think the issue is fixed. Thank you so much for your valuable feedback. 

Thanks
Mohammad

Ultima Ratio

unread,
Aug 21, 2024, 7:22:34 AMAug 21
to Android CameraX Discussion Group, Mohammad Sajib Al Seraj, Android CameraX Discussion Group, charco...@google.com
I have certain Samsung devices (Android 14) which are freezing in punch-to-zoom... The Jetpack app works fine. Zooming code is basically the same..

But for whatever reasons, it says, it has no useCase...

The same code works fine, if I am in video mode. 

It also works fine on Pixel Android 14 devices. I am switching to useCaseGroup and try again... If its still not working, I will post the log output.

Ultima Ratio

unread,
Aug 21, 2024, 10:34:25 AMAug 21
to Android CameraX Discussion Group, Ultima Ratio, Mohammad Sajib Al Seraj, Android CameraX Discussion Group, charco...@google.com
Ok, the issue is again the ImageCapture.CAPTURE_MODE_ZERO_SHUTTER_LAG property..

If you add a simple pinch to zoom listener to the CameraXBasic example and upgrade it to 1.4.0-rc01 and then setCaptureMode(ImageCapture.CAPTURE_MODE_ZERO_SHUTTER_LAG), the preview "freezes" when you pinch to zoom..

BUT: Only for Samsung Android 14 devices. Samsung Flip4-5G and Samsung S24 Ultra. 

Same code works fine on Pixel 7A and Pixel Tablet (both Android 14). It also works fine  with the front lens camera, which is kinda strange.

Video also works, but video doesnt have this captureMode property anyway.


BR, Joerg

PS.: Can provide a minimal example based on the CameraXBasic if someone needs it.

Kailiang Chen

unread,
Aug 21, 2024, 12:20:49 PMAug 21
to Ultima Ratio, Android CameraX Discussion Group, Mohammad Sajib Al Seraj, charco...@google.com
I've verified this issue is reproducible on Samsung s24 Ultra but not Pixel 8 Pro and Xiaomi 14 Ultra.
I've filed the bug: https://buganizer.corp.google.com/issues/361328838 for further investigation.

My hypothesis is it's a device-specific issue for reprocessing. 
We need to add CTS for reprocessing and report this bug to Samsung after we verified there is no bug in CameraX.

Kailiang Chen

unread,
Aug 21, 2024, 12:23:27 PMAug 21
to Ultima Ratio, Android CameraX Discussion Group, Mohammad Sajib Al Seraj, charco...@google.com
I'll disable the ZSL for these Samsung devices in our quirk as a temporary fix.
I've verified it will work on Samsung s24 Ultra.
Reply all
Reply to author
Forward
0 new messages