Skip to content

rtc: stop disabling H.264 publish for desktop Linux Firefox, never fall back to RTX - #4934

Closed
krithin wants to merge 1 commit into
livekit:masterfrom
krithin:fix/firefox-linux-h264-and-rtx-fallback
Closed

krithin wants to merge 1 commit into
livekit:masterfrom
krithin:fix/firefox-linux-h264-and-rtx-fallback

Conversation

@krithin

@krithin krithin commented Oct 5, 2026

Copy link
Copy Markdown

Fixes #4929

Problem

When enabled_codecs lists H.264 as the only video codec, desktop Linux Firefox's camera track is registered as video/rtx and no subscriber can decode it:

  1. The static client configuration disables H.264 publishing for firefox && (linux || android). That rule was added for Firefox for Android (Remove un-preferred codecs for android firefox #2183, Disable h264 for android firefox #2190). The user agent parser reports Firefox for Android as os: "android", so the linux clause only matches desktop Linux Firefox, which can publish H.264 via OpenH264.
  2. With H.264 removed, that participant's enabled publish codecs are [video/rtx, audio/opus, audio/red]. selectAlternativeVideoCodec returns the first video/ entry, which is video/rtx.

Changes

  • pkg/clientconfiguration/conf.go: narrow the Firefox H.264 publish rule to c.os == "android". The Xiaomi 2201117TI clause is unchanged.
  • pkg/rtc/mediaengine.go: selectAlternativeVideoCodec skips RTX, ULPFEC and FlexFEC, so it returns a real video codec or the VP8 default.

ClientInfo.ComplyWithCodecOrderInSDPAnswer() in pkg/rtc/clientinfo.go has the same (linux || android) && firefox shape from #2183. I left it alone: it only trims the codecs offered in desktop Firefox's SDP answer, which didn't cause a problem here. Happy to narrow it too if you'd prefer the two rules to match.

Testing

  • New TestStaticConfigurationFirefoxH264Publish checks client info as the server parses it: H.264 publish stays disabled for Firefox Mobile/Android and Firefox/Android, and is allowed for Firefox/Linux and Chrome/Linux.
  • New TestSelectAlternativeVideoCodec covers RTX first, RTX after H.264, FEC entries, and no video codec at all.
  • Both new tests fail on master (desktop Linux Firefox / expected "video/VP8", actual "video/rtx") and pass with this change. go test ./pkg/clientconfiguration/ ./pkg/rtc/ passes.
  • End-to-end: v1.13.6 plus this change (with MimeTypeFlexFEC03 dropped, because the protocol version pinned by v1.13.6 doesn't have it), self-hosted on arm64, with enabled_codecs: [audio/opus, audio/red, video/h264]. Desktop Firefox 156 on Linux published video/H264 with all three simulcast layers, alongside an Element X Android client publishing video/H264. Both sides saw each other's video. There were no falling back to alternative video codec / could not find codec for webrtc receiver lines, and the server forwarded about 2.7 Mbit/s of video. A second run added Element X on iOS 18.7 (JS SDK 2.21.0 in WKWebView): it fell back from VP8 to video/H264 and published all three simulcast layers alongside desktop Linux Firefox, again with no could not find codec lines. On stock v1.13.6 with the same config, the Firefox track was registered as video/rtx and showed as a blank tile.

Not tested: Firefox for Android. Its rule is deliberately unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DLqi1aZH5ZCxHdAMP9BP3c

…ll back to RTX

The static client configuration disabled H.264 publishing for Firefox on
"linux" or "android". It was added for Firefox for Android (livekit#2183, livekit#2190),
but the user agent parser reports Firefox for Android as os "android", so
the "linux" clause only ever matched desktop Linux Firefox, which can
publish H.264 via OpenH264. Narrow the rule to Android.

With video/h264 as the only enabled video codec, that rule left desktop
Linux Firefox with enabledPublishCodecs = [video/rtx, audio/opus,
audio/red]. Its VP8 request then fell back via selectAlternativeVideoCodec,
which returns the first video/ entry, so the track was registered as
video/rtx while H.264 packets arrived ("could not find codec for webrtc
receiver") and no subscriber could decode it. Skip RTX and FEC formats
when picking an alternative codec.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@krithin
krithin requested a review from a team as a code owner October 5, 2026 00:43
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Krithin Sitaram seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@krithin
krithin marked this pull request as draft October 5, 2026 00:44
@boks1971

boks1971 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

This was partially addressed in #4930.

Not enabling H.264 for Linux. That needs more evaluation as some distributions may not have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop Linux Firefox can't publish video when enabled_codecs only lists H.264 (track registered as video/rtx)

3 participants