-
Notifications
You must be signed in to change notification settings - Fork 92
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
Send one full update from y-websocket #6650
base: main
Are you sure you want to change the base?
Conversation
2cfb371
to
4675077
Compare
1702eee
to
9b78b88
Compare
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Keep an internal ydoc tracking updates that came from the server. Send updates, that would sync this doc with the current doc state. Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
The pushed steps are echoed back with all other steps since version immediately. Processing them reduces the size of the following pushes and syncs. Signed-off-by: Max <[email protected]>
It has always been publicly called from the PollingBackend. Signed-off-by: Max <[email protected]>
Updates now include all the local structs that were not yet received from remote. No need to compute a separate update message anymore. Signed-off-by: Max <[email protected]>
9b78b88
to
1495034
Compare
Apply document state as a step. Process it like other steps received from the remote. In particular include it in the tracking of steps already applied and set the version accordingly. Signed-off-by: Max <[email protected]>
This was a very inefficient attempt to resync that we did not even process on the client side. Only the steps since the last save may not be enough to get back in sync. However we can expand this by including the document state or storing it as the first step after a save. Signed-off-by: Max <[email protected]>
Signed-off-by: Max <[email protected]>
Do not process document state from create response. During create the editor has not been initialized fully and the cursor position is 0 - which is invalid as it is not inside a node with inline content. (It is inside the doc before the initial paragraph.) This also allows processing document state later on in order to recover from out of sync situations. But we do not make use of that yet. Signed-off-by: Max <[email protected]>
1495034
to
f08a168
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave this a first try and basic syncing is still working fine, also some offline online switching on two browser sessions worked as expected.
One small difference I noticed (without reading the code yet in detail):
- When loading the file it seems we no longer wait until the content is loaded to hide the loading indicator, we start with an empty document and can type before any document state is propagated to us. @max-nextcloud is this expected or can it cause any side effects?
@@ -0,0 +1,539 @@ | |||
/** | |||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | |||
* SPDX-License-Identifier: AGPL-3.0-or-later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file license is probably still MIT then, but not entirely sure, probably something to clarify
I didin't diff how much it is based on it (https://github.com/yjs/y-websocket/blob/master/LICENSE)
lib/Service/DocumentService.php
Outdated
$getStepsSinceVersion = count($querySteps) > 0 ? 0 : $version; | ||
// If there were any queries in the steps send all steps since last save. | ||
$getStepsSinceVersion = count($querySteps) > 0 | ||
? $document->getLastSavedVersion() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be min($document->getLastSavedVersion(), $version)
to make sure we don't skip any steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in the next commit by including the document state that matches $document->getLastSavedVersion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still using the smaller would mean we have a redundancy in case the client that did the save was out of sync.
What's missing:
|
Always send full diff to server state.
received from the server.
Todo: