Bug Report: Android 9.0 r2, camera hal conflict

615 views
Skip to first unread message

Katharine Chui

unread,
Jul 11, 2020, 4:00:20 AM7/11/20
to Android-x86
In android pie, aosp introduced their own v4l2 and v4l2 probing mechanism
During android x86 9.0 build, device/generic/common/treble.mk includes:
PRODUCT_PACKAGES += ... android.hardware...@2.4-impl android.hardware...@2.4-external-service
Giving android itself the ability to use v4l2 devices through hal3 camera 3.4 with automatic probing
This in turn creates an inaccessible device, probably due to competing hal1 and hal3 implementations

07-11 04:56:06.697  1401  1510 I Cam...@1.0-impl: Opening camera 0     
07-11 04:56:06.697  1401  1510 D Camera_Factory: CameraFactory::get_camera_info     
07-11 04:56:06.697  1401  1510 D Camera_Factory: CameraFactory::getCameraInfo: id = 0, info = 0xe807f1e8     
07-11 04:56:06.697  1401  1510 D Camera_Factory: CameraFactory::getCameraNum: 1     
07-11 04:56:06.697  1401  1510 D Camera_Factory: CameraFactory::device_open: name = 0     
07-11 04:56:06.697  1401  1510 D Camera_Factory: CameraFactory::cameraDeviceOpen: id = 0     
07-11 04:56:06.697  1401  1510 D Camera_Factory: CameraFactory::getCameraNum: 1     
07-11 04:56:06.697  1401  1510 D CameraHardware: CameraHardware::connectCamera: /dev/video0     
07-11 04:56:06.697  1401  1510 D CameraHardware: CameraHardware::setCallbacks     
07-11 04:56:06.697  1401  1510 D CameraHardware: CameraHardware::getParameters     
07-11 04:56:06.697  1401  1510 D CameraHardware: CameraHardware::putParameters     
07-11 04:56:06.697  4231  4237 I Cam...@2.4-external: ExtCam: adding /dev/video0 to External Camera HAL!     
07-11 04:56:06.697  4231  4237 I CameraProviderManager: Enumerating new camera device: device@3.4/external//dev/video0     
07-11 04:56:06.697  1401  1510 D CameraHardware: CameraHardware::setPreviewWindow: preview_stream_ops: 0xe91ce024     
07-11 04:56:06.697  4231  4237 I CameraService: onDeviceStatusChanged: Status changed for cameraId=/dev/video0, newStatus=1     
07-11 04:56:06.697  4231  4237 I CameraService: onDeviceStatusChanged: Unknown camera ID /dev/video0, a new camera is added     
07-11 04:56:06.697  1401  1510 D CameraHardware: Trivially accept it. No changes detected 

Attempting to use this device usually results in app crashes, or black screen
Jitsi meet behaves in a works on a very very good day basis, since it always attempt to use a front facing camera, while I've used set_prop_if_empty hal.camera.0 0,0 to force hal1 to believe that the first camera is the back camera since apps like Telegram requires that to work. That said front camera is the one probed by provider@2.4

07-11 04:56:01.346  4095  4116 D JitsiMeetSDK: [modules/RTC/RTCUtils.js] Available devices:  [ { kind: 'videoinput',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     label: 'Camera 0, Facing back, Orientation 0',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     groupId: '',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     deviceId: '0',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     facing: 'environment' },
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:   { kind: 'videoinput',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     label: 'Camera 1, Facing front, Orientation 0',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     groupId: '',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     deviceId: '1',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     facing: 'front' },
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:   { kind: 'audioinput',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     label: 'Audio',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     groupId: '',
07-11 04:56:01.346  4095  4116 D JitsiMeetSDK:     deviceId: 'audio-1' } ]
...
07-11 04:57:02.551  4095  4192 I org.webrtc.Logging: Camera1Session: Open camera 1
07-11 04:57:02.551  4095  4192 D com.oney.WebRTCModule.WebRTCModule: CameraEventsHandler.onCameraOpening: cameraName=Camera 1, Facing front, Orientation 0
07-11 04:57:02.552  4231  4250 I CameraService: CameraService::connect call (PID -1 "org.jitsi.meet", camera ID /dev/video0) for HAL version default and Camera API version 1
07-11 04:57:02.554  4231  4250 E CameraProviderManager: filterLogicalCameraIdsLocked: Failed to getCameraCharacteristics for id 0
07-11 04:57:02.565  4095  4095 E org.jitsi.meet: No package ID ff found for ID 0xffffffff.
07-11 04:57:02.566  1424  4315 E FileSource: Failed to open file '/product/media/audio/ui/camera_click.ogg'. (No such file or directory)
07-11 04:57:02.567  4231  4250 E CameraService: Failed to load CameraService sounds: /product/media/audio/ui/camera_click.ogg
07-11 04:57:02.619  4231  4250 E CameraService: Failed to load CameraService sounds: /product/media/audio/ui/VideoRecord.ogg
07-11 04:57:02.655  4231  4250 E CameraService: Failed to load CameraService sounds: /product/media/audio/ui/VideoStop.ogg
07-11 04:57:02.678  4231  4250 I Camera2ClientBase: Camera /dev/video0: Opened. Client: org.jitsi.meet (PID 4095, UID 10080)
07-11 04:57:02.778  4231  4250 W Camera2-Parameters: Unable to find the size to match the given aspect ratio 1.777778.Fall back to 0 x 0
07-11 04:57:02.778  4231  4250 E Camera2-Parameters: Error finding static metadata entry 'android.distortionCorrection.availableModes' (1b0001)
07-11 04:57:02.778  4231  4250 I Camera2-Parameters: initialize: allowZslMode: 0 slowJpegMode 0
07-11 04:57:02.788  4095  4192 I org.webrtc.Logging: Camera1Session: Available fps ranges: [[15.0:30.0]]
07-11 04:57:02.792  4095  4192 I org.webrtc.Logging: Camera1Session: Create new camera1 session on camera 1
07-11 04:57:02.792  4095  4192 I org.webrtc.Logging: Camera1Session: Start capturing
07-11 04:57:02.795  4231  4250 I chatty  : uid=1047(cameraserver) Binder:4231_2 identical 1 line
07-11 04:57:03.748  4231  4250 E Camera3-OutputStream: configureConsumerQueueLocked: Unable to connect to native window for stream 0
07-11 04:57:03.748  4231  4250 E Camera3-Stream: finishConfiguration: Unable to configure stream 0 queue: Invalid argument (-22)
07-11 04:57:03.748  4231  4250 E Camera3-Device: Camera /dev/video0: configureStreamsLocked: Can't finish configuring output stream 0: Invalid argument (-22)
07-11 04:57:03.748  4231  4250 E Camera3-Device: Camera /dev/video0: setUpRequestLocked: Can't set up streams: Invalid argument (-22)
07-11 04:57:03.748  4231  4250 E Camera3-Device: Camera /dev/video0: convertMetadataListToRequestListLocked: Can't create capture request
07-11 04:57:03.748  4231  4250 E Camera2-StreamingProcessor: startStream: Camera 1: Unable to set preview request to start preview: Invalid argument (-22)
07-11 04:57:03.748  4231  4250 E Camera2Client: startPreviewL: Camera 1: Unable to start streaming preview: Invalid argument (-22)
07-11 04:57:03.748  4095  4192 I org.webrtc.Logging: Camera1Session: Stop internal
07-11 04:57:03.781  4231  4250 I Camera3-Device: disconnect: E
07-11 04:57:03.828  4231  4250 I Camera3-Device: disconnect: X
07-11 04:57:03.828  4231  4250 I Camera3-Device: disconnect: E
07-11 04:57:03.831  4231  4250 E CameraProviderManager: filterLogicalCameraIdsLocked: Failed to getCameraCharacteristics for id 0
07-11 04:57:03.831  4231  4250 I CameraService: disconnect: Disconnected client for camera /dev/video0 for PID 4095
07-11 04:57:03.831  4231  4250 I Camera2Client: Camera 1: Closed
07-11 04:57:03.831  4231  4250 I Camera2ClientBase: Closed Camera /dev/video0. Client was: org.jitsi.meet (PID 4095, UID 10080)

I'm currently building android 9.0 r2 without provider@2.4 to see if that allows it to behave just like it was in nougat 

Katharine Chui

unread,
Jul 11, 2020, 8:26:22 AM7/11/20
to Android-x86
Correction: instead of taking camera provider out losing camera access entirely, I should be disabling external camera probe so that the two hal implementation are not fighting with eachother
however, now I'm met with a hal1 <-> libcameraservice error message along with black screen video capture, triggered by starting jitsi meet once, gettings proper video input, turn camera off in the app/close the app, start video capturing again
interestingly, it's only jitsi
ps: with the same version of hardware/libcamera as cm-14.1-r4 which doesn't have this problem

07-11 10:46:10.965  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 2 lines
07-11 10:46:10.969  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 3 lines
07-11 10:46:11.177  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 3 lines
07-11 10:46:11.285  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 3 lines
07-11 10:46:11.493  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 50 lines
07-11 10:46:11.600  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 52 lines
07-11 10:46:12.173  2696  2772 I org.webrtc.Logging: CameraStatistics: Camera fps: 0.
07-11 10:46:14.175  2696  2772 I org.webrtc.Logging: CameraStatistics: Camera fps: 0.
07-11 10:46:14.176  2696  2772 E org.webrtc.Logging: CameraStatistics: Camera freezed.
07-11 10:46:14.176  2696  2772 D com.oney.WebRTCModule.WebRTCModule: CameraEventsHandler.onCameraFreezed: errorDescription=Camera failure.
07-11 10:46:16.325  2696  2696 I JitsiMeetSDK: PictureInPicture Entering Picture-in-Picture
07-11 10:46:16.770  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 5 lines
07-11 10:46:16.941  2696  2722 I JitsiMeetSDK: [features/base/lastn] Setting last N to: 1
07-11 10:46:16.984  2696  2701 I org.jitsi.meet: Compiler allocated 14MB to compile void com.facebook.react.uimanager.x.g()
07-11 10:46:17.091  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 3 lines
07-11 10:46:17.302  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 3 lines
07-11 10:46:17.415  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 4 lines
07-11 10:46:17.621  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 4 lines
07-11 10:46:17.834  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 3 lines      
07-11 10:46:18.040  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 3 lines      
07-11 10:46:18.152  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 9 lines      
07-11 10:46:18.358  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 11 lines      
07-11 10:46:18.859  2696  2722 I JitsiMeetSDK: [features/base/lastn] Setting last N to: -1      
07-11 10:46:19.109  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 4 lines      
07-11 10:46:19.532  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 2 lines      
07-11 10:46:19.535  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 3 lines      
07-11 10:46:19.741  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 4 lines      
07-11 10:46:19.851  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 4 lines      
07-11 10:46:20.164  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 3 lines      
07-11 10:46:20.271  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 3 lines      
07-11 10:46:20.481  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 4 lines      
07-11 10:46:20.595  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 4 lines      
07-11 10:46:20.908  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 3 lines      
07-11 10:46:21.016  1410  1474 I chatty  : uid=1047(cameraserver) HwBinder:1410_1 expire 3 lines      
07-11 10:46:21.223  1394  2980 I chatty  : uid=1047(cameraserver) prov...@2.4-se expire 2 lines      
07-11 10:46:21.331  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:21.435  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:21.540  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:21.645  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:21.749  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:21.854  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:21.959  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:22.063  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:22.179  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found      
07-11 10:46:22.291  1410  1474 E CameraHardwareInterface: dataCallback: memory pool ID 9 not found
...

Katharine Chui

unread,
Jul 11, 2020, 1:39:27 PM7/11/20
to Android-x86
Since android 9 never seems to destroy CameraFactory and CameraHardware objects, I propose that heap to always be released on close, with related runtime members be reset
https://github.com/Kethen/android_hardware_libcamera/commit/8c2ca9870bdc8d2af308988fbe4a64056ac49938

Michael Goffioul

unread,
Jul 11, 2020, 1:46:08 PM7/11/20
to Android-x86
What I'm doing in my build is to make the newer HAL ignore my built-in webcams, so that they're only handled by the legacy HAL. I installed the following file into $(TARGET_COPY_OUT_VENDOR)/etc/external_camera_config.xml:

<ExternalCamera>
    <Provider>
        <!-- Internal video devices to be ignored by external camera HAL -->
        <ignore>
            <id>0</id>
            <id>1</id>
        </ignore>
    </Provider>
</ExternalCamera>

Michael.


--
You received this message because you are subscribed to the Google Groups "Android-x86" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-x86/69e008e6-5ca3-401d-835c-f23f53a2e73bn%40googlegroups.com.

Katharine Chui

unread,
Jul 11, 2020, 1:57:26 PM7/11/20
to andro...@googlegroups.com
Hmm, if it's done that way, a third usb camera will still have issues... not like someone would plug a camera to a laptop with already two cameras tho

Michael Goffioul

unread,
Jul 11, 2020, 2:06:00 PM7/11/20
to Android-x86
Well, maybe you can complement that with /etc/camera.cfg that will define the cameras that are handled by the legacy HAL. AFAIK, if the file exists, any /dev/videoX that is not part of it will be ignored by the legacy HAL.

On Sat, Jul 11, 2020 at 1:57 PM Katharine Chui <kathari...@gmail.com> wrote:
Hmm, if it's done that way, a third usb camera will still have issues... not like someone would plug a camera to a laptop with already two cameras tho

--
You received this message because you are subscribed to the Google Groups "Android-x86" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-x86...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages