skip out of order participant state updates (#3583)

* skip out of order participant state updates

* avoid nil last active pointer

* cleanup

* protect state change callbacks

* gen

* test
This commit is contained in:
Paul Wells
2025-04-06 06:44:50 -07:00
committed by GitHub
parent 15a8d9a266
commit ee08aede5b
5 changed files with 38 additions and 25 deletions
+5 -2
View File
@@ -444,13 +444,16 @@ func (r *Room) Join(participant types.LocalParticipant, requestSource routing.Me
r.joinedAt.Store(time.Now().Unix())
}
participant.OnStateChange(func(p types.LocalParticipant, state livekit.ParticipantInfo_State) {
var onStateChangeMu sync.Mutex
participant.OnStateChange(func(p types.LocalParticipant) {
if r.onParticipantChanged != nil {
r.onParticipantChanged(p)
}
r.broadcastParticipantState(p, broadcastOptions{skipSource: true})
if state == livekit.ParticipantInfo_ACTIVE {
onStateChangeMu.Lock()
defer onStateChangeMu.Unlock()
if state := p.State(); state == livekit.ParticipantInfo_ACTIVE {
// subscribe participant to existing published tracks
r.subscribeToExistingTracks(p)