Closed Bug 1803530 Opened 2 years ago Closed 1 year ago

WebRTC hw encoding on Android will skip frames with odd resolutions

Categories

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

Firefox 108
Unspecified
Android
defect

Tracking

()

VERIFIED FIXED
109 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox107 --- unaffected
firefox108 + verified
firefox109 + verified

People

(Reporter: pehrsons, Assigned: pehrsons)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

On Android when h264 hw encoding is available (it mostly is), we negotiate h264 by default.

These hw encoders tend to be picky on the resolution they will accept. libwebrtc for instance sets the resolution alignment on Android MediaCodecs to 16.

Before bug 1780310 we had a particular way of calculating resolutions, mainly for simulcast, that would normally result in 16-aligned dimensions. This behavior was due to limitations in libwebrtc; it would only accept layers with exactly matching aspect ratios.

Bug 1780310 left the handling to libwebrtc since those limitations were gone. However, on Android where the encoder is picky, we 1) do not tell libwebrtc about this pickiness, and 2) do not handle said resolution alignment when signaled.

This is a simple blanket fix to avoid a regression in 108.
This assumes MediaDataEncoder is mainly used for hardware encoding, therefore
the main use cases on desktop should still use other alignment (libwebrtc
encoders).

Pushed by pehrsons@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/fae38792970a
Request 16-alignment for MediaDataEncoder. r=jolin,webrtc-reviewers,jib
https://hg.mozilla.org/integration/autoland/rev/a57a28264a06
Follow resolution alignment in VideoStreamFactory. r=webrtc-reviewers,jib
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch

:apehrsons do you have any clear STR that can be provided to QA before nominating this for uplift into 108? It would be good to have some verification in nightly first.

Flags: qe-verify+
Flags: needinfo?(apehrson)

STR:

  • Load https://jsfiddle.net/pehrsons/cq3wjnba/show (thanks jib for the original fiddle)
  • Make sure h264 is checked
  • Click gUM! to start capturing video
  • Some Android devices may fail to encode h264, then they are no good for verification. We have for instance seen a Pixel 6 that may have been blocked. If you see two live video elements you are good.
  • Set the downscale value so that either width*downscale or height*downscale would be an odd number.

This bug is verified if at this point there are two live video elements.
This bug is NOT verified if one video element is frozen.

Flags: needinfo?(apehrson)

The patch landed in nightly and beta is affected.
:pehrsons, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox108 to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(apehrson)

Verified as fixed on the latest Nightly 109.0a1 (2022-12-06) build.
Devices used:

  • Oppo Find X5 (Android 12).
  • Google Pixel 6 (Android 13).

Using the steps given above, the two live video elements were displayed.

Flags: qe-verify+

Comment on attachment 9306236 [details]
Bug 1803530 - Follow resolution alignment in VideoStreamFactory. r?#webrtc-reviewers!

Beta/Release Uplift Approval Request

  • User impact if declined: Video calls on Android (webrtc) are likely to freeze for remote peers at some point because we do not send frames for certain resolutions for the default codec on Android. The affected resolutions could be set by the site or by libwebrtc under the hood.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: see comment 6
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This bug adds a bit of plumbing and some logic to adjust the send resolution. gtest coverage of the resolution adjustment exists. mochitest coverage of both pieces exist. No lifetime/timing changes. Multiple threads access the relevant data but it is const so no real concern here.
  • String changes made/needed:
  • Is Android affected?: Yes
Flags: needinfo?(apehrson)
Attachment #9306236 - Flags: approval-mozilla-beta?
Attachment #9306235 - Flags: approval-mozilla-beta?

Comment on attachment 9306235 [details]
Bug 1803530 - Request 16-alignment for MediaDataEncoder. r?jolin!, r?#webrtc-reviewers!

Changing flag to release since we are in RC week for 108

Attachment #9306235 - Flags: approval-mozilla-beta? → approval-mozilla-release?

Comment on attachment 9306236 [details]
Bug 1803530 - Follow resolution alignment in VideoStreamFactory. r?#webrtc-reviewers!

Approved for 108.0rc2

Attachment #9306236 - Flags: approval-mozilla-beta? → approval-mozilla-release+
Attachment #9306235 - Flags: approval-mozilla-release? → approval-mozilla-release+
Flags: qe-verify+

Verified as fixed on the latest RC 108.1.0 build2.
Devices used:

Oppo Find X5 (Android 12).

Using the same steps as before, the two live video elements were displayed.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: