OpenGL with mir on Joule

Hi,

I’m trying to get a snap with a simple OpenGL app (glxgears) to run on Core in Joule with mir-kiosk and apps.
The kiosk mode works fine but OpenGL glfwinit() fails - see below.

Any tips appreciated.

parts have:
gears:
plugin: nil
stage-packages:
- mesa-utils
- libgl1-mesa-dri

and the wrapper is simply:

#!/bin/bash
echo "running glxgears"
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/x86_64-linux-gnu/dri
exec $SNAP/usr/bin/glxgears

On the Joule target side from /var/log/syslog

Jan 13 04:15:13 localhost snap[11128]: running glxgears
Jan 13 04:15:13 localhost snap[11128]: Error: couldn't open display (null)

I also checked this https://bugs.launchpad.net/snappy/+bug/1584178

dont you also need to have libgl1-mesa-glx in the stage-packages for glx ?

Thanks. Tested but it fails the same way also with
gears:
plugin: nil
stage-packages:
- mesa-utils
- libgl1-mesa-dri
- libgl1-mesa-glx

you might need to add $SNAP/usr/lib/x86_64-linux-gnu/mesa to your LD_LIBRABRY_PATH with your wrapper … that is where it ships libGL.so.1

also, since you didnt post the whole snapcraft.yaml i assume you have the opengl plug enabled there ?

Thanks, really appreciate your help. opengl plug is there.
I’ll check with your proposed addition to the wrapper and let you know.

Adding $SNAP/usr/lib/x86_64-linux-gnu/mesa to LD_LIBRABRY_PATH did not solve the issue.
/var/log/syslog shows:

May  5 11:29:37 localhost snap[12130]: running glxgears
May  5 11:29:37 localhost snap[12130]: MIR_CLIENT_PLATFORM_PATH=/snap/mir-kiosk-apps/x1/mir-libs/x86_64-linux-gnu/mir/client-platform
May  5 11:29:37 localhost snap[12130]: SNAP_USER_COMMON=/root/snap/mir-kiosk-apps/common
May  5 11:29:37 localhost snap[12130]: SNAP_REEXEC=
May  5 11:29:37 localhost snap[12130]: LIBGL_DRIVERS_PATH=/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/dri
May  5 11:29:37 localhost snap[12130]: LD_LIBRARY_PATH=/snap/mir-kiosk-apps/x1/mir-libs/x86_64-linux-gnu:/var/lib/snapd/lib/gl:/var/lib/snapd/void:/snap/mir-kiosk-apps/x1/usr/lib:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/mesa:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/mesa-egl:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/mesa:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/mesa-egl::/snap/mir-kiosk-apps/x1/lib:/snap/mir-kiosk-apps/x1/usr/lib:/snap/mir-kiosk-apps/x1/lib/x86_64-linux-gnu:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/mesa:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/mesa-egl:/snap/mir-kiosk-apps/x1/usr/lib/x86_64-linux-gnu/dri
May  5 11:29:37 localhost snap[12130]: SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/void
May  5 11:29:37 localhost snap[12130]: SNAP_COMMON=/var/snap/mir-kiosk-apps/common
May  5 11:29:37 localhost snap[12130]: SNAP_USER_DATA=/root/snap/mir-kiosk-apps/x1
May  5 11:29:37 localhost snap[12130]: SNAP_DATA=/var/snap/mir-kiosk-apps/x1
May  5 11:29:37 localhost snap[12130]: PATH=/snap/mir-kiosk-apps/x1/usr/sbin:/snap/mir-kiosk-apps/x1/usr/bin:/snap/mir-kiosk-apps/x1/sbin:/snap/mir-kiosk-apps/x1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
May  5 11:29:37 localhost snap[12130]: PWD=/var/snap/mir-kiosk-apps/x1
May  5 11:29:37 localhost snap[12130]: XKB_CONFIG_ROOT=/snap/mir-kiosk-apps/x1/usr/share/X11/xkb
May  5 11:29:37 localhost snap[12130]: MIR_SOCKET=/run/mir_socket
May  5 11:29:37 localhost snap[12130]: LANG=C.UTF-8
May  5 11:29:37 localhost snap[12130]: SNAP_REVISION=x1
May  5 11:29:37 localhost snap[12130]: SHLVL=1
May  5 11:29:37 localhost snap[12130]: HOME=/root/snap/mir-kiosk-apps/x1
May  5 11:29:37 localhost snap[12130]: SNAP_NAME=mir-kiosk-apps
May  5 11:29:37 localhost snap[12130]: SNAP_ARCH=amd64
May  5 11:29:37 localhost snap[12130]: SNAP_VERSION=0.1
May  5 11:29:37 localhost snap[12130]: XDG_RUNTIME_DIR=/run/user/0/snap.mir-kiosk-apps
May  5 11:29:37 localhost snap[12130]: SNAP=/snap/mir-kiosk-apps/x1
May  5 11:29:37 localhost snap[12130]: _=/usr/bin/env
May  5 11:29:37 localhost snap[12130]: Error: couldn't open display (null)

I also checked the environment for missing pieces with https://raw.githubusercontent.com/ubuntu/snapcraft-desktop-helpers/master/common/desktop-exports but to no avail.

I shared my simple OpenGL test on Joule at https://git.launchpad.net/opengl-test with my test_joule script

In general, I’m just interested in any simple OpenGL snap to render graphics on Ubuntu Core with Joule so if you have ideas, please share.

With above:

vilvo@localhost:~$ snap list
Name            Version                 Rev   Developer  Notes
bluez           5.44-1                  65    canonical  -
classic         16.04                   17    canonical  devmode
core            16-2                    1689  canonical  -
joule           16.04-0.8+3             4     canonical  -
joule-linux     4.4.0-1000.0+joule21-6  8     canonical  -
mir-kiosk       1.2.0                   30    canonical  -
mir-kiosk-apps  0.1                     x1               -
mir-libs        0.26.1                  25    canonical  -
pulseaudio      8.0-3                   9     canonical  -
snapweb         0.26.1                  207   canonical  -

and interfaces:

vilvo@localhost:~$ snap interfaces
Slot                      Plug
bluez:service             bluez:client
:account-control          -
:alsa                     -
:autopilot-introspection  -
:bluetooth-control        -
:browser-support          -
:camera                   -
:classic-support          -
:core-support             core:core-support-plug
:dcdbas-control           -
:docker-support           -
:firewall-control         -
:framebuffer              -
:fuse-support             -
:hardware-observe         -
:home                     pulseaudio
:io-ports-control         -
:joystick                 -
:kernel-module-control    -
:locale-control           -
:log-observe              -
:lxd-support              -
:mount-observe            -
:network                  mir-kiosk-apps,pulseaudio,snapweb
:network-bind             snapweb
:network-control          -
:network-observe          -
:network-setup-control    -
:network-setup-observe    -
:opengl                   mir-kiosk,mir-kiosk-apps
:openvswitch-support      -
:physical-memory-control  -
:physical-memory-observe  -
:ppp                      -
:process-control          -
:raw-usb                  -
:removable-media          -
:shutdown                 -
:snapd-control            snapweb
:system-observe           -
:system-trace             -
:time-control             -
:timeserver-control       snapweb
:timezone-control         snapweb
:tpm                      -
:uhid                     bluez
joule:alsa                -
joule:gpio-led-0          -
joule:gpio-led-1          -
joule:gpio-led-2          -
joule:gpio-led-3          -
joule:i2c-0               -
joule:i2c-1               -
joule:i2c-10              -
joule:i2c-11              -
joule:i2c-2               -
joule:i2c-3               -
joule:i2c-4               -
joule:i2c-5               -
joule:i2c-6               -
joule:i2c-7               -
joule:i2c-8               -
joule:i2c-9               -
joule:serial-usb          -
mir-kiosk:mir             mir-kiosk-apps
mir-libs:mir-libs         mir-kiosk,mir-kiosk-apps
pulseaudio:service        pulseaudio:client
-                         bluez:bluetooth-control
-                         bluez:network-control

since you are using the mir-kiosk-apps package as a blueprint for your GL testing, would you mind trying the package from the store to be sure the whole mir setup runs at all (afaik there are also GL based demos like the photoviewer included).

it could well be that direct GL stuff does not work in this constellation (i.e. not going through the Qt/QML interface).

photoviewer in mir-kiosk-apps from edge works but when I build the snap from Alberto Aguirre launchpad repository (baseline of my fork), the snap fails to build with photoviewer. That’s why I removed it - other demos run with self-built snap, though.