yjs / y-webrtc

WebRTC Connector for Yjs
MIT License
448 stars 109 forks source link

Fix webrtc glare #39

Closed dextertanyj closed 1 year ago

dextertanyj commented 1 year ago

Context

When two client simultaneously announce themselves to the signalling server, they will both create a Peer with { initiator: true } before sending the offer message to each other. As such, both parties will attempt to answer each other's offer and the second answer will result in an ERR_SET_REMOTE_DESCRIPTION. Thereafter, the connection closes and the when the reconnection takes place, both clients have { initiator: false }, causing a standstill as they wait for each other.

Screenshot 2022-10-28 at 12 51 59 AM Screenshot 2022-10-27 at 2 32 08 PM

This issue is similar to glare, and simple-peer is unlikely to handle this issue in the foreseeable future based on previous discussion.

Approach

dmonad commented 1 year ago

Thank you, I didn't know about this!

This looks good, I'm gonna put this in the next release.