From 4f6fda586cd1c582309dfa6c22127fea88fc0648 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 14 Feb 2023 23:12:08 -0800 Subject: [PATCH] Do not unsubscribe from track if it's been republished (#1424) thank you @boks1971 for the debugging --- pkg/rtc/subscriptionmanager.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/rtc/subscriptionmanager.go b/pkg/rtc/subscriptionmanager.go index e864c4af8..f3dd627fa 100644 --- a/pkg/rtc/subscriptionmanager.go +++ b/pkg/rtc/subscriptionmanager.go @@ -399,6 +399,12 @@ func (m *SubscriptionManager) subscribe(s *trackSubscription) error { } if res.TrackRemovedNotifier != nil && s.setRemovedNotifier(res.TrackRemovedNotifier) { res.TrackRemovedNotifier.AddObserver(string(m.params.Participant.ID()), func() { + // re-resolve the track in case the same track had been re-published + res := m.params.TrackResolver(m.params.Participant.Identity(), s.trackID) + if res.Track != nil { + // do not unsubscribe, track is still available + return + } // source track removed, we would unsubscribe s.logger.Debugw("unsubscribing track since source track was removed") s.setDesired(false)