-
Notifications
You must be signed in to change notification settings - Fork 29
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
CoEditor Unable to Reconcile Simultaneous Changes #185
Comments
Try to brainstorm some ideas here... Solutions
Current ApproachI have been working for the past two days on a DOM tree based approach to representing and syncing the editor data. I've come up with a representation (likely to change somewhat) of the DOM tree that we can use to sync. The difficult part is doing a Tree DiffingI could not find any useful existing libraries that could diff trees (in JavaScript), so I found some papers describing techniques for doing so. I have implemented an algorithm described by Chawathe et. al. [1], and have been testing it for correctness and designing a series of regression tests. The algorithm essentially takes two trees and finds an Currently, one part of the algorithm is unacceptably slow, but [1] and [2] offer solutions. Another caveat is that [1] makes some assumptions about the tree structure and data in order to guarantee to find a minimal Update June 17th 2012I've created a branch (treeBasedEditor https://github.com/opencoweb/cowebx/tree/treeBasedEditor) with the code changes. In the current state, the coeditor has been converted to use the tree based approach, but there are some bugs that prevent syncing to work properly. In other words, I just haven't finish fully implementing everything, but the majority of the work is done, and with some tweaking the editor should be fully functional. [1] http://ilpubs.stanford.edu:8090/115/1/1995-46.pdf |
I believe we can improve the raw HTML based editor to a state that eliminates the effects of the inherent issue discussed above.
Since all clients will converge to the invalid HTML (guaranteed by the OT algorithm), eventually each will request a fresh copy from the moderator, who will always have a valid HTML string. |
The coedit app uses a moderator to track the rich text editor widget changes. Now, I need to
|
Always forget to include issue number in commit messages. 49881468001c65e81a4e42b24d468a72104c896d |
The CoEditor appears to work properly when clients atomically make changes, but when two clients make simultaneous changes, the operational transform algorithm destroys the HTML structure embedded in the raw character text. See the example below.
Initially:
<br>
<br>
<br>
into<b>a</b><br>
and sends the following syncs to the server:insert 2 >
insert 3 a
insert 4 <
insert 5 /
insert 6 b
insert 7 >
insert 8 <
insert 9 b
<br>
intos
and sends the following syncs to the server:delete 0
delete 0
delete 0
update 0 s
At this point:
<b>a</b><br>
s
After the operational transform:
insert 0 >
insert 1 a
insert 2 <
insert 3 /
insert 4 b
insert 5 >
insert 6 <
insert 7 b
delete 0
delete 0
delete 8
update s 8
The final HTML of both clients does in fact remain the same - however, it is malformed:
>a</b><bs
The core issue is the operational transform is agnostic to information encoded in HTML tags (i.e. the OT only provides syntactical consistency, not semantic consistency). This is not an OT bug, but rather a design flaw in how the editor data is synced.
#167 is related in behavior, although the underlying problems are different and perhaps more severe for this issue.
The text was updated successfully, but these errors were encountered: