Wayland, Remote Desktop Sharing and Ubuntu 22.04

Desktop sharing is one of the essential things I do every day. For almost 10 years now, I’m using x11vnc to get GUI access on remote Ubuntu desktops. There are many VNC servers, but x11vnc is the best I have found so far, as it works well even under extremely severe bandwidth constraints, i.e., it can easily live with 1 Mbit/s in the uplink when using the highest compression scheme. And if nothing happens on the desktop, there is almost no data transmitted. As the name implies, x11vnc is based on the x11 display server. That’s a bit of a problem these days, as all Linux distributions that use the Gnome desktop, including Ubuntu, are trying very hard for years now to switch to the newer Wayland display server. One of the problems that have plagued all attempts so far was the lack of a usable remote desktop solution. But now, it looks like Ubuntu will make Wayland the default compositor in the upcoming 22.04 Long Term Support (LTS) version. X11 is still supported, but once Wayland becomes the default, I wonder how much love x11 will still get!? So long story short, I was wondering what kind of remote desktop sharing solution Gnome and Ubuntu are proposing for 22.04 and whether it works as well as x11vnc. The answer was not as bad as I thought, but also not as good as I hoped.

Broken in the Daily Build

It’s still early April 2022 so Ubuntu LTS 22.04 has not yet been released. However, there are daily builds available, so I download the latest one to have a closer look at the built-in desktop sharing. To my surprise, the functionality is totally broken in my daily build, but I’m not the first to notice. More about that later. So I assume for now that in whatever way the current problem will be fixed before 22.04 is released, the result will pretty much look like what is currently built into Ubuntu 21.10. So I got the latest image of that release and continued there.

Update 11. May 2022: It turned out that my assumption that 22.04 LTS would work the same as 21.10 was wrong. The final version of 22.04 LTS uses RDP instead of VNC for remote desktop sharing in combination with Wayland. Therefore, head over to my later review of the final RDP based solution in Ubuntu 22.04.

The remainder of this post has a look of the VNC backend of the remote desktop solution of Ubuntu 21.04 and also of the “legacy fallback option” in Ubuntu 22.04.

Wayland, Desktop Sharing and Ubuntu 21.10

In Ubuntu 21.10, desktop sharing works in Wayland mode and I could activate it in the settings. I then used Remmina and its VNC plugin to connect remotely. In the local network, this works very nicely and the remote UI is responsive to mouse clicks and key presses. A positive surprise!

However, I could already see there and then that the bandwidth requirements are huge. Double digit Mbit/s datarates were not out of the ordinary. While this is no problem in the local network, such data rates are a total showstopper when connecting to a device over a slow Internet connection with 1-2 Mbit/s. Also, connecting to moving devices and quickly changing backhaul speeds, e.g. in trains (yes, I do that) is just out of the question at such speeds.

Minimum Data Rates

So what’s the slowest Internet connection Ubuntu’s Wayland based remote desktop sharing is still usable with? I experimented for quite a while and in the highest compression setting, I could get down as low as 2 Mbit/s. Anything less and the session becomes unresponsive. Even at 2 Mbit/s, responsiveness is considerably worse compared to x11vnc. In addition, desktop sharing takes the full 2 Mbit/s of bandwidth at all times, even if nothing changes on the screen. This significantly slows down other applications running over the slow remote line at the same time. So while I’m glad it works at all, I’m not so happy that some of my major use cases can’t be covered with that solution.

Other Tidbits

In addition, there are a number of other things that would make my live difficult with Ubuntu’s Wayland desktop sharing. Fortunately, I found a workaround for each of them:

No Localhost Option

The first thing that bugged me was that when desktop sharing is activated, it is open to all incoming IP addresses. That’s a problem, because VNC only uses 8 character passwords. That’s not strong enough by far. X11vnc shares the same problem, but I usually run the vnc server in ‘localhost’ mode, i.e. it only accepts incoming connections from 127.0.0.1. To access desktop sharing, I establish an ssh session and activate port forwarding. The way around this with Ubuntu’s built in Wayland desktop sharing is to use the Universal Firewall (ufw) and limit incoming access to port 5900 to localhost. I haven’t tried if this works, but I’m pretty confident that this can be made to work.

Network Dependencies

In Ubuntu’s settings menu, Remote Desktop Sharing can and has to be activated per Wi-Fi SSID. That’s nice but many devices I support frequently change Wi-Fi networks and I can’t get to the GUI remotely to activate desktop sharing in a new Wi-Fi. Fortunately, I usually do have SSH connections to those machines, even if they change networks frequently, and running

systemctl --user start gnome-remote-desktop

on the shell activates the remote desktop server if it is not running.

Restarting Hung Sessions

You might have noticed that nothing is perfect. Internet connectivity on the move in particular. If a VNC connection is interrupted, the vnc server hangs, and it’s not possible to log-in again. Also, there’s no way on the GUI to get things going again. But once the ssh link is up again, killing the remote desktop server and starting it again on the shell gets things running again.

Repeating Keys

Over slow connections, VNC suffers from characters that keep repeating. I didn’t have much of a problem with that, as x11vnc can handle very slow connections. With gnome-remote-desktop with the VNC backend, this is much more of a problem over slow connections. The fix: On the remote host, disable ‘repeat keys’ in the ‘Universal Access’ settings. Cool, I can use this for my current x11 setup as well in special situations.

Summary and Way Forward

Over relatively fast and un-metered Internet connections, Ubuntu’s Wayland desktop sharing with gnome-remote-desktop and the VNC backend works quite well. Unfortunately, my low bandwidth use-case is the norm rather than the exception for me, so it’s not a solution for me. Fortunately, it’s also possible to switch from Wayland to x11 for a user when logging in, and Ubuntu remembers this decision across reboots. In the next episode I’ll therefore have a closer look how x11vnc behaves in Ubuntu 22.04 LTS. Also, there is still the possibility that Ubuntu will switch to the RDP backend of the gnome-remote-desktop package they use for remote desktop sharing, which might change things again. If that happens, I’ll have a closer again.

P.S.

And to check if the current GUI session runs over X11 or Wayland, the following shell command comes in handy:

echo $XDG_SESSION_TYPE