diff --git a/document/peer-transport/src/replica.rs b/document/peer-transport/src/replica.rs index 69b84cccf6..398eedb80a 100644 --- a/document/peer-transport/src/replica.rs +++ b/document/peer-transport/src/replica.rs @@ -383,6 +383,7 @@ impl Replica { epoch: self.epoch, seq: self.seq, }; + log::info!("Join handshake: hello sent to {transport_peer:?} as {:?}", self.role); self.transport.send(transport_peer, &hello)?; Ok(()) } @@ -390,6 +391,7 @@ impl Replica { fn handle_packet(&mut self, from: TransportPeerId, packet: SyncPacket, target: &mut dyn SyncTarget, events: &mut Vec) -> Result<(), ReplicaError> { match packet { SyncPacket::Hello { peer, user, role, epoch, seq } => { + log::info!("Join handshake: hello from {peer:?} ({role:?}), synced {}", self.is_synced()); self.peers.insert(from, RemotePeer { peer, user, role }); self.anchor_delivered(peer, epoch, seq); @@ -402,6 +404,7 @@ impl Replica { self.resources_stale = true; if role == Role::Host && !self.is_synced() { + log::info!("Join handshake: sync request sent to the host"); self.transport.send(from, &SyncPacket::SyncRequest { known_revs: target.known_revs() })?; } } @@ -426,6 +429,7 @@ impl Replica { return Ok(()); } let shares_history = known_revs.iter().any(|&rev| target.contains_rev(rev)); + log::info!("Join handshake: sync request from {from:?}, shares history {shares_history}"); let sync = SyncPayload { registry: (!shares_history).then(|| target.retired_registry()), deltas: target.deltas_unknown_to(&known_revs), @@ -437,9 +441,11 @@ impl Replica { retracted: target.retracted_marks(), document_id: target.document_id(), }; + log::info!("Join handshake: sync answered with {} deltas and {} hot ops", sync.deltas.len(), sync.hot_log.len()); self.transport.send(from, &SyncPacket::Sync(Box::new(sync)))?; } SyncPacket::Sync(sync) => { + log::info!("Join handshake: sync received with {} deltas, full registry {}", sync.deltas.len(), sync.registry.is_some()); let SyncState::AwaitingSync { pending } = std::mem::replace(&mut self.sync, SyncState::Synced) else { return Ok(()); }; diff --git a/editor/src/messages/portfolio/sync/sync_message_handler.rs b/editor/src/messages/portfolio/sync/sync_message_handler.rs index 342f085e95..85b52530f1 100644 --- a/editor/src/messages/portfolio/sync/sync_message_handler.rs +++ b/editor/src/messages/portfolio/sync/sync_message_handler.rs @@ -151,6 +151,7 @@ impl MessageHandler> for SyncMessageHandler for event in events { match event { Event::Synced => { + log::info!("Join handshake: synced, applying the host's state"); self.dirty.insert(document_id); self.fit_after_sync.insert(document_id); } @@ -196,6 +197,7 @@ impl MessageHandler> for SyncMessageHandler if document.apply_remote_changes(responses) { self.dirty.remove(&document_id); if self.fit_after_sync.remove(&document_id) && Some(document_id) == active_document_id { + log::info!("Join handshake: the host's state is applied, fitting the viewport after the graph runs"); // The bounds come from the render, so the fit waits for the graph to run on the new document. responses.add(DeferMessage::AfterGraphRun { messages: vec![DocumentMessage::ZoomCanvasToFitAll.into()],