algesten / str0m

A Sans I/O WebRTC implementation in Rust.
MIT License
335 stars 50 forks source link

Dedupe remote ICE candidates #576

Closed k0nserv closed 1 month ago

k0nserv commented 1 month ago

The changes in 5c4c9d5 caused problems because we'd end up creating new identical pairs. For example, if an existing pair, 0-0, exists as local: 192.168.1.33:5445, remote: 192.168.1.33:63461. Then, after processing a new offer another remote candidate would be added for 192.168.1.33:63461, call this pair 0-1. When determining which pair an incoming binding request belonged too we'd then identify 0-1 instead of 0-0(because max_by_key) returns the last value on ties. In Chrome this would work correctly, but in Firefox connectivity would be lost.

Ultimately adding a new remote candidate that is exactly the same as one that's already part of a viable pair is redundant, so we resolve this issue by simply skipping such candidates.