Do not call telemetry listener under pending track lock. (#4706)

* Do not call telemetry listener under pending track lock.

Fix the TrackPublishRequested call of telemetry listener.

Audited other callbacks to ensure that it is not under lock.

* missed some paths of recording it, thanks Devin
This commit is contained in:
Raja Subramanian
2026-07-27 23:52:21 +05:30
committed by GitHub
parent 0aa296e126
commit 25e3774cbb
+8 -5
View File
@@ -2876,8 +2876,6 @@ func (p *ParticipantImpl) onSubscribedAudioCodecChange(
func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit.TrackInfo {
p.pendingTracksLock.Lock()
defer p.pendingTracksLock.Unlock()
if req.Sid != "" {
track := p.GetPublishedTrack(livekit.TrackID(req.Sid))
if track == nil {
@@ -2888,11 +2886,14 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
AddTrack: utils.CloneProto(req),
},
})
p.pendingTracksLock.Unlock()
return nil
}
track.(*MediaTrack).UpdateCodecInfo(req.SimulcastCodecs)
return track.ToProto()
ti := track.ToProto()
p.pendingTracksLock.Unlock()
return ti
}
backupCodecPolicy := req.BackupCodecPolicy
@@ -3060,8 +3061,6 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
}
}
p.params.TelemetryListener.OnTrackPublishRequested(p.ID(), p.Identity(), utils.CloneProto(ti))
if p.supervisor != nil {
p.supervisor.AddPublication(livekit.TrackID(ti.Sid))
p.supervisor.SetPublicationMute(livekit.TrackID(ti.Sid), ti.Muted)
@@ -3093,6 +3092,8 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
AddTrack: utils.CloneProto(req),
},
})
p.pendingTracksLock.Unlock()
p.params.TelemetryListener.OnTrackPublishRequested(p.ID(), p.Identity(), utils.CloneProto(ti))
return nil
}
@@ -3110,6 +3111,8 @@ func (p *ParticipantImpl) addPendingTrack(req *livekit.AddTrackRequest) *livekit
"request", logger.Proto(req),
"pendingTrack", p.pendingTracks[req.Cid],
)
p.pendingTracksLock.Unlock()
p.params.TelemetryListener.OnTrackPublishRequested(p.ID(), p.Identity(), utils.CloneProto(ti))
return ti
}