Skip to content

Selection/cursor-change and edits racing condition #1

@pedrosanta

Description

@pedrosanta

A known issue of this approach/example is a racing condition which makes cursors stuck/out-of-correct-position sometimes when a selection-change cursor update (which goes through cursors socket) is quickly followed by some edits (which goes through ShareDB and its socket) - like using the back arrow key with Ctrl to go to the beginning of a word and immediately start typing.

How to replicate:

  1. Open two side-by-side windows on https://quill-sharedb-cursors.herokuapp.com;
  2. On one of them try to move to the beginning of a word with the keyboard shortcut (Ctrl/Option+Left Arrow) and inserting some text immediately after;
  3. If you do these things quick enough, the cursor on the other client might become off-position.

My take is that:

  • Sometimes, the insert operation gets processed first (and vice-versa) on server (which moves cursor forward) and then the message with absolute position (from the arrow caret move) comes in and places the cursor behind from it is on the other client;
  • Sometimes the cursor doesn't even move from the place of start, meaning that it only gets updated/shifted on the insert operations, like the server hasn't ever received the caret change update/message in the first place;

One solution for this was if... cursor updates could be transmitted through ShareDB (probably as ephemeral metadata like stated on share/sharedb#128).

Still needs more testing.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions