fix(webrtc): Fix Firefox simulcast race condition and respect HPB bandwidth limits#17776
Open
fix(webrtc): Fix Firefox simulcast race condition and respect HPB bandwidth limits#17776
Conversation
β¦dwidth limits - Chain sender.setParameters() before createOffer() in Firefox to avoid a race where the offer SDP is generated before simulcast encodings are applied. Previously the promise was ignored, causing simulcast to fail silently on low-bandwidth links and fall back to a single high-bitrate stream that congested the connection. - Add _getMaxBitrates() helper that derives simulcast tiers from the signaling server's maxstreambitrate instead of hardcoded values. The server already sent this limit in the room join response but the client never used it, so publishers always tried to push 1.3 Mbps even when the uplink or server policy was much lower. - Parse data.room.bandwidth.maxstreambitrate in joinResponseReceived and expose it on the signaling connection so Peer objects can read it. - Guard s.track before accessing s.track.kind in getSenders() find, matching the existing upstream fix for disabled tracks in Firefox. Fixes #17774 Signed-off-by: Tarek Loubani <tarek@tarek.org>
Member
|
Past 2 of your fixes I already did in #17670 π |
Author
That's so great. I tried to look and see if this was anywhere, but couldn't quite find it. Does that mean this PR should close? Or was there something in this PR you thought could be useful? |
Member
|
Well you seem to address more, but since you vibed it and I have not enough knowledge about the sdp patching, I leave this to the experts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using Firefox with the High Performance Backend (HPB / MCU) and simulcast enabled, the publisher side initializes simulcast encodings via
sender.setParameters(). However, the returnedPromiseis not awaited beforecreateOffer()is called. This creates a race condition where the offer SDP may be generated before the simulcast parameters are actually applied to the sender.This fixes issue #17774 - more details in that issue. OpenCode with Kimi 2.6 and Qwen 3.6 35B3A were used to debug and repair.