From 800d6bfa0f842af9c2eefb83cd7ca28cbf6e27f2 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Sun, 15 Nov 2026 09:51:16 +0100 Subject: [PATCH] rtc: re-use the offered transceiver in one shot signalling on Safari (#5212) A one shot client, i. e. WHIP, cannot negotiate again. The transceivers of its offer are the only place for a subscribed track. #4474 turned off transceiver re-use for Safari, and the check ran before the one shot branch. The server then added a new transceiver for the subscribed track, which the answer cannot carry. A WHIP client in desktop Safari got a `recvonly` answer and never received the track. The one shot branch now runs first. Co-authored-by: Claude Fable 5.2 --- pkg/rtc/participant.go | 11 +++++++---- pkg/rtc/participant_internal_test.go | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index b472e7ab9..96be8d46e 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -4244,14 +4244,17 @@ func (p *ParticipantImpl) SupportsSyncStreamID() bool { } func (p *ParticipantImpl) SupportsTransceiverReuse(mt types.MediaTrack) bool { - if !p.params.ClientInfo.SupportsTransceiverReuse() { - return false - } - + // ONE-SHOT-SIGNALLING-MODE: the client cannot negotiate again, so the transceivers of its offer + // are the only place for a subscribed track. This holds for every client, also for one that + // does not re-use transceivers in regular signalling. if p.params.UseOneShotSignallingMode { return p.ProtocolVersion().SupportsTransceiverReuse() } + if !p.params.ClientInfo.SupportsTransceiverReuse() { + return false + } + return p.ProtocolVersion().SupportsTransceiverReuse() && !p.SupportsSyncStreamID() && (!mt.IsEncrypted() || !p.params.DisableTransceiverReuseForE2EE) } diff --git a/pkg/rtc/participant_internal_test.go b/pkg/rtc/participant_internal_test.go index 07bc59773..7fcb2b4c8 100644 --- a/pkg/rtc/participant_internal_test.go +++ b/pkg/rtc/participant_internal_test.go @@ -116,6 +116,24 @@ func TestPublishCodecFallbackSkipsRTX(t *testing.T) { }) } +func TestSupportsTransceiverReuse(t *testing.T) { + // Browser / Os values are what the server's user agent parser sets for desktop Safari + safari := &livekit.ClientInfo{Browser: "Safari", Os: "Mac OS X"} + track := &typesfakes.FakeMediaTrack{} + + // a one shot client, i. e. WHIP, cannot negotiate again, so the transceivers of its offer are + // the only place for a subscribed track, also on a client that does not re-use otherwise + t.Run("one shot signalling re-uses on Safari", func(t *testing.T) { + p := newParticipantForTestWithOpts("test", &participantOpts{clientInfo: safari, oneShot: true}) + require.True(t, p.SupportsTransceiverReuse(track)) + }) + + t.Run("regular signalling does not re-use on Safari", func(t *testing.T) { + p := newParticipantForTestWithOpts("test", &participantOpts{clientInfo: safari}) + require.False(t, p.SupportsTransceiverReuse(track)) + }) +} + func TestSupportsMoving(t *testing.T) { t.Run("current protocol version", func(t *testing.T) { p := newParticipantForTestWithOpts("test", &participantOpts{protocolVersion: types.CurrentProtocol})