Repository navigation
fix(sfu): upgrade mediasoup to 3.31 and port the sdp bridge - #1192
Open
mcottontensor wants to merge 1 commit into
Open
mcottontensor wants to merge 1 commit into
mcottontensor wants to merge 1 commit into
Conversation
mediasoup 3.15.5 has no kernel 7 prebuilt, so installs compiled the worker from source. 3.31.0 ships one; 3.32's new BWE freezes Firefox viewers, so it is held below 3.32. Ports the bridge to mediasoup-client 3.26 and fixes the SFU's SCTP id allocation and signal handling for the new API.
🦋 Changeset detectedLatest commit: 5ecbe59 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Upgrades mediasoup from 3.15.5 to 3.31.0 for the SFU and the SDP bridge, ports the bridge to mediasoup-client 3.26, and fixes two SFU breakages caused by the new mediasoup API. Closes #1147.
Relevant components:
Problem statement:
mediasoup 3.15.5 has no prebuilt worker for Linux kernel 7. On a kernel 7 host, installing the SFU compiles the worker from C++ source, which needs Python, meson and a C++ toolchain and takes minutes (#1147). #1186 stopped
start.shfrom installing the SFU, but SFU users and the SFU image still hit it. mediasoup has shipped kernel 7 prebuilts since 3.20.7.The upgrade can't be a version bump alone. mediasoup-client has to move with it, the bridge uses APIs that were renamed or removed, and the SFU calls a private mediasoup method that no longer exists.
Solution
Versions
~3.31.0in the SFU,3.31.0as a dev dependency and^3.31.0as a peer of the bridge.>=3.25.0 <3.27.0).a=msidis parsed.Why 3.31.0 and not 3.32.x. mediasoup 3.32.0 replaced its bandwidth estimation with a new built-in stack. With it, a Firefox viewer's estimated available bitrate decays to the 30 kbps floor within about 20 seconds, even on a lossless localhost/LAN link. The simulcast consumer then has no layer it can afford, and the video freezes. On the same SFU at the same moment, Chrome viewers stay at about 11–14 Mbps. On 3.31.0, and on master's 3.15.5, Firefox is fine. I couldn't find an existing mediasoup report of this, and it will be reported upstream.
~3.31.0keeps a lockfile refresh from pulling 3.32 back in.SDP bridge port (fixes all 19 type errors listed in #1147 without casts)
mediasoup/types.validateRtpCapabilities→validateAndNormalizeRtpCapabilities.getExtendedRtpCapabilities(…, false)keeps the remote codec order used before. I diffed 3.10.1 against 3.26.0: the matching logic is otherwise the same.planBoption is dropped.sdp-transformtypes instead ofobject/any. That exposed a new requiredcodecsargument togetRtpEncodings, which now gets the producer codecs the same way mediasoup-client's own handlers pass them. The effect is that RTX is only added when an RTX codec is negotiated.{}media fallback now throws an explicit error.toffset, which mediasoup no longer supports, is removed from the browser capabilities.SFU
transport.getNextSctpStreamId()no longer exists, so a streamer opening data channels would throw. The SFU now reserves ids through mediasoup's (still private)allocateSctpStreamId()in one helper. Unlike the old method, it marks the id as used, so DataConsumers can't be given the same id. Replaying the SFU's call order on real transports gives the same ids as before, in both multiplexed and per-peer mode. The trade-off: mediasoup never frees ids it gave to producers, so per-peer mode uses two ids on the streamer transport for each player join, out of 65,535, until the streamer reconnects.died. Registering those listeners stops Node from exiting on the signal, so the SFU would keep running, still connected to signalling, with no worker (docker stopwould then wait and SIGKILL it). The SFU now exits on those signals itself.Documentation
Changesets for
@epicgames-ps/pixelstreaming-sfuand@epicgames-ps/mediasoup-sdp-bridge(bothminor). The SFU changeset notes that kernel 5 hosts (Debian 11, Amazon Linux 2, Ubuntu 22.04 on its original kernel) no longer get a prebuilt, and that the kernel 7 prebuilt needs glibc 2.38 or newer. The currentnode:ltsimage (Debian 13, glibc 2.41) is fine.Test Plan and Compatibility
npm citakes about 7 s, builds the bridge inprepare, and downloads the worker prebuilt rather than compiling it.toffsetextension, no audioabs-send-time,ice2advertised, and the AV1 dependency descriptor offered for simulcast.minimal-streamer-5.7release: Wilbur, the SFU, and several Chrome and Firefox viewers on the LAN.-SimulcastParameters(that build uses the original Pixel Streaming plugin). The SFU created asimulcastproducer, and viewers played through it.-PixelStreamingEncoderCodec=H264with GPU rendering gave unreliable video, both direct and through the SFU.Not tested
Backport: UE5.8 only. The SFU and bridge package names carry no UE suffix, but
package-lock.jsonwill need regenerating on that branch rather than cherry-picking.