Tweaks to reduce supervisor error logs (#1039)
Seeing some supervisor error logs under two conditions - Issuing a full reconnect - client should close this session and form a new one. So, supervisor errors on the to be closed session is not useful. - Some times it takes a long time for publisher PC to establish. If publish monitor timer stars when a pending track is added, the time out fires before ICE/DTLS is established. So, include a condition to start timer on publication monitor only after peer connection is connected.
This commit is contained in:
@@ -1317,6 +1317,7 @@ func (p *ParticipantImpl) onICECandidate(c *webrtc.ICECandidate, target livekit.
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) onPublisherInitialConnected() {
|
||||
p.supervisor.SetPublisherPeerConnectionConnected(true)
|
||||
go p.publisherRTCPWorker()
|
||||
}
|
||||
|
||||
@@ -2061,6 +2062,9 @@ func (p *ParticipantImpl) onAnyTransportNegotiationFailed() {
|
||||
},
|
||||
})
|
||||
p.CloseSignalConnection()
|
||||
|
||||
// on a full reconnect, no need to supervise this participant anymore
|
||||
p.supervisor.Stop()
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) EnqueueSubscribeTrack(trackID livekit.TrackID, f func(sub types.LocalParticipant) error) {
|
||||
|
||||
@@ -21,9 +21,10 @@ type ParticipantSupervisorParams struct {
|
||||
type ParticipantSupervisor struct {
|
||||
params ParticipantSupervisorParams
|
||||
|
||||
lock sync.RWMutex
|
||||
publications map[livekit.TrackID]types.OperationMonitor
|
||||
subscriptions map[livekit.TrackID]types.OperationMonitor
|
||||
lock sync.RWMutex
|
||||
isPublisherConnected bool
|
||||
publications map[livekit.TrackID]types.OperationMonitor
|
||||
subscriptions map[livekit.TrackID]types.OperationMonitor
|
||||
|
||||
isStopped atomic.Bool
|
||||
}
|
||||
@@ -44,11 +45,27 @@ func (p *ParticipantSupervisor) Stop() {
|
||||
p.isStopped.Store(true)
|
||||
}
|
||||
|
||||
func (p *ParticipantSupervisor) SetPublisherPeerConnectionConnected(isConnected bool) {
|
||||
p.lock.Lock()
|
||||
p.isPublisherConnected = isConnected
|
||||
|
||||
for _, pm := range p.publications {
|
||||
pm.PostEvent(types.OperationMonitorEventPublisherPeerConnectionConnected, p.isPublisherConnected)
|
||||
}
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
func (p *ParticipantSupervisor) AddPublication(trackID livekit.TrackID) {
|
||||
p.lock.Lock()
|
||||
pm, ok := p.publications[trackID]
|
||||
if !ok {
|
||||
pm = NewPublicationMonitor(PublicationMonitorParams{TrackID: trackID, Logger: p.params.Logger})
|
||||
pm = NewPublicationMonitor(
|
||||
PublicationMonitorParams{
|
||||
TrackID: trackID,
|
||||
IsPeerConnectionConnected: p.isPublisherConnected,
|
||||
Logger: p.params.Logger,
|
||||
},
|
||||
)
|
||||
p.publications[trackID] = pm
|
||||
}
|
||||
pm.PostEvent(types.OperationMonitorEventAddPendingPublication, nil)
|
||||
|
||||
@@ -24,8 +24,9 @@ type publish struct {
|
||||
}
|
||||
|
||||
type PublicationMonitorParams struct {
|
||||
TrackID livekit.TrackID
|
||||
Logger logger.Logger
|
||||
TrackID livekit.TrackID
|
||||
IsPeerConnectionConnected bool
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
type PublicationMonitor struct {
|
||||
@@ -34,6 +35,8 @@ type PublicationMonitor struct {
|
||||
lock sync.RWMutex
|
||||
desiredPublishes deque.Deque
|
||||
|
||||
isConnected bool
|
||||
|
||||
publishedTrack types.LocalMediaTrack
|
||||
isMuted bool
|
||||
unmutedAt time.Time
|
||||
@@ -43,7 +46,8 @@ type PublicationMonitor struct {
|
||||
|
||||
func NewPublicationMonitor(params PublicationMonitorParams) *PublicationMonitor {
|
||||
p := &PublicationMonitor{
|
||||
params: params,
|
||||
params: params,
|
||||
isConnected: params.IsPeerConnectionConnected,
|
||||
}
|
||||
p.desiredPublishes.SetMinCapacity(2)
|
||||
return p
|
||||
@@ -51,6 +55,8 @@ func NewPublicationMonitor(params PublicationMonitorParams) *PublicationMonitor
|
||||
|
||||
func (p *PublicationMonitor) PostEvent(ome types.OperationMonitorEvent, omd types.OperationMonitorData) {
|
||||
switch ome {
|
||||
case types.OperationMonitorEventPublisherPeerConnectionConnected:
|
||||
p.setConnected(omd.(bool))
|
||||
case types.OperationMonitorEventAddPendingPublication:
|
||||
p.addPending()
|
||||
case types.OperationMonitorEventSetPublicationMute:
|
||||
@@ -80,12 +86,23 @@ func (p *PublicationMonitor) addPending() {
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
func (p *PublicationMonitor) maybeStartMonitor() {
|
||||
if p.isConnected && !p.isMuted {
|
||||
p.unmutedAt = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PublicationMonitor) setConnected(isConnected bool) {
|
||||
p.lock.Lock()
|
||||
p.isConnected = isConnected
|
||||
p.maybeStartMonitor()
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
func (p *PublicationMonitor) setMute(isMuted bool) {
|
||||
p.lock.Lock()
|
||||
p.isMuted = isMuted
|
||||
if !p.isMuted {
|
||||
p.unmutedAt = time.Now()
|
||||
}
|
||||
p.maybeStartMonitor()
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
|
||||
@@ -431,6 +431,7 @@ const (
|
||||
OperationMonitorEventUpdateSubscription OperationMonitorEvent = iota
|
||||
OperationMonitorEventSetSubscribedTrack
|
||||
OperationMonitorEventClearSubscribedTrack
|
||||
OperationMonitorEventPublisherPeerConnectionConnected
|
||||
OperationMonitorEventAddPendingPublication
|
||||
OperationMonitorEventSetPublicationMute
|
||||
OperationMonitorEventSetPublishedTrack
|
||||
@@ -445,6 +446,8 @@ func (o OperationMonitorEvent) String() string {
|
||||
return "SET_SUBSCRIBED_TRACK"
|
||||
case OperationMonitorEventClearSubscribedTrack:
|
||||
return "CLEAR_SUBSCRIBED_TRACK"
|
||||
case OperationMonitorEventPublisherPeerConnectionConnected:
|
||||
return "PUBLISHER_PEER_CONNECTION_CONNECTED"
|
||||
case OperationMonitorEventAddPendingPublication:
|
||||
return "ADD_PENDING_PUBLICATION"
|
||||
case OperationMonitorEventSetPublicationMute:
|
||||
|
||||
Reference in New Issue
Block a user