mirror of
https://github.com/livekit/livekit.git
synced 2026-05-11 06:07:12 +00:00
Clean up data track observers on unsubscribe. (#4421)
Media track clean up fixed some leaks. There are more when the participants thrash. This is not the issue, but doing this to match media tracks.
This commit is contained in:
@@ -119,11 +119,16 @@ func (m *SubscriptionManager) Close(isExpectedToResume bool) {
|
||||
// this participant and its transports to be garbage collected.
|
||||
m.lock.Lock()
|
||||
subs := maps.Clone(m.subscriptions)
|
||||
dataTrackSubs := maps.Clone(m.dataTrackSubscriptions)
|
||||
m.lock.Unlock()
|
||||
for _, sub := range subs {
|
||||
sub.setChangedNotifier(nil)
|
||||
sub.setRemovedNotifier(nil)
|
||||
}
|
||||
for _, dataTrackSub := range dataTrackSubs {
|
||||
dataTrackSub.setChangedNotifier(nil)
|
||||
dataTrackSub.setRemovedNotifier(nil)
|
||||
}
|
||||
|
||||
subTracks := m.GetSubscribedTracks()
|
||||
downTracksToClose := make([]*sfu.DownTrack, 0, len(subTracks))
|
||||
@@ -1098,6 +1103,9 @@ func (m *SubscriptionManager) unsubscribeDataTrack(s *dataTrackSubscription) err
|
||||
dataTrack := dataDownTrack.PublishDataTrack()
|
||||
dataTrack.RemoveSubscriber(s.subscriberID)
|
||||
|
||||
s.setChangedNotifier(nil)
|
||||
s.setRemovedNotifier(nil)
|
||||
|
||||
m.unmarkSubscribedTo(s.getPublisherID(), s.trackID)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user