WebView crash when accessing camera on Android R + external camera HAL

568 views
Skip to first unread message

Michael Goffioul

unread,
Feb 26, 2021, 3:18:01 PM2/26/21
to android-webview-dev
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.

Torne (Richard Coles)

unread,
Mar 1, 2021, 10:47:18 AM3/1/21
to Michael Goffioul, android-webview-dev
Does this same issue happen in Chrome on this device? This doesn't seem likely to be WebView-specific, and so you're more likely to find someone who can help if you can reproduce it in Chrome and file a bug against Chrome. The WebView team don't have detailed knowledge about many of the common parts of Chromium code like the media support.

--
You received this message because you are subscribed to the Google Groups "android-webview-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-webview...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/android-webview-dev/CAB-99Lu5Wz2V12rvSMda2epTwyqW5%2B74j5qKw8LZODvDULjqhA%40mail.gmail.com.

Michael Goffioul

unread,
Mar 1, 2021, 11:00:05 AM3/1/21
to android-webview-dev
Yes, Chrome also crashes the same way. I'll file a bug against Chrome, then.

Eyasin Mollah

unread,
Jul 24, 2023, 9:57:14 AM7/24/23
to android-webview-dev, Michael Goffioul
Hi, Michael. Have you been able to fix the error in webview and Chrome?

Michael Goffioul

unread,
Jul 24, 2023, 10:14:16 AM7/24/23
to Eyasin Mollah, android-webview-dev
You can find the bug report here: https://bugs.chromium.org/p/chromium/issues/detail?id=1183362
A change has been integrated into Chrome, which avoids the crash. The more correct approach of handling camera ID as string (and not integer) has never been done, to my knowledge.
Reply all
Reply to author
Forward
0 new messages