Skip to content
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

sync functional, but not near-realtime #65

Closed
heckj opened this issue Apr 28, 2024 · 6 comments · Fixed by #71
Closed

sync functional, but not near-realtime #65

heckj opened this issue Apr 28, 2024 · 6 comments · Fixed by #71
Assignees
Labels
bug Something isn't working

Comments

@heckj
Copy link
Collaborator

heckj commented Apr 28, 2024

After having updated MeetingNotes (automerge/MeetingNotes#42), the sync is clearly functioning, but its no longer happening in realtime.

When I activate websocket channel from two devices to an upstream automerge-repo server, they both appear to sync, but the content isn't replicated realtime.

When I active local peer2peer, the changes replicate faster, but on live updating of text views in MeetingNotes, there are no changes flowing back into the UI - so typing on one doesn't appear on the other.

My tests to date have been iOS <-> Mac:

  • just websocket on each
  • just peer-to-peer on each
  • both websocket and peer-to-peer on each

The consistency of behavior makes me think there's at least some issue in the interface from automerge-repo-swift and what's happening in the docs to replicate changes, and I suspect it's on the "incoming change from remote peer" path.

@heckj heckj added the bug Something isn't working label Apr 28, 2024
@heckj heckj self-assigned this Apr 28, 2024
@heckj
Copy link
Collaborator Author

heckj commented Apr 28, 2024

watching the console/logging while I type on macOS <-websocket-> automerge-repo, as I'm typing in one of the notes fields, there's no immediate replication of content - no sync messages are being generated. I'm a bit unclear if that's in MeetingNotes, AutomergeText, or the repository, but somewhere the "hey, there's a change" signal is getting dropped, delayed significantly (longer than a few seconds), or lost

@heckj
Copy link
Collaborator Author

heckj commented Apr 28, 2024

WebSocket investigation log (Mac <--websocket--> automerge-repo)

From typing a single character in an agenda-item text field:

These first two updates were from the Automerge doc's objectWillChange sink, happening almost exactly 1 second apart.
There's a debounce in this stream of 1 second, but getting two update noticifations for a single keypress is a tad unexpected.

3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX ** objectWillChange (1 sec delay) **
Loading model updates
3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX ** objectWillChange (1 sec delay) **
Loading model updates

It goes on to trigger a sync upstream

RESOLVE document id 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX [ready]
RESOLVED! :: 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX [ready]
Providing stored sync state for doc 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX
REPONET: sending message on AutomergeRepo.WebSocketProvider to Optional("storage-server-sync-automerge-org")
REPONET: sending message on AutomergeRepo.PeerToPeerProvider to Optional("storage-server-sync-automerge-org")
Sending SYNC[documentId: 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX, sender: 16C39119-27E3-4BB9-8905-DDE4DD3CB8FD, target: storage-server-sync-automerge-org, data: 247 bytes] to peer storage-server-sync-automerge-org
Unable to find a connection to peer storage-server-sync-automerge-org
WebSocket received: SYNC[documentId: 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX, sender: storage-server-sync-automerge-org, target: 16C39119-27E3-4BB9-8905-DDE4DD3CB8FD, data: 71 bytes]
REPONET: received event from network adapter: NetworkAdapterEvents.message[SYNC[documentId: 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX, sender: storage-server-sync-automerge-org, target: 16C39119-27E3-4BB9-8905-DDE4DD3CB8FD, data: 71 bytes]]
PEER: 16C39119-27E3-4BB9-8905-DDE4DD3CB8FD - handling a sync msg from storage-server-sync-automerge-org to 16C39119-27E3-4BB9-8905-DDE4DD3CB8FD
 - Sync request received for document 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX
 - working on handle for 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX, state: ready
Providing stored sync state for doc 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX

And then we see another objectWillChange from the document, which I thought was also unexpected, but looks like it may have been triggered internally to the repo. I suspect I've got some extra change notifications in the repo doc-resolve process that may be pushed extra notifications:

3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX ** objectWillChange (1 sec delay) **
Loading model updates
Updated contents of document 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX, state: ready
Storing updated sync state for doc 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX and peer storage-server-sync-automerge-org.
RESOLVE document id 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX [ready]
RESOLVED! :: 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX [ready]
Providing stored sync state for doc 3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX
3BwAK2fZ3Nrgn9HRBb9yvNx9xXKX ** objectWillChange (1 sec delay) **
Loading model updates

@heckj
Copy link
Collaborator Author

heckj commented Apr 29, 2024

Thread on discord highlighted a possible avenue to track discrete sets of patches after applying changes - the diff API. That's not (yet) wired through to the Swift library, so I've opened an issue (automerge/automerge-swift#148) on that repo to wire that up for potential use - including in solving this issue, or related issues in Automerge-swift that aren't efficiently propagating change notifications.

@heckj
Copy link
Collaborator Author

heckj commented Apr 29, 2024

I found at least one place there's a flaw - logged as automerge/automerge-swift#149, AutomergeText doesn't have any direct means to report its changed when an underlying doc changed. In the previous setup in MeetingNotes, I was signaling updates from the coordinator (now repo), and all those places really need to be refined to reflect changes on the Automerge document, or derive a change from that notification.

@heckj
Copy link
Collaborator Author

heckj commented Apr 29, 2024

I have a first cut of this resolved with automerge/automerge-swift#150, but I'll need to cut a full release of automerge-swift to verify that resolves the problems I'm seeing with MeetingNotes, and to establish tests that validate the changes signals propogate as expected.

The implementation was the worst version possible, just to verify that was the issue, and there's pending work to "make that better" with automerge/automerge-swift#151 and automerge/automerge-swift#152

@heckj
Copy link
Collaborator Author

heckj commented Apr 30, 2024

I suspect I have this properly sorted, with updates in Automerge-swift, but to properly test it here along with automerge-repo-swift, I really need to cut a new automerge-swift release. I'll verify the solution, or continue digging, when that's done and I can iterate and test with the fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant