16 Matching Annotations
  1. Apr 2020
    1. There are many types of CRDTs

      CRDTs have different types, such as Grow-only set and Last-writer-wins register. Check more of them here

    2. Some of our main takeaways:CRDT literature can be relevant even if you're not creating a decentralized systemMultiplayer for a visual editor like ours wasn't as intimidating as we thoughtTaking time to research and prototype in the beginning really paid off

      Key takeaways of developing a live editing tool

    3. traditional approaches that informed ours — OTs and CRDTs

      Traditional approaches of the multiplayer technology

    4. CRDTs refer to a collection of different data structures commonly used in distributed systems. All CRDTs satisfy certain mathematical properties which guarantee eventual consistency. If no more updates are made, eventually everyone accessing the data structure will see the same thing. This constraint is required for correctness; we cannot allow two clients editing the same Figma document to diverge and never converge again

      CRDTs (Conflict-free Replicated Data Types)

    5. They’re a great way of editing long text documents with low memory and performance overhead, but they are very complicated and hard to implement correctly

      Characteristics of OTs

    6. Even if you have a client-server setup, CRDTs are still worth researching because they provide a well-studied, solid foundation to start with

      CRDTs are worth studying for a good foundation

    7. Figma’s multiplayer servers keep track of the latest value that any client has sent for a given property on a given object

      No conflict:

      • two clients changing unrelated properties on the same object
      • two clients changing the same property on unrelated objects.

      Conflict:

      • two clients changing the same property on the same object (document will end up with the last value sent)
    8. Figma doesn’t store any properties of deleted objects on the server. That data is instead stored in the undo buffer of the client that performed the delete. If that client wants to undo the delete, then it’s also responsible for restoring all properties of the deleted objects. This helps keep long-lived documents from continuing to grow in size as they are edited

      Undo option

    9. Designers worried that live collaborative editing would result in “hovering art directors” and “design by committee” catastrophes.

      Worries of using a live collaborative editing

    10. We had a lot of trouble until we settled on a principle to help guide us: if you undo a lot, copy something, and redo back to the present (a common operation), the document should not change. This may seem obvious but the single-player implementation of redo means “put back what I did” which may end up overwriting what other people did next if you’re not careful. This is why in Figma an undo operation modifies redo history at the time of the undo, and likewise a redo operation modifies undo history at the time of the redo

      Undo/Redo working

    11. operational transforms (a.k.a. OTs), the standard multiplayer algorithm popularized by apps like Google Docs. As a startup we value the ability to ship features quickly, and OTs were unnecessarily complex for our problem space

      Operational Transforms (OT) are unnecessarily complex for problems unlike Google Docs

    12. Every Figma document is a tree of objects, similar to the HTML DOM. There is a single root object that represents the entire document. Underneath the root object are page objects, and underneath each page object is a hierarchy of objects representing the contents of the page. This tree is is presented in the layers panel on the left-hand side of the Figma editor.

      Structure of Figma documents

    13. When a document is opened, the client starts by downloading a copy of the file. From that point on, updates to that document in both directions are synced over the WebSocket connection. Figma lets you go offline for an arbitrary amount of time and continue editing. When you come back online, the client downloads a fresh copy of the document, reapplies any offline edits on top of this latest state, and then continues syncing updates over a new WebSocket connection

      Offline editing isn't a problem, unlike the online one

    14. An important consequence of this is that changes are atomic at the property value boundary. The eventually consistent value for a given property is always a value sent by one of the clients. This is why simultaneous editing of the same text value doesn’t work in Figma. If the text value is B and someone changes it to AB at the same time as someone else changes it to BC, the end result will be either AB or BC but never ABC

      Consequence of approaches like last-writer-wins

    15. We use a client/server architecture where Figma clients are web pages that talk with a cluster of servers over WebSockets. Our servers currently spin up a separate process for each multiplayer document which everyone editing that document connects to

      Way Figma approaches client/server architecture

    16. CRDTs are designed for decentralized systems where there is no single central authority to decide what the final state should be. There is some unavoidable performance and memory overhead with doing this. Since Figma is centralized (our server is the central authority), we can simplify our system by removing this extra overhead and benefit from a faster and leaner implementation

      CRDTs are designed for decentralized systems