From 507fc9cf76926dfc93bf63f7dc4b5587ac1db179 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Mon, 17 Mar 2025 10:31:32 +0530 Subject: [PATCH] Do not instantiate 0 sized sequencer. (#3529) This happens due to improper track type. One possible option is to check the mime type of the track and calculate the size, but there are other places in the code which work off provided track type. So, just doing a defensive fix. Have to review code for all uses of type and how it affects things if client provides incorrect type. --- pkg/rtc/mediatracksubscriptions.go | 2 ++ pkg/sfu/sequencer.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pkg/rtc/mediatracksubscriptions.go b/pkg/rtc/mediatracksubscriptions.go index 88a9df90f..b20bf6f0f 100644 --- a/pkg/rtc/mediatracksubscriptions.go +++ b/pkg/rtc/mediatracksubscriptions.go @@ -113,6 +113,8 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr * case livekit.TrackType_VIDEO: rtcpFeedback = t.params.SubscriberConfig.RTCPFeedback.Video maxTrack = t.params.ReceiverConfig.PacketBufferSizeVideo + default: + t.params.Logger.Warnw("unexpected track type", nil, "kind", t.params.MediaTrack.Kind()) } codecs := wr.Codecs() for _, c := range codecs { diff --git a/pkg/sfu/sequencer.go b/pkg/sfu/sequencer.go index 5ba788b9c..1e08ef9ce 100644 --- a/pkg/sfu/sequencer.go +++ b/pkg/sfu/sequencer.go @@ -119,6 +119,10 @@ type sequencer struct { } func newSequencer(size int, maybeSparse bool, logger logger.Logger) *sequencer { + if size == 0 { + return nil + } + s := &sequencer{ size: size, startTime: time.Now().UnixNano(),