Latest updates causes ImageCapture to halt the preview

157 views
Skip to first unread message

Raz

unread,
Jul 2, 2021, 12:38:11 PM7/2/21
to Android CameraX Discussion Group
The camera latest updates cause the ImageCapture use case to halt the preview when taking a picture. When running the same code in the versions below, saving an image happens in the background and does not have an effect on the preview. But when updating to version 5-25/6-26 the preview stops until the image is saved - it is not just the preview, when recording and capturing an image while recording, the video stops same as the preview did, so essentially when capturing an image the preview gets halted but the camera is not disconnected so even the halted preview is still being recorded.

Last stable versions of the dependencies that probably cause the problem(Even updating each only causes the problem described above):

"androidx.camera:camera-core:1.1.0-alpha04"
implementation "androidx.camera:camera-camera2:1.1.0-alpha04"
implementation "androidx.camera:camera-lifecycle:1.1.0-alpha04"
implementation "androidx.camera:camera-extensions:1.0.0-alpha24"

Is it a bug? is it intended to be this way? and if it is, is there a way to avoid this behavior?

Leo Huang

unread,
Jul 2, 2021, 1:44:37 PM7/2/21
to Raz, Android CameraX Discussion Group
Hi Raz,

Does the issue happen when the use case combination is "ImageCapture + VideoCapture + Preview"?

When the use case combination change to only "ImageCapture + Preview", does the issue still occur?

Ask this because if VideoCapture is bound, the new version will use TEMPLATE_RECORD instead of TEMPLATE_PREVIEW  for repeating request. I suspect this may be the reason.


Raz <raz.l...@gmail.com> 於 2021年7月3日 週六 上午12:38寫道:
--
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/bded1b35-1f02-477d-b654-310cdfade429n%40android.com.

Raz

unread,
Jul 2, 2021, 3:33:00 PM7/2/21
to Android CameraX Discussion Group, leoh...@google.com, Android CameraX Discussion Group, Raz
Yes,  the use case combination is "Preview+ VideoCapture + ImageCapture".
I checked and the issue does not occur when the combination is only "Preview + ImageCapture".
By "if VideoCapture is bound, the new version will use TEMPLATE_RECORD instead of TEMPLATE_PREVIEW  for repeating request", do you mean that with the new video capture use case bound, this issue will not occur?

ב-יום שישי, 2 ביולי 2021 בשעה 20:44:37 UTC+3, leoh...@google.com כתב/ה:

Leo Huang

unread,
Jul 4, 2021, 11:24:50 PM7/4/21
to Raz, Android CameraX Discussion Group
Thanks for the update. The new version here means "version 5-25/6-26", i.e. the alpha05, alpha06 will use TEMPLATE_RECORD instead of TEMPLATE_PREVIEW to set repeating request which causes the issue you observed.
Just found a possible solution, more research may be needed. By the way, what devices do you test?


Raz <raz.l...@gmail.com> 於 2021年7月3日 週六 上午3:33寫道:

Raz

unread,
Jul 5, 2021, 6:23:54 AM7/5/21
to Android CameraX Discussion Group, leoh...@google.com, Android CameraX Discussion Group, Raz
Currently I have tested on Xiaomi Redmi note 9s(api 30,29), and galaxy s21 ultra(api 30).
By the way, when I tried to test the app on the emulator with api 23 the use case combination of "Preview + ImageCapture + VideoCapture" fails to bind with the following error:

Failed to bind use cases
java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 0.  May be attempting to bind too many use cases. Existing surfaces: [] New configs: [androidx.camera.core.impl.ImageCaptureConfig@ea0f3d7, androidx.camera.core.impl.VideoCaptureConfig@a2d3756, androidx.camera.core.impl.PreviewConfig@3406d71]

But when binding every other combination without the VideoCapture, the error does not occur. So why does the video capture works on the physical devices that I have tested? is it because the api? although it should work for api 21 and up.
ב-יום שני, 5 ביולי 2021 בשעה 06:24:50 UTC+3, leoh...@google.com כתב/ה:

Leo Huang

unread,
Jul 5, 2021, 9:32:07 AM7/5/21
to Raz, Android CameraX Discussion Group
The "failed to bind" relates to the supported resolution combinations mentioned in the API doc ProcessCameraProvider#bindToLifecycle.

The resolutions that can be supported depends on the camera device hardware level that there are some default guaranteed resolutions listed in CameraDevice.createCaptureSession(List, android.hardware.camera2.CameraCaptureSession.StateCallback, Handler).

The supported table is defined in this chapter.

In LEGACY-level guaranteed configurations, there is no guarantee combination for Preview (PRIV) + VideoCapture (PRIV) + ImageCapture (JPG).

So it will always fail to bind these 3 use cases on LEGACY camera devices. AFAIK, the hardware level of the emulators all belong to LEGACY camera. 

The failure will also occur on a physical device if it belongs to LEGACY camera. They are usually devices with lower API level but not necessarily.

Raz <raz.l...@gmail.com> 於 2021年7月5日 週一 下午6:23寫道:

Raz

unread,
Jul 5, 2021, 10:36:42 AM7/5/21
to Android CameraX Discussion Group, leoh...@google.com, Android CameraX Discussion Group, Raz

Got it. Quick reply appreciated  👍 
ב-יום שני, 5 ביולי 2021 בשעה 16:32:07 UTC+3, leoh...@google.com כתב/ה:
Reply all
Reply to author
Forward
0 new messages