Skip to content

Minimal yjs based collaboration#2971

Merged
max-nextcloud merged 60 commits into
mainfrom
experiment/minimal-yjs
Jan 31, 2023
Merged

Minimal yjs based collaboration#2971
max-nextcloud merged 60 commits into
mainfrom
experiment/minimal-yjs

Conversation

@max-nextcloud

@max-nextcloud max-nextcloud commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

Comment thread src/components/Editor.vue Outdated
@juliusknorr juliusknorr added this to the Nextcloud 26 milestone Sep 22, 2022
@juliusknorr juliusknorr added enhancement New feature or request 2. developing labels Oct 11, 2022
@max-nextcloud max-nextcloud force-pushed the experiment/minimal-yjs branch from 9cd3d29 to 0b8e260 Compare October 17, 2022 13:12
@max-nextcloud max-nextcloud force-pushed the experiment/minimal-yjs branch from 0b8e260 to 3057169 Compare December 7, 2022 06:58
@cypress

cypress Bot commented Dec 7, 2022

Copy link
Copy Markdown

Passing run #8385 ↗︎

0 132 0 0 Flakiness 0

Details:

Minimal yjs based collaboration
Project: Text Commit: b49ade4770
Status: Passed Duration: 06:41 💡
Started: Jan 31, 2023 9:43 AM Ended: Jan 31, 2023 9:50 AM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

// This way the user can still resolve conflicts in the editor view
if ($document->getLastSavedVersion() !== $document->getCurrentVersion()) {
$stepsVersion = $this->stepMapper->getLatestVersion($document->getId());
if ($stepsVersion && ($document->getLastSavedVersion() !== $stepsVersion)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we drop the step version that check against the last saved version will no longer work, so maybe we need to find a different approach to determine the collision case.

@max-nextcloud max-nextcloud force-pushed the experiment/minimal-yjs branch 2 times, most recently from 5ab0d4c to 9cae5ea Compare December 12, 2022 11:51
Comment thread lib/Service/DocumentService.php Outdated

@juliusknorr juliusknorr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First half of the review for backend bits

Comment thread lib/Db/StepMapper.php Outdated
Comment thread lib/Service/ApiService.php Outdated
Comment thread lib/Service/ApiService.php
Comment thread lib/Service/DocumentService.php Outdated
$oldVersion = $document->getCurrentVersion();
$newVersion = $oldVersion + count($steps);
$stepsVersion = $this->stepMapper->getLatestVersion($document->getId());
$newVersion = $stepsVersion + count($steps);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get rid of the lock we may want to wrap this in a transaction so that reading the current version, increasing and writing steps is an atomic operation.

Should be easy with https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/database.html#transactions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a follow up issue in #3726

@max-nextcloud max-nextcloud force-pushed the experiment/minimal-yjs branch 4 times, most recently from e9f4dd1 to 1e7224f Compare January 25, 2023 17:11
@max-nextcloud

Copy link
Copy Markdown
Collaborator Author

Locally only sync, attachments and the flaky Links tests are failing (with npx cypress run).

@juliusknorr juliusknorr force-pushed the experiment/minimal-yjs branch from 1e7224f to 4326eb3 Compare January 26, 2023 23:10
@juliusknorr

Copy link
Copy Markdown
Member

Pushed a bit of polishing for the backend code to make CI happy and a fix for direct editing to pass the initial session data to the web socket polyfill. Let's see what CI says.

@juliusknorr

This comment was marked as resolved.

@juliusknorr

This comment was marked as resolved.

@juliusknorr juliusknorr force-pushed the experiment/minimal-yjs branch 2 times, most recently from 98bffa2 to 0ae0ea0 Compare January 27, 2023 16:10
@juliusknorr

Copy link
Copy Markdown
Member

@max-nextcloud So far for my week I pushed couple of fixes and polishing. I ended up also refactoring the PollingBackend a bit to clean this up. Cypress tests pass now though there are two draft commits that we should discuss on Monday about on how to best handle that.

  • f232328 It seemed that there was still an issue where longer running sessions ended up playing ping pong with messages which lead to heavy load. I figured out that we may not need to send back steps during the push operations as this was originally more a shortcut to avoid another polling round. I feel this is more stable and also makes more sense to just have one channel where steps get sent from the server to the clients. This was they can also continue to fetch them in order of the database
  • 00879a6 As we no longer store the version of the document the left TODO statement // TODO: figure out when to autosave caused that the files were not saved. In order to have a working branch I pushed this draft commit to always send the documentState and autosaveContent with each sync request, but we should probably be smarter about that.

@max-nextcloud

Copy link
Copy Markdown
Collaborator Author

@juliushaertl Wow... thanks for looking into this and pushing the pr forward like that!
❤️

@max-nextcloud

Copy link
Copy Markdown
Collaborator Author

@juliushaertl Given your last commit i wonder what happens if...

  • two users edit the doc
  • it's update on the server through a different mechanis -> conflict
  • one user resolves the conflict

Ideally the conflict would get resolved for the other user as well, right? In particular so they do not pick different strategies.
Is that the case already, or what happens?
Did we account for that in the past?

@juliusknorr

Copy link
Copy Markdown
Member

Ideally the conflict would get resolved for the other user as well, right? In particular so they do not pick different strategies.
Is that the case already, or what happens?
Did we account for that in the past?

We didn't have any handling for different strategies in the past. My additional commit would already solve this by just moving any resulution to happen trough y.js, so individual users can also undo. One thing that might need further work is to timely propagate the resolved conflict, but I'd not consider that a blocker for the merge as it has been worse before ;)

juliusknorr and others added 15 commits January 31, 2023 09:28
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
…flict through force save

Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Max <max@nextcloud.com>
Replaying old awareness state will trigger cursor moves
which in turn trigger new awareness messages.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
Sometimes loading the doc will trigger one sync, sometimes two.
Make sure we always inspect the actual save request
by waiting for two syncs before we trigger and inspect it.

Signed-off-by: Max <max@nextcloud.com>
@max-nextcloud max-nextcloud force-pushed the experiment/minimal-yjs branch from 3f4f352 to 23c9e2b Compare January 31, 2023 08:28
Signed-off-by: Max <max@nextcloud.com>
@max-nextcloud max-nextcloud merged commit a337849 into main Jan 31, 2023
@delete-merged-branch delete-merged-branch Bot deleted the experiment/minimal-yjs branch January 31, 2023 11:22
@szaimen

szaimen commented Jan 31, 2023

Copy link
Copy Markdown
Contributor

🎉🎉🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Y.js backend drop in replacement

6 participants