/ Ideas / Low-latency wayland compositor in OCaml

This is an idea proposed in 2024 as a Cambridge Computer Science Part II project, and is currently being worked on by Tom Thorogood. It is supervised by Ryan Gibb and Anil Madhavapeddy as part of the Interspatial OS project.

Summary

When building situated displays and hybrid streaming systems, we need fine-grained composition over what to show on the displays. Wayland is a communications protocol for next-generation display servers used in Unix-like systems.[1]

It has been adopted as the default display server by Linux distributions including Fedora with KDE, and Ubuntu and Debian with GNOME. It aims to replace the venerable X display server with a modern alternative. X leaves logic such as window management to application software, which has allowed the proliferation of different approaches. Wayland, however, centralizes all this logic in the 'compositor', which assumes both display server and window manager roles.[2]

Libraries such as wlroots, libweston, and 'small Wayland compositor', exist to provide a basis on which to build a Wayland compositor. Much of the Wayland ecosystem is written in C, but modern memory-safe, type-safe, composable systems programming languages like OCaml offer tempting alternatives. This project proposes writing a Wayland compositor in OCaml, which opens up interesting opportunities for writing custom window management logic similar to how xmonad does for X[3] rather than relying on IPC mechanisms used in state-of-the-art systems.[4]

This project is suitable for an ambitious student with a keen interest in graphics, communication protocols, and operating systems. Starting points include completing OCaml wlroots bindings[3] enough to implement an OCaml version of the tinywl compositor[5] and the pure OCaml implementation of the Wayland protocol.[6]

If you want to read a really fun historical paper that inspires this work, then the teleporting displays paper should give you some entertaining background.

  1. https://wayland.freedesktop.org/

    ↩︎︎
  2. https://wayland.freedesktop.org/faq.html#heading_toc_j_11

    ↩︎︎
  3. https://github.com/swaywm/ocaml-wlroots

    ↩︎︎1↩︎︎2
  4. https://github.com/swaywm/sway/blob/master/sway/sway-ipc.7.scd

    ↩︎︎
  5. https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/tinywl/tinywl.c

    ↩︎︎
  6. https://github.com/talex5/ocaml-wayland

    ↩︎︎

Related Ideas