yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
355 stars 124 forks source link

Prevent infinite cursor awareness update loop #145

Open furkan3ayraktar opened 1 year ago

furkan3ayraktar commented 1 year ago

If two editors are open for the same Y.Doc, the cursor awareness state enters into an infinite update loop. This commit fixes the issue by using the solution suggested in this issue.

We've been using this solution for the last one and half years in production without any issues. I remembered it when receiving a recent notification from the issue and wanted to share the solution as a PR.

szymonkozak commented 11 months ago

I have tested this solution and though it fixes the main problem I have noticed that after switching a tab (focusout event), the cursor of the user (which switches the tab) is blinking for a moment. When we don't register focusout listener then this problem is solved but I don't know if it introduces other issues or not.

garth commented 10 months ago

I used pnpm patch to apply this PR and it fixed infinite loops when using awareness with tiptap with y-websocket-server, but the infinite loop still happens with hocuspocus.