kasmtech / KasmVNC

Modern VNC Server and client, web based and secure
GNU General Public License v2.0
3.03k stars 290 forks source link

Black / Blank Screen with default KasmVNC Settings and Solution #264

Open jarrah31 opened 1 month ago

jarrah31 commented 1 month ago

This post is to both report an issue and solution to the blank screen problem I had when using default installation options on Ubuntu Jammy 22.04 Desktop.

As per https://www.kasmweb.com/kasmvnc/docs/latest/install.html, I installed KasmVNC as follows:

wget https://github.com/kasmtech/KasmVNC/releases/download/v1.3.1/kasmvncserver_jammy_1.3.1_amd64.deb
sudo apt install ./kasmvncserver_jammy_1.3.1_amd64.deb
sudo addgroup $USER ssl-cert
reboot
vncserver

After creating a new user, I chose option 1 for the Desktop Environment:

Please choose Desktop Environment to run:
[1] Gnome
[2] Manually edit xstartup

Browsing to the Ubuntu VNC server both locally (https://127.0.1.1:8444) and from another client on my network (https://192.168.1.207:8444/) results in a black screen.

For reference, the ~/.vnc/xstartup file looks like this:

$ cat ~/.vnc/xstartup
#!/bin/sh
set -x
XDG_CURRENT_DESKTOP=GNOME exec dbus-launch --exit-with-session /usr/bin/gnome-session

The solution

The first part of the solution results in a basic Gnome desktop with no menu bar, so to have the full desktop environment some edits to xstartup and an additional package install is required which is shown later in these instructions. First let's get the basic desktop working.

  1. Remove the existing .vnc folder. rm -rf ~/.vnc
  2. Run vncserver again
  3. Create a new user (you may not need to do this again)
  4. Choose option 2 for the Desktop Environment
    Please choose Desktop Environment to run:
    [1] Gnome
    [2] Manually edit xstartup
  5. Now if you browse to the IP you should see a basic desktop with no blank screen. If you still have a blank screen, you may need to reboot.

For reference, the xstartup file looks like this now. The reason for the basic desktop is twm at the bottom of the file.

#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
  case "$WINDOWMANAGER" in
    *gnome*)
      if [ -e /etc/SuSE-release ]; then
        PATH=$PATH:/opt/gnome/bin
        export PATH
      fi
      ;;
  esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
  exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
  exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm

The next part of the solution is to change the xstartup file contents and install dbus-x11.

  1. Kill any existing vnc sessions vncserver -list vncserver -kill :1
  2. Create a backup of xstartup. cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
  3. Edit xstartup nano ~/.vnc/xstartup
  4. Replace all content with the following:
    
    #!/bin/sh

unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

vncconfig -iconic &

export XKL_XMODMAP_DISABLE=1 export GNOME_SHELL_SESSION_MODE=ubuntu export XDG_CURRENT_DESKTOP=ubuntu:GNOME export XDG_SESSION_DESKTOP=ubuntu export XDG_SESSION_TYPE=x11 export DISPLAY=:1

dbus-launch --exit-with-session gnome-session &


5. Ensure the file is executable
`chmod +x ~/.vnc/xstartup`
6. Install dbus-x11
`sudo apt-get install dbus-x11`
7. Start vncserver with optional extra options
`vncserver -geometry 1920x1080 -depth 24`
8. Browse to your desktop IP and you should find it shows a full desktop.
<img width="383" alt="image" src="https://github.com/user-attachments/assets/44d110a2-4918-476a-b48a-db41fee69ede">
jarrah31 commented 1 month ago

Actually, the black screen can be fixed by ensuring you install "dbus-x11" when choosing the Desktop Environment Option 1 (Gnome), but it still results in a minimal desktop, so the xstartup modification is still required.