Skip to main content
System Design Blueprint (November 2026) 26 minPublished November 17, 2026

Designing a Real-Time Collaborative Canvas (Figma & Miro Architecture)

Building a multiplayer infinite collaborative canvas like Figma or Miro is one of the most demanding challenges in software engineering. It requires sub-16ms vector rendering at 60 FPS, concurrent state synchronization without server locks, spatial indexing across millions of vector nodes, and seamless offline-to-online reconciliation.

CRDT Tree Hierarchies vs. Operational Transformation (OT)

Architecting a real-time collaborative canvas—such as Figma, Miro, or Canva—presents distributed systems engineering challenges fundamentally distinct from collaborative text editors like Google Docs. While collaborative text operates as a linear 1D sequence of characters, an infinite visual canvas operates as a mutable 2D directed acyclic graph (DAG) of vector objects: nested frames, layout groups, vector paths, shape properties, and transform matrices.

Early collaborative architectures relied on Operational Transformation (OT). However, OT requires a centralized server to serialize operations, resolve concurrent edit collisions, and maintain a global transformation matrix. In high-concurrency canvas editing—where a single designer dragging a shape emits 60 transform events per second—centralized OT servers quickly become massive network bottlenecks, incurring high CPU serialization overhead and failing catastrophically during intermittent network disconnections.

Modern collaborative canvases utilize Conflict-free Replicated Data Types (CRDTs), specifically tree-based State-based and Operation-based CRDTs (such as fractional indexing algorithms and LWW-Element-Set trees). Every shape, vector vertex, and style property is assigned a unique, immutable Lamport timestamp and a cryptographically random client identifier:

ElementID = LamportTimestamp:ClientID:SequenceCounter

When concurrent users modify identical canvas objects simultaneously—such as Designer A resizing a frame while Designer B recolors its background fill—the CRDT mathematical merge function guarantees that all client replicas converge deterministically to the identical document state without requiring centralized server arbitration.

WebAssembly & WebGPU: Achieving Sustained 60 FPS Vector Rendering

The standard browser Document Object Model (DOM) is fundamentally incapable of rendering complex collaborative canvases containing 50,000+ vector elements. Instantiating tens of thousands of HTML <div> or SVG elements overwhelms browser layout engines, triggering continuous reflow calculations and collapsing framerates to single digits.

To deliver buttery-smooth 60 FPS panning, zooming, and vector manipulation, modern canvas applications bypass the DOM entirely. The entire document model, geometry engine, and rendering pipeline are compiled from C++ or Rust into WebAssembly (WASM), rendering directly to a full-window HTML5 <canvas> element via WebGL2 or WebGPU.

The WebAssembly rendering loop optimizes hardware utilization through three core techniques:

  • Linear Memory Allocation: The canvas scene graph resides in a contiguous WebAssembly linear memory buffer, completely avoiding JavaScript garbage collection pauses.
  • Spatial R-Tree Indexing: The geometry engine maintains a 2D R-Tree spatial index. When rendering a viewport frame, the engine queries the R-Tree to cull elements positioned outside the visible screen coordinates in sub-millisecond time.
  • GPU Batch Draw Calls: Vector paths, text glyphs, and rectangular quads are packed into instanced GPU vertex buffers, allowing the WebGPU pipeline to render thousands of complex canvas layers in a single draw call.

Ephemeral Presence Protocol & Spatial Cursor Multiplexing

Collaborative canvas UX relies heavily on social presence: observing co-workers' live cursor positions, active selection boxes, and chat bubbles moving across the infinite canvas. However, broadcasting raw 60 Hz mouse coordinate streams for hundreds of active users across a single WebSocket connection would flood network bandwidth and choke client CPU threads.

To optimize network transmission, presence telemetry is decoupled from durable document CRDT state. While canvas edits are persisted via durable message queues, presence telemetry is broadcast through ephemeral, low-overhead WebSocket streams or WebRTC data channels using binary encoding (such as Protocol Buffers or MessagePack).

The presence ingestion gateway implements adaptive spatial throttling:

  • Viewport Culling: A client only receives high-frequency cursor updates (30 Hz) for peers whose viewports intersect their current visible canvas region.
  • Distance-Based Decimation: Peering cursors located far outside the user's active viewport are downsampled to 2 Hz or omitted entirely.
  • Dead Reckoning & Spline Interpolation: The client UI renders smooth cursor trajectories between intermittent 30 Hz position updates using cubic Hermite spline interpolation, giving users the visual perception of flawless 60 FPS cursor motion with 80 percent lower network overhead.

Offline Reconnection & Tree Reparenting Cycle Prevention

A legendary failure mode in collaborative hierarchical tree editing is the Reparenting Cycle Anomaly. Consider two collaborating designers working offline on a flight: Designer A moves Folder 1 inside Folder 2, while Designer B concurrently moves Folder 2 inside Folder 1. In a naive hierarchical database, merging these two offline operations creates an orphaned cyclical reference (Folder 1 contains Folder 2, which contains Folder 1), corrupting the document tree and crashing the rendering engine.

Modern collaborative canvas architectures eliminate reparenting cycles through the Replicated Tree CRDT algorithm. When a client reconciles a move operation during offline synchronization:

isValidMove(targetNode, newParent) = !isDescendantOf(newParent, targetNode)

The CRDT algorithm traverses the ancestor path of the proposed parent node. If a cycle condition is detected, the operation with the lower Lamport timestamp is deterministically aborted or demoted to a top-level unparented group, ensuring that the document graph remains a strictly valid directed acyclic tree under all network failure and offline reconnection scenarios.

Spatial Indexing: 2D Quadtrees & Bounding Box Culling

In large enterprise design projects—such as complete multi-screen UI design systems containing 100,000+ vector objects, frames, and typography layers—maintaining a linear array of canvas elements results in catastrophic $O(N)$ rendering loops. If the rendering engine must iterate through 100,000 elements on every animation frame just to determine which objects are visible inside the user's current 1920x1080 viewport, the CPU budget of 16.6 milliseconds (required for 60 FPS) is completely exhausted before a single GPU draw call is issued.

Modern collaborative canvases solve this through spatial partitioning data structures, specifically 2D Quadtrees and R-Trees maintained within WebAssembly linear memory. The canvas plane is recursively divided into four quadrants whenever an area contains more than an empirical threshold of elements (typically 32 objects).

When the user pans or zooms across the canvas, the geometry engine queries the Quadtree using the camera's axis-aligned bounding box (AABB):

VisibleElements = Quadtree.queryRange(cameraViewport.getAABB())

The query executes in $O(log N)$ logarithmic time, returning only the 150 to 300 vector elements that actually intersect the current viewport in less than 0.4 milliseconds. Elements positioned off-screen are culled instantly, keeping the GPU render pipeline lightweight and sustaining rock-solid 60 FPS framerates even on massive, complex enterprise design files.

Binary Wire Protocols: FlatBuffers vs. Protocol Buffers vs. JSON

Serializing real-time canvas modifications over network connections introduces significant CPU overhead if text-based formats like JSON are used. A single designer dragging a complex vector path emits dozens of coordinate updates per second; parsing JSON strings requires allocating new JavaScript strings and objects, triggering continuous garbage collection pauses that cause visible UI micro-stutters.

Production collaborative canvases replace JSON with zero-copy binary serialization protocols, specifically Google FlatBuffers or Cap'n Proto. Unlike Protocol Buffers (which requires an intermediate parsing and memory allocation step to decode messages), FlatBuffers structures serialized data such that the in-memory binary format is identical to the wire format.

When a WebAssembly client receives a FlatBuffers binary packet over a WebSocket connection, it can read vector coordinates and transform matrices directly from the raw byte array buffer without parsing or allocating new memory objects. This zero-copy deserialization enables the canvas engine to process thousands of incoming peer updates per second with zero garbage collection overhead and sub-millisecond dispatch latency.

Principal Architect Verification Checklist & Canvas Invariants

Engineering an infinite, real-time collaborative canvas capable of supporting 50,000+ vector elements at 60 FPS requires adherence to four core architectural invariants:

  • CRDT Deterministic Convergence: Ensure all canvas transformations (resizing, recoloring, reparenting) utilize tree-based CRDTs with Lamport timestamps and client IDs, guaranteeing mathematical document convergence without centralized lock managers.
  • Zero-DOM WebAssembly Rendering: Bypass the browser Document Object Model entirely by rendering vector paths, text glyphs, and layout frames via WebAssembly and WebGPU directly to full-window canvas contexts.
  • Spatial R-Tree Viewport Culling: Index all canvas elements within 2D R-Tree or Quadtree structures, ensuring that off-screen objects are culled in sub-millisecond time before GPU draw calls are executed.
  • Decoupled Ephemeral Presence Streams: Transmit high-frequency cursor coordinates (30 Hz) over ephemeral WebSocket or WebRTC channels using zero-copy binary serialization (FlatBuffers), insulating durable document state from transient presence telemetry.

By adhering to these architectural standards, design engineering teams can build collaborative graphic applications that deliver desktop-class performance, instant offline synchronization, and seamless multi-user collaboration.

Production Post-Mortem: Eliminating CRDT Tombstone Memory Bloat

In collaborative document editing, deleting elements presents subtle memory management challenges. When a designer deletes 10,000 vector shapes on a collaborative canvas, naive CRDT implementations retain "tombstones" (metadata markers indicating deletion) indefinitely to resolve potential concurrent operations from offline collaborators. Over months of intensive design iteration, document CRDT state can swell from 15MB to over 400MB of pure deletion tombstones, choking client RAM and inducing multi-second document load times.

To solve tombstone memory bloat in production, modern canvas engines implement Garbage Collection Epochs based on Stable Vector Clocks. The collaborative sync server periodically computes the minimum Lamport timestamp across all active client replicas and offline session leases.

Any deletion tombstone whose timestamp is strictly older than the minimum active vector clock is guaranteed to never be resurrected by an in-flight concurrent edit. The server runs an asynchronous compaction pass, physically purging the expired tombstones from the document binary graph. This compaction algorithm shrinks active canvas file sizes by up to 88 percent while preserving mathematical convergence invariants.

SV
Shiva Vinodkumar
Principal Architect & Editorial Lead, HelloAIHub
Share:
Key Architecture Takeaways
  • CRDT vs. Operational Transformation: Why modern collaborative engines migrated from centralized OT servers to peer-to-peer Conflict-Free Replicated Data Types (Yjs, Automerge) for offline resilience.
  • WebAssembly Vector Engine: Bypassing the HTML DOM tree by compiling C++/Rust 2D graphics engines directly to WebAssembly and WebGL/WebGPU shaders.
  • Spatial Indexing (R-Trees & BVH): Organizing millions of canvas elements into hierarchical bounding boxes so the rendering loop evaluates only elements inside the active user viewport.
  • Multi-Tiered WebSocket Gateways: Separating high-frequency ephemeral broadcasts (mouse cursor coordinates at 60Hz) from durable document mutations.

1. Why the HTML DOM Fails for Infinite Canvases

Attempting to build an infinite canvas using standard HTML <div> elements or SVG nodes fails beyond ~1,000 shapes. The browser layout engine (reflow and repaint) collapses, memory usage skyrockets, and scrolling drops from 60 FPS down to a stuttering 8 FPS.

Figma solved this by compiling a custom C++ vector rendering pipeline directly to WebAssembly (WASM). The canvas uses a single HTML <canvas> element. The WASM binary communicates directly with the GPU via WebGL/WebGPU, packing vector vertices into GPU buffers and rendering hundreds of thousands of path primitives in single-digit milliseconds.

2. State Synchronization: Conflict-Free Replicated Data Types (CRDTs)

Older systems (like Google Docs) relied on Operational Transformation (OT), requiring a single centralized server to order all keystrokes. In a graphics canvas with offline laptop edits, OT breaks down under complex topological graph merges.

Modern collaborative architectures use state-based or delta-state CRDTs. Every shape and vector point receives a globally unique, Lamport timestamped identifier. Concurrent transformations (such as User A resizing a rectangle while User B shifts its color) merge deterministically on every client without requiring roundtrips to an authority lock server:

CRDT Conflict Resolution Rule (LWW-Element-Set):
Shape {
  id: "uuid_shape_9841",
  type: "RECTANGLE",
  props: {
    width:  { val: 400, timestamp: 1731846001, peer: "client_A" }, // Winner (higher TS)
    fill:   { val: "#00F2FE", timestamp: 1731846000, peer: "client_B" }
  }
}
Result: Both modifications apply cleanly with mathematical convergence!

3. Spatial Indexing: Bounding Volume Hierarchies (BVH)

Even on GPU hardware, issuing draw calls for 500,000 shapes when the user is zoomed into a 200x200 pixel icon wastefully saturates the command buffer.

The canvas maintains an in-memory 2D R-Tree (or Bounding Volume Hierarchy). When the user pans or zooms, the viewport rectangle is queried against the spatial tree in O(log N) time. Only the ~50 elements physically intersecting the screen frustum are dispatched to the GPU shaders.

4. Ephemeral Cursor Broadcasts & WebRTC DataChannels

Broadcasting live mouse cursor positions for 50 active collaborators in a single document generates 3,000 coordinate packets per second. Sending these updates through standard HTTP or database-persisted WebSocket pipelines introduces unacceptable server CPU overhead.

The canvas architecture routes ephemeral data through WebRTC DataChannels or non-persisted UDP-backed gateway clusters. Coordinates are compressed into 8-byte binary packets (X/Y uint16 plus user ID). Clients apply deadband threshold filtering: if a mouse moves less than 2 screen pixels, the update is dropped, cutting network egress by 65% while maintaining fluid visual tracking.

5. Distributed Selective Undo/Redo Engine

Implementing undo/redo in a multiplayer vector editor is significantly more complex than in single-user software. If User A presses Cmd + Z, the system must undo User A's last action without rolling back simultaneous edits made by User B and User C.

The collaborative engine maintains an internal Inversion Operation Log keyed by user session ID. When an undo request arrives, the client computes the inverse mutation of the target operation and commits it as a brand-new forward CRDT operation. This ensures that history remains strictly append-only while preserving document integrity across all participating peers.

6. Document Compaction, Delta Snapshots & Cold Boot Optimization

As a design file accumulates months of collaborative edits, replaying millions of granular CRDT operations from scratch causes painful 30-second document load times.

A background snapshot compaction service periodically materializes the active document graph into a single compressed binary state vector. When a user opens a canvas, the client downloads the latest compacted snapshot in under 400ms and replays only the recent delta log frames committed since the snapshot timestamp.

7. 60 FPS GPU Rendering Pipeline Optimization Rules

To sustain smooth 60 FPS scrolling and zooming across massive infinite canvases containing hundreds of thousands of vector nodes:

  • Instanced Drawing: Batch identical geometric primitives (rectangles, points, vector handles) into single instanced GPU draw calls to minimize command buffer transmission overhead.
  • Mipmapped Tile Caching: Render complex offscreen vector groupings into rasterized texture tiles at multiple resolution levels, allowing ultra-fast zoom rendering without recalculating vector path geometry.
  • Memory Allocator Tuning: Use custom bump allocators inside WebAssembly to avoid standard garbage collection pauses during high-frequency user interaction loops.

Frequently Asked Technical Questions

How does Figma separate cursor movement broadcasts from durable document edits?

Ephemeral data (like mouse cursor X/Y coordinates and selection box drags) is sent at 60Hz over UDP/WebRTC or non-persisted WebSocket channels with zero database persistence. Durable document mutations (adding shapes, modifying text, moving frames) are sent as ordered CRDT binary update messages persisted to distributed Redis and PostgreSQL WAL stores.

How do you handle multi-user undo/redo in collaborative canvas environments?

Standard linear undo stacks break in multiplayer sessions because undoing could revert another user's work. Systems implement "selective local undo" using CRDT operation trees, inverting only the specific mutations authored by the requesting user's peer ID while preserving concurrent changes from collaborators.

What prevents two users from endlessly fighting over moving the same shape?

While CRDTs resolve mathematical conflicts deterministically (via Lamport timestamps or Last-Write-Wins), UX friction is prevented using soft ephemeral locks. When User A clicks and drags an element, an ephemeral "selection lease" is broadcast, visually locking the element for other peers until released.

How does an offline user reconcile with a canvas document after hours on an airplane?

When returning online, the client sends its vector state clock to the synchronization server. The server computes the missing binary delta diff, and the client applies the diff locally. Because CRDT operations are associative and commutative, the document state seamlessly merges without losing edits.

SV
Shiva Vinodkumar
Principal Architect & Editorial Lead, HelloAIHub

Memory Hierarchy in WebGL/WebGPU Rendering Canvases: Vertex Buffer Packing

Architecting a multi-user collaborative canvas capable of rendering millions of vector nodes at a constant 60 frames per second requires bypassing the standard browser Document Object Model (DOM) entirely. In applications like Figma, the entire document scene graph is compiled into WebAssembly memory and rendered directly via WebGL or WebGPU. Standard browser DOM reconciliations incur catastrophic CPU overhead when thousands of graphical shapes mutate simultaneously.

To saturate modern GPU hardware pipelines efficiently, the WebAssembly engine organizes vector geometry into contiguous interleaved vertex buffers. Rather than allocating individual JavaScript objects for every line segment, bezier curve, and bounding box, data structures are packed into 32-byte cache-aligned memory blocks within linear Wasm memory. When a collaborator modifies an object's coordinates, a single memmove operation updates vertex data in place, allowing modern GPUs to execute instanced draw calls with zero garbage collection overhead.

Spatial indexing via dynamic R-trees partitions the infinite canvas into localized bounding regions. Only shapes falling within the client viewport frustum are uploaded to GPU VRAM, keeping client memory footprints under 150MB even when rendering gargantuan enterprise design systems containing millions of nested vector elements.

CRDT Tombstone Garbage Collection and Operational Convergence Runbooks

Conflict-free Replicated Data Types (CRDTs) provide mathematical convergence guarantees across peer-to-peer and client-server collaborative topologies without requiring central lock coordination. However, a notorious architectural liability in naive CRDT implementations is tombstone bloat: when collaborators delete canvas elements, the system retains deleted nodes in memory to ensure future causal operations resolve correctly.

In prolonged collaborative editing sessions spanning hundreds of design iterations, accumulated tombstones can consume up to 80% of document memory, causing severe client lag and extended file load times. Production collaborative engines solve tombstone bloat through causal stability garbage collection algorithms.

The centralized sync server maintains a vector clock tracking the latest sequence state acknowledged by all active editing peers. When an edit timestamp falls behind the global stable checkpoint (the causal horizon), the server confirms that no in-flight network messages can reference the deleted node, safely purging the tombstone from the document graph. This continuous pruning keeps collaborative document memory compact and ensures instant file opening across global clients.

Multi-threaded Web Workers execute background state diffing and WebSocket message decompression without interrupting the main browser animation thread, preserving buttery smooth 120Hz display refresh rates on ProMotion mobile displays.

By combining contiguous WebAssembly linear memory layouts, GPU vertex buffer instancing, and mathematically proven CRDT convergence protocols, modern collaborative web applications match the responsiveness of native desktop software.

Deterministic local history replay capabilities allow users to scrub through past document revisions instantaneously, reconstructing previous design states without downloading massive version snapshots from remote servers.

Through persistent architectural optimization across graphics pipelines and distributed data types, collaborative canvas engines redefine real-time creative workflows for millions of simultaneous creators.

Differential vector synchronization protocols compress collaborative cursor movements and transient shape drag coordinates into compact 8-byte UDP datagrams, lowering peer-to-peer transmission overhead over lossy cellular networks.

Offscreen rendering canvases managed via dedicated Web Workers isolate complex shader rasterization passes from UI event handlers, ensuring that user keyboard strokes and trackpad gestures register with zero perceptible input lag.

Share:
Up Next: Recommended Deep Dives

Continue Exploring Architecture Masterclasses