KDE Developer Demos Seamless Crash Recovery in QtWayland

KDE developer David Edmundson has demoed a new feature being incorporated in Plasma, one that will allow seamless recovery from crashes.

The Linux world is in the midst of a transition from the old X11 display server to the newer Wayland protocol. At the same time, KDE is transitioning the Plasma desktop environment (DE) and apps to version 6 of the underlying Qt toolkit.

Together, these changes are providing a unique opportunity for KDE developers to build in seamless crash recovery when the display server crashes, as Edmundson explains in his blog:

Right now if you restart pulseaudio your sound might cut out, restart NetworkManager and you lose your wifi, restart an X11 window manager and your decorations disappear.

But within a second it’s all back to normal exactly where you left off with everything recovering fine.

This isn’t true for display servers. If X11 restarts you’re back at the login prompt. All drafts lost, games unsaved, work wasted.

Edmundson details how QtWayland 6.6 provides a way to overcome this issue:

The solution for this? Instead of exiting when the compositor closes, simply…don’t!

If we could connect to a new compositor we just need to send the right amount of information to bring it in sync and notify the application code of any changes to bring this in sync.

For Qt applications all this information is handled in the backend, in the Wayland Qt Platform Abstraction (QPA).

Qt already has to handle screens and input devices being removed, clipboards being revoked and drag and drops cancelled. Supporting a whole reset isn’t introducing any new work, we just have to trigger all of these actions at once, then reconnect to the newly restored compositor and restore our contents.

Applications already have to support all of these events too as well as handle callbacks to redraw buffers. There’s no changes needed at an application code level, it’s all done as transparently as possible.

Edmundson says there are other potential benefits down the road, including the ability to seamlessly perform updates in place that would normally require logging out and back in.

The KDE developers are also upstreaming these changes so other toolkits can use them, with “pending patches for GTK, SDL and even XWayland, with key parts of SDL merged but disabled already.”

The feature is a significant improvement for the Linux desktop and will hopefully be widely adopted across desktops and distributions.