@@ -79,7 +79,6 @@ func newWithClientOrServer(servers []webrtc.ICEServer, client bool, opts *ConnOp
79
79
// This channel needs to be bufferred otherwise slow consumers
80
80
// of this will cause a connection failure.
81
81
localCandidateChannel : make (chan webrtc.ICECandidateInit , 16 ),
82
- pendingRemoteCandidates : make ([]webrtc.ICECandidateInit , 0 ),
83
82
localSessionDescriptionChannel : make (chan webrtc.SessionDescription , 1 ),
84
83
remoteSessionDescriptionChannel : make (chan webrtc.SessionDescription , 1 ),
85
84
}
@@ -129,10 +128,6 @@ type Conn struct {
129
128
localSessionDescriptionChannel chan webrtc.SessionDescription
130
129
remoteSessionDescriptionChannel chan webrtc.SessionDescription
131
130
132
- pendingRemoteCandidates []webrtc.ICECandidateInit
133
- pendingCandidatesMutex sync.Mutex
134
- pendingCandidatesFlushed bool
135
-
136
131
pingChannelID uint16
137
132
pingEchoChannelID uint16
138
133
@@ -357,28 +352,6 @@ func (c *Conn) negotiate() {
357
352
case c .localSessionDescriptionChannel <- answer :
358
353
}
359
354
}
360
-
361
- // The ICE transport resets when the remote description is updated.
362
- // Adding ICE candidates before this point causes a failed connection,
363
- // because the candidate would be lost.
364
- c .pendingCandidatesMutex .Lock ()
365
- defer c .pendingCandidatesMutex .Unlock ()
366
- for _ , pendingCandidate := range c .pendingRemoteCandidates {
367
- c .opts .Logger .Debug (context .Background (), "flushing buffered remote candidate" ,
368
- slog .F ("hash" , c .hashCandidate (pendingCandidate )),
369
- slog .F ("length" , len (pendingCandidate .Candidate )),
370
- )
371
- err := c .rtc .AddICECandidate (pendingCandidate )
372
- if err != nil {
373
- _ = c .CloseWithError (xerrors .Errorf ("flush pending remote candidate: %w" , err ))
374
- return
375
- }
376
- }
377
- c .opts .Logger .Debug (context .Background (), "flushed buffered remote candidates" ,
378
- slog .F ("count" , len (c .pendingRemoteCandidates )),
379
- )
380
- c .pendingCandidatesFlushed = true
381
- c .pendingRemoteCandidates = make ([]webrtc.ICECandidateInit , 0 )
382
355
}
383
356
384
357
// LocalCandidate returns a channel that emits when a local candidate
@@ -389,18 +362,10 @@ func (c *Conn) LocalCandidate() <-chan webrtc.ICECandidateInit {
389
362
390
363
// AddRemoteCandidate adds a remote candidate to the RTC connection.
391
364
func (c * Conn ) AddRemoteCandidate (i webrtc.ICECandidateInit ) error {
392
- c .pendingCandidatesMutex .Lock ()
393
- defer c .pendingCandidatesMutex .Unlock ()
394
- fields := []slog.Field {
365
+ c .opts .Logger .Debug (context .Background (), "adding remote candidate" ,
395
366
slog .F ("hash" , c .hashCandidate (i )),
396
367
slog .F ("length" , len (i .Candidate )),
397
- }
398
- if ! c .pendingCandidatesFlushed {
399
- c .opts .Logger .Debug (context .Background (), "bufferring remote candidate" , fields ... )
400
- c .pendingRemoteCandidates = append (c .pendingRemoteCandidates , i )
401
- return nil
402
- }
403
- c .opts .Logger .Debug (context .Background (), "adding remote candidate" , fields ... )
368
+ )
404
369
return c .rtc .AddICECandidate (i )
405
370
}
406
371
0 commit comments