Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webrtc glare #39

Merged
merged 1 commit into from
Jun 16, 2023
Merged

Fix webrtc glare #39

merged 1 commit into from
Jun 16, 2023

Conversation

dextertanyj
Copy link
Contributor

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

  • Generate a tiebreaker value glareToken for each webrtc connection object when a signal event occurs.
  • Include the tiebreaker value for signal messages.
  • When a client receives an offer message with a lower tiebreaker value, it is ignored.
  • Tiebreaker values are cleared on both sides of the webrtc connection when a successful connection is established.

@dmonad
Copy link
Member

dmonad commented Jun 16, 2023

Thank you, I didn't know about this!

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

@dmonad dmonad merged commit 0cb5412 into yjs:master Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants