Friday 14 January 2022

X forwarding over ssh fails in Ubuntu 18.04

To run some graphical applications over ssh in Linux, indirect GLX rendering must be enabled in X. Recently it has been disabled by default due to security reasons. If disabled, running glxinfo over ssh on the remote host will return an error message like this

me@remote$ glxinfo
name of display: :0
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  41
  Current serial number in output stream:  42

Some applications seem to run ok, like emacs and xclock. I ran into this problem trying to test a webcam connected to a remote host with cheese. The message returned was this one:

me@remote$ cheese

(cheese:3640): Cogl-WARNING **: 16:02:28.989: winsys/cogl-winsys-egl-kms.c:771: Error restoring saved CRTC

(cheese:3640): Gdk-CRITICAL **: 16:02:29.027: gdk_visual_get_screen: assertion 'GDK_IS_VISUAL (visual)' failed

(cheese:3640): Gdk-CRITICAL **: 16:02:29.027: gdk_window_new: assertion 'gdk_visual_get_screen (attributes->visual) == screen' failed

(cheese:3640): Gdk-CRITICAL **: 16:02:29.027: gdk_window_get_width: assertion 'GDK_IS_WINDOW (window)' failed

(cheese:3640): Gdk-CRITICAL **: 16:02:29.027: gdk_window_get_height: assertion 'GDK_IS_WINDOW (window)' failed
Segmentation fault (core dumped)

A simple way to test if indirect GLX rendering is enabled is force indirect GLX rendering by running glxinfo with the -i option:

me@local$ glxinfo -i

If you have a xorg.conf file, just add to it the code below in both local and remote hosts.

Section "ServerFlags"
    Option "AllowIndirectGLX" "on"
    Option "IndirectGLX" "on" 
EndSection

If there is no xorg.conf file, create a file /etc/X11/xorg.conf.d/10-indirectglx.conf and add the code above to it.

References:

https://askubuntu.com/questions/1100451/how-to-enable-allowindirectglx-on-ubuntu-18-04-with-nvidia-1050ti