Closed Bug 1776595 Opened 2 years ago Closed 2 years ago

Camera device list empty due to NPE in Camera2Enumerator::convertSizes in libwebrtc sdk

Categories

(Core :: WebRTC: Audio/Video, defect, P3)

Firefox 101
ARM
Android
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: benedictpak, Unassigned)

References

Details

Steps to reproduce:

Using Fenix 101.2.0, or GeckoView-example on Samsung Galaxy Note 10+ on Android 12:

  1. Visit https://mozilla.github.io/webrtc-landing/gum_test.html
  2. Click Camera
  3. Allow permission for Firefox to use the camera while using the application

Actual results:

"NotFoundError: The object cannot be found here." appears.

Expected results:

Fenix should prompt "Allow the site to use your camera", then the camera should start capturing.

Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → Android
Hardware: Unspecified → ARM
Blocks: media-triage
Blocks: webrtc-triage
No longer blocks: media-triage

Thanks Benedict for filing! This seems device dependent, as I'm unable to reproduce on my (admittedly ancient) Samsung S9. Maybe others on our team have newer devices to test with...

Do you happen to have the line number for the exception in convertSizes?

And lastly, did this work before in an earlier version? Determining if it's a regression would help us find it and also help escalate priority. Thanks

Flags: needinfo?(benedictpak)

Hi Jan, thanks for the response!

I'm not sure if it worked in an earlier version since I only recently started trying out Firefox Mobile. Do you have a Samsung Galaxy S20? This issue could be reproduceable on that device as well.

The line number for the exception is on line 246, when enumerating cameraSizes. The value of cameraSizes is null, because of line 158 for camera ID 4. The fix is actually available here in mozilla's libwebrtc:
https://github.com/mozilla/libwebrtc/commit/1460e15a45525a2d2f5b6957b79c8a84dd94d4ce

I tested it on my local build of fenix, and it works fine. There is an additional fix to be made for GeckoView Example for Android 12 when testing, in GeckoViewActivity.java line 2389 - just set the flag to be FLAG_IMMUTABLE.

getUserMedia works fine on Chrome 103 for Samsung Note 10+. I never had an issue with it. I suspect that Google had already merged a fix sometime before.

I was searching for this issue online and these are the relevant issues I have found:
https://github.com/twilio/twilio-video.js/issues/1264
https://github.com/mozilla-mobile/fenix/issues/18368
https://deepinout.com/android-camera-official-documentation/android-camera2-api/android-camera2-api-streamconfigurationmap-coding-1.html (The reference here is in Chinese (Mandarin), but there's code below indicating that camera ID 4 throws this error on Samsung Note 10+ and Galaxy S20.)

Apologies for not making a pull request - I found it very complex to do so here. I hope you can apply this patch soon!

Flags: needinfo?(benedictpak)
No longer blocks: webrtc-triage
Severity: -- → S4
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.