Ubuntu – x11vnc much slower than Xvnc + how to get a Xubuntu session manually

headlessvncxubuntu

I'm running Xubuntu 12.04 on a headless server inside a VMware virtual machine. I'd prefer using x11vnc over Xvnc in order to use LightDM and the X server started by LightDM (and login using Xubuntu-session rather than xfce4).

The problem is that x11vnc is much slower than Xvnc (both vnc4server and tightvncserver flavours). I'm on a low speed broadband connection and, e.g. dragging windows is visibly slower on x11vnc, about 3-4 times slower I'd say.

I'm forcing 16 bit and 1280×800 on both x11vnc and Xvnc, but I'm not sure x11vnc is actually using 16bpp (see logs below).

x11vnc

I start x11vnc with a start script in /etc/init/x11vnc:

start on login-session-start
script
x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 \
  -auth /var/run/lightdm/root/:0 -forever -shared -bg \
  -o /var/log/x11vnc.log -rfbport 5901 -localhost -nopw -xrandr
end script

By default, this will start in 800×600 with 32bpp, which cannot be changed via command line parameters. I had to do:

apt-get install xserver-xorg-video-dummy

and then create /etc/X11/xorg.conf (which did not exist by default) with the contents:

Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
EndSection

Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 31.5-48.5
    VertRefresh 50-70
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 16
    SubSection "Display"
    Depth 16
    Modes "1280x800"
    EndSubSection
EndSection

When connecting to it, /var/log/x11vnc.log says:

30/11/2013 07:12:32 Pixel format for client 127.0.0.1:
30/11/2013 07:12:32   16 bpp, depth 16, little endian
30/11/2013 07:12:32   true colour: max r 31 g 63 b 31, shift r 11 g 5 b 0
30/11/2013 07:12:32 no translation needed

note the true color part.

Also, there is still transparency in the lower panel when using 16bpp in x11vnc, whereas when using "-depth 16" with Xvnc, all transparent panels have solid color and the "alpha" option in the panel configuration is gone. This makes me think that XFCE still detects a 32bit display when using x11vnc, which may be a cause for slowness.

I also tried xserver-command=X -depth 16 in /etc/lightdm/lightdm.conf, but didn't make any difference.

Xvnc

I did:

apt-get install vnc4server
vncserver :1 -depth 16 -geometry 1280x800

This starts a new X session, depending on what I have in ~/.vnc/startup, which is:

#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
# x-window-manager &
startxfce4 &

There is no wireframe by default. Dragging windows shows the full window, not just a border, and it's still visibly faster than x11vnc which is showing only a wire frame when dragging windows! Same goes if I replace vnc4server with tightvncserver.

Any clues on how to make x11vnc just as fast? It must be capable somehow!

I tried all sort of options to x11vnc (from all thos -nox* -nowireframe, etc) to no avail.

Alternatively, I could stop LightDM and start Xvnc with the ~/.vnc/xstartup so that it starts the same Xubuntu session as it does from LilghtDM login screen, rather than XFCE4 session … but I don't know how. I did replace startxfce4 with /etc/X11/Xsession but it does not look the same. The fonts are smaller and there are artefacts.

Any help would be appreciated!

Best Answer

I managed to answer the Alternative part of my question, i.e. use vnc4server or tightvncserver to start a Xubuntu session instead of a plain XFCE session. This is separate from LightDM, which can then be stopped or put on manual. I'll investigate Nicholas's suggestions later.

This is equivalent to logging in via LightDM with a Xubuntu session, it remains alive if my vnc connection dies or I disconnect, and I get to enjoy the Xubuntu customizations.

To do that, make ~/.vnc/xstartup contain just the following:

#!/bin/sh
export XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg
export XDG_DATA_DIRS=/usr/share/xubuntu:/usr/local/share/:/usr/share/:/usr/share
vncconfig -iconic &
. lightdm-session

You can replace . lightdm-session with exec startxfce4 or startxfce4 &. The former is really what LightDM calls, but it calls xfce4-session in the end.

This then starts a Xubuntu session, rather than a plain XFCE one, and you can stop LightDM altogether if X/keyboard access is not needed.

You can configure a daemon by placing the following in /etc/init/vncserver.conf:

start on runlevel [2345]
stop on runlevel [016]
post-start script
        su USER -c "vncserver :1 -geometry 1280x800 -depth 16 -localhost -SecurityTypes None"
end script
post-stop script
        su USER -c "vncserver -kill :1"
end script

Then start/stop it with start vncserver. The above is for vnc4server and will start Xvnc listening only on 127.0.0.1 and will not require a password. This is handy for me as I use an ssh tunnel anyway:

ssh -L6901:127.0.0.1:5901 USER@HOST.DOMAIN.COM

If you use tightvncserver, then delete the option -SecurityTypes None as it doesn't understand it. Note that tightvncserver always asks for a password (you can't make it passwordless).

NOTE: if USER above is not root, or if you run "vncserver :1 [options]" as non-root, then inside XFCE there will be issues sudo-ing into GUI apps because the underlying sudo-ed app will not find an X display. I haven';t yet found a fix for this. With x11vnc it works because x11vnc connects to an existing X session, including the :0 one.