fix(client): allow forcing the dual peer connection path on WebRTC - #963
fix(client): allow forcing the dual peer connection path on WebRTC#963chinmayv095 wants to merge 1 commit into
Conversation
livekit-client defaults singlePeerConnection to true, so the v1 join protocol bundles the publisher offer in the JoinRequest and moves the microphone request earlier in the connection sequence. iOS and iPadOS Safari reject it there. Add a webRtc.singlePeerConnection session option so callers can opt back into the dual peer connection path, following the shape elevenlabs#934 landed for webRtc.iceTransportPolicy. Left undefined when unset, so livekit-client's own default continues to apply. Fixes elevenlabs#960
PR SummaryLow Risk Overview The option is documented on Reviewed by Cursor Bugbot for commit 7307f67. Bugbot is set up for automated code reviews on this repo. Configure here. |
Fixes #960
What happens
WebRTCConnection.create()constructs the LiveKitRoomwith no options, sosinglePeerConnectiontakes livekit-client's own default, which istrueas of 2.21.0:The v1 join protocol bundles the publisher offer in the JoinRequest, which moves the point in the connection sequence where the microphone is requested.
create()enables the microphone offRoomEvent.SignalConnected, so the timing of that request follows the protocol version:@sailod reports that on iOS and iPadOS Safari the request is rejected at that earlier point with
NotAllowedError, and that pinningsinglePeerConnection: falsethroughpatch-packagerestores it.Why this is not a straight revert
singlePeerConnection: falsedid exist. It was added in ae50508 (#782) as defense in depth for LiveKit servers that did not process a bundled publisher offer, and removed in c037e48 (#780). The removal was deliberate, not incidental: that commit message calls it out by name as an intended edit that a rebase had dropped and that was being restored.So this PR does not restore
falseas the client default. Whether the server side is now uniformly ready for v1 is a call I cannot make from outside the deployment, and re-pinning every caller to v0 would undo #780 for everyone in order to fix one platform.What it does instead
Adds
webRtc.singlePeerConnection, following the shape #934 landed three days ago. That PR started as a generalrtcConfigpassthrough and was narrowed before merge to a single named option underwebRtc, so this reuses the same namespace and the same one-option-at-a-time convention rather than reopening the passthrough question.Left
undefinedwhen unset, so livekit-client's default continues to apply and nothing changes for existing callers. The reporter can droppatch-packageand passwebRtc: { singlePeerConnection: false }instead.Considered and not taken
Defaulting to
falseon iOS and iPadOS specifically. That means user agent sniffing in a package that deliberately keeps DOM assumptions out of common code, and it would encode a guess about which platforms are affected. If you would rather ship a platform default, or flip the client default back tofalseoutright, both are small follow-ups on top of this and I am happy to send either.Verification
Four tests in
WebRTCConnection.test.ts, placed beside the existingiceTransportPolicytest rather than at the end of the file, since my open #953 appends there.forces the dual peer connection path when set to falsefalsereaches theRoomconstructorpasses the option through when set to truetruedoes too, so the option is not hard-coded one wayleaves the LiveKit default alone when the option is omitteddoes not pin the peer connection mode when only iceTransportPolicy is setwebRtcoptions stay independentFail-first, stashing only
WebRTCConnection.ts: 2 failed, 17 passed. The two failures are the two that assert the new behaviour. The other two pass both ways by design, which is the point of them: they are the back-compat controls, and a fix that pinned a default would break them.They assert that no
singlePeerConnectionwas pinned rather than asserting the exactRoomcall arity, becausenew Room()andnew Room(undefined)are the same thing to LiveKit and pinning the arity would fail on any harmless refactor.packages/clientsuite: 238 on main, 242 on the branch, delta exactly the four added, zero failures either side.pnpm -w run check-types: 16 successful, 16 total.prettier --checkclean on all four touched files.minor, matching Add webRtc.iceTransportPolicy session option for WebRTC connections #934's bump for the sibling option.