I'm using a webview-based app on a device running Android R. The device only has the external camera HAL enabled: android.hardware...@2.5-external-service. And the device has one USB camera connected to it.
The webview is self-compiled @ 88.0.4324.181 (but I can reproduce the problem also with 87.0.4280.66).
When the webview attempts to access the camera (e.g. navigator.mediaDevices.getUserMedia({video:true,audio:true})), the whole app crashes and logcat contains entries about invalid camera index followed by a NullPointerException. The invalid camera index message comes from here:
and the NullPointerException is simply a consequence of getCameraCharacteristics() returning null. The uncaught java exception is then handled in jni_android.cc and triggers the app crash. I added some more extensive debug information and determined that when the problem occurs:
index = 100
cameraIdList = [ "100" ]
So it seems that chromium code assumes the camera ID is identical to a 0-based index, but this is not valid in this case. The value 100 is coming from the default ID offset used in the external camera HAL:
Is this a bug in webview/chromium, or is it just that the external camera HAL is not (supposed to be) supported?
Michael.