-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
- Current state (ours):
- Send: src/hooks/useSync.ts:186-211, 320-344 emits full SCENE_INIT every 500 ms from every
client on any onChange (leading+trailing throttle), no diffing, no isDedicatedSyncer gate. - Receive: src/hooks/useCollaboration.ts:567-589 applies full element arrays; dedup is a JSON
string compare scoped to the render, no versioning. - Echo: remote updateScene triggers onChange and re-sends the same scene.
- Server: websocket_server/SocketManager.js:334 rebroadcasts blindly.
- Send: src/hooks/useSync.ts:186-211, 320-344 emits full SCENE_INIT every 500 ms from every
- Problem: High baseline traffic and CPU just by being in a room; identical scenes bounce;
SCENE_INIT is misused for ongoing updates; no message version/id; elements always sent, only
files are hashed. - Main solution (follow Excalidraw collab pattern):
- Upstream reference:
- Incremental send only when scene version increases: broadcastElements in https://github.com/excalidraw/excalidraw/blob/master/excalidraw-app/collab/Collab.tsx#L900-L954
- Throttled full-scene fallback: queueBroadcastAllElements just below in same file.
- Receive merge after version filtering: handleRemoteSceneUpdate in https://github.com/excalidraw/excalidraw/blob/master/excalidraw-app/collab/Collab.tsx#L782-L820
- Adopt that model:
- Track scene version (or reuse computeElementVersionHash) and broadcast only when it
increases; add a throttled full-scene fallback. - Split message types: keep SCENE_INIT for first sync, add SCENE_UPDATE for incremental;
include message version/id so receivers drop stale or duplicate updates. - Gate scene broadcasts to isDedicatedSyncer; others send cursors/viewport only.
- Add a receive-side last-version ref to skip reapply without stringifying payloads.
- Prevent echo: mark remote-applied scenes so onChange does not rebroadcast them.
- Files/images: add a lightweight dataURL hash map to skip unchanged file sends; keep on
reliable channel.
- Track scene version (or reuse computeElementVersionHash) and broadcast only when it
- Upstream reference:
- Impact: Much lower bandwidth and CPU per participant, fewer focus/interaction glitches for embeddables, clearer message semantics for future work.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Type
Projects
Status
🏗️ In progress