Skip to content

Introduce API for clients to handoff between compositors

David Edmundson requested to merge davidedmundson/wayland:reconnections into main

Being able for clients to survive compositor crashes is a problem for user experience compared to X11. We also see clients get taken down when they commit a one-off error or overflow the input stack.

This patch introduces an optional mechanism for clients to survive a crash and reconnect seemingly seamlessly.

Supporting compositors would introduce a method to make the wayland socket file in the file system persistent against compositor restarts either directly or through a service like systemd.

If the compositor crashes, clients can try to reconnect to the previously used socket and resend window state and buffers. Typical toolkits have all of this information at hand already and can take care of it transparently to application code. If the compositor does not support the reconnect mechanism and it exits/crashes or in the case of logout where a supporting compositor cleanly closes, applications will exit as before.

We want to have the same wl_display object used between connection instances as this object is passed to multiple libraries across a client application. in particular to mesa for the egldisplay which we want to behave as a singleton.

This impacts other design decisions; as multiple threads can be used at once it can be important to know which proxy objects belong to the alive or dead connection. Upon reconnecting all old proxies are marked as "defunct". This allows a thread to carry on using old proxy objects without anything being sent across the wire until that thread is later synced.

This is the follow-up merge request to the discussion at: https://www.mail-archive.com/wayland-devel@lists.freedesktop.org/msg41274.html which also has more rationale

This has been successfully implemented in:

And corresponding helper libraries:

Changes are relatively noninvasive throughout these libraries.

Applications themselves require no changes, unless they also do low-level wayland work. It has been tested with a wide range of applications from advanced IDEs to video editors to games. It remains opt-in, applications can also exit if they encounter an error.

Edited by David Edmundson

Merge request reports