Camerax Display Black screen in frot camera while using Videocapture class in specific devcie

132 views
Skip to first unread message

Surbhi Dixit

unread,
Aug 21, 2024, 3:17:44 AMAug 21
to Android CameraX Discussion Group
Hello team
i am using
https://github.com/android/camera-samples/tree/main/CameraXVideo
to record video how ever when i switch to front camera it display black preview in motorola edge 20 fusion, android version 12
i have tried to run with
       val recorder = Recorder.Builder()
            .setQualitySelector(QualitySelector.from(Quality.LOWEST))
            .build()
 But front camera seems to provide black preview only
//
androidx-camera-core = { module = "androidx.camera:camera-core", version.ref = "cameraXVersion" }
androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "cameraXVersion" }
androidx-camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "cameraXVersion" }
androidx-camera-extensions = { module = "androidx.camera:camera-extensions", version.ref = "cameraXVersion" }
androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "cameraXVersion" }
androidx-camera-video = { module = "androidx.camera:camera-video", version.ref = "cameraXVideoVersion" }

 cameraXVersion = "1.4.0-alpha02"
cameraXVideoVersion = "1.1.0-beta01"

i observe that on same device if i run https://github.com/android/camera-samples/tree/main/CameraXBasic then back and front both camera works fine 

Leo Huang

unread,
Aug 21, 2024, 4:10:14 AMAug 21
to Surbhi Dixit, Android CameraX Discussion Group
Hi,
Could you try if calling this API `VideoCapture.Builder.setSurfaceProcessingForceEnabled()` when building VideoCapture can workaround this problem?

Surbhi Dixit <surbhid...@gmail.com> 於 2024年8月21日 週三 下午3:17寫道:
--
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/428bf3e6-186c-402a-bd58-a7c56f474fa0n%40android.com.

Surbhi Dixit

unread,
Aug 21, 2024, 6:10:34 AMAug 21
to Android CameraX Discussion Group, leoh...@google.com, Android CameraX Discussion Group, Surbhi Dixit
Thanks for early reply
VideoCapture.Builder.setSurfaceProcessingForceEnabled() seem to work for me
i have to use this version
androidx.camera:camera-video:1.4.0-beta02
Thank you 

Leo Huang

unread,
Aug 21, 2024, 9:50:08 PMAug 21
to Surbhi Dixit, Android CameraX Discussion Group
Hi,

Thank you for trying and it seems this might be a device specific issue. 

For now, it is suggested to call the API only on the problematic device. You can use something like Build.Model and Build.Brand to identify it. (See this example: https://android.googlesource.com/platform/frameworks/support/+/androidx-master-release/camera/camera-core/src/main/java/androidx/camera/core/internal/compat/quirk/ImageCaptureRotationOptionQuirk.java#49)

Could you also share the Build.Model and Build.Brand values from the device?

We can then add it to our workaround list, so you (and other developers) won't need to rely on the hidden API in future releases.

Thank you.


Surbhi Dixit <surbhid...@gmail.com> 於 2024年8月21日 週三 下午6:10寫道:

Surbhi Dixit

unread,
Aug 22, 2024, 12:41:14 AMAug 22
to Android CameraX Discussion Group, leoh...@google.com, Android CameraX Discussion Group, Surbhi Dixit
yes it is device specific issue here is the model name 
Model: motorola edge 20 fusion, Brand: motorola. 
thanks for the link will check it as well 

Astha Garg

unread,
Aug 22, 2024, 2:28:01 AMAug 22
to Android CameraX Discussion Group, surbhid...@gmail.com, leoh...@google.com, Android CameraX Discussion Group

Hi Surbhi,

I saw your issue and it looks like it's similar to what I'm also facing but on a different device and with Quality set to HIGHEST.

Also, In my case the issue could be with image capture or video recording use case, I'm unable to know because this is happening on a customer's device.

So, I wanted to know if you are facing the same black screen issue with image capture and setting quality to 100 (which is the max value).


@Leo - 

How is the fix working (VideoCapture.Builder.setSurfaceProcessingForceEnabled()) working exactly? Will it work for this issue as well ? - https://issuetracker.google.com/issues/359729269


Looking forward to your reply, I'm also stuck :(


Regards,

Astha

Surbhi Dixit

unread,
Aug 22, 2024, 3:47:47 AMAug 22
to Android CameraX Discussion Group, aashi...@gmail.com, Surbhi Dixit, leoh...@google.com, Android CameraX Discussion Group
hi astha 
for image capture youmight try to  use  https://github.com/android/camera-samples/tree/main/CameraXBasic   as i have not face any black screen preview  in this example  

this solution works for me for camera recording with VideoCapture 
VideoCapture.Builder.setSurfaceProcessingForceEnabled().  

Leo Huang

unread,
Aug 22, 2024, 3:55:09 AMAug 22
to Android CameraX Discussion Group, surbhid...@gmail.com, aashi...@gmail.com, Leo Huang, Android CameraX Discussion Group
Hi Astha,

If you've worked with android's camera2 API, you'll know the camera service requires "Surface" objects to output data. VideoCapture normally creates a Surfaces using MediaCodec and sends it to the camera service.

When surface processing (OpenGL) is enabled, VideoCapture does something extra: it creates another Surface using SurfaceTexture, and sends this Surface to the camera service instead of the MediaCodec one.

The key is, the camera HAL (implemented by OEM) might handle these two Surface types in different ways. Sometimes, there can be bugs in how it handles one type but not the other. We don't know exactly why these bugs happen. Switching to using the SurfaceTexture Surface can sometimes work around these problems just speaking from experience.

For your case, it's possible that making this switch could fix the issue you're seeing. Unfortunately, the only way to know for sure is to try it out on real devices.

surbhid...@gmail.com 在 2024年8月22日 星期四下午3:47:47 [UTC+8] 的信中寫道:

Astha Garg

unread,
Aug 22, 2024, 4:03:42 AMAug 22
to Leo Huang, Android CameraX Discussion Group, surbhid...@gmail.com
Hi Leo,
Thanks for the explanation.
Let me try to check after adding setSurfaceProcessingForceEnabled() on the affected devices.
If it fixes my issue, I will share the model details so the fix can come from Camerax through Quirk class-related changes.

Astha Garg

unread,
Aug 22, 2024, 4:28:47 AMAug 22
to Leo Huang, Android CameraX Discussion Group, surbhid...@gmail.com
Also, what is the release timeline of the Camerax 1.4.0 stable version which has setSurfaceProcessingForceEnabled() API?

Leo Huang

unread,
Aug 22, 2024, 5:37:00 AMAug 22
to Android CameraX Discussion Group, aashi...@gmail.com, Android CameraX Discussion Group, surbhid...@gmail.com, Leo Huang
Timeline of CameraX 1.4.0 stable version not yet confirmed. We'll be releasing the stable version later this year. The exact timing will depend on whether we need to incorporate any additional bug fixes for the rc.

aashi...@gmail.com 在 2024年8月22日 星期四下午4:28:47 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages