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

Insertions latency and fractional position conflicts #26

Open
anphetamina opened this issue Mar 24, 2020 · 1 comment
Open

Insertions latency and fractional position conflicts #26

anphetamina opened this issue Mar 24, 2020 · 1 comment

Comments

@anphetamina
Copy link

I was wondering what case this line of code should cover. Is that related to fractional position conflicts between multiple editors?
How Conclave behaves when an insert message comes after locally inserting a symbol with the same fractional position of the character coming from the message. I mean, shouldn't all the editors follow the same fractional position ordering? If the algorithm just searches for the position before and after the character, will the state between editors be broken?

@sunny-b
Copy link
Contributor

sunny-b commented May 24, 2020

You're correct that when two different symbols with the same fractional position are inserted at (or near) the same time, all the editors should follow the same logical ordering. And that's what that line is attempting to do (at least from my best recollection, it's been a while since I've touched Conclave code).

All users who're collaborating on a document are given an ID, which is the siteId you see in that line of code. The reason we're checking the siteId in that line of code is because of this line. That line is saying that both symbols have the same fractional position. If both symbols have the same fractional index, then we insert whichever symbol came from the user with the smaller siteId since someone has to be positioned first and we just decided to use the user with the smaller id.

I'm not sure what you mean about mean, shouldn't all the editors follow the same fractional position ordering?. This code is running on all of the browsers of the users who're collaborating, so they're all using the same fractional position ordering logic.

I'm also not super clear on your question If the algorithm just searches for the position before and after the character, will the state between editors be broken?. The algorithm that you pointed to (generatePosBetween), is run only once for a symbol. Whenever a user inserts a symbol or character into the document, that symbol needs to be given a fractional index. And that index is determined by the indexes of the characters surrounding it.

However, once it's given a fractional index, that index stays fixed and isn't recalculated. So when that symbol is emitted to the other users so that their documents can sync-up, they take the index that was calculated and insert it into the document based on it's position here

I hope that helps clarify your question. The code definitely is pretty messy. We wrote Conclave rather quickly and didn't spend too much time cleaning up or making things look nicer.

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

No branches or pull requests

2 participants