Cannot run PyQt snap in Ubuntu Core

Hi. I have a PyQt5 snap. I works great on Ubuntu Desktop. I have been trying to run the snap on my Ubuntu Core for the last few days, but no luck till now.

Here is my snapcraft.yaml

name: cluemaster-mediadisplay 
base: core20
version: '1.0.8'
summary: summary
description: description
grade: stable 
confinement: strict

apps:
  cluemaster-mediadisplay-daemon:
    command: bin/run-daemon wayland-launch prepare-launch $SNAP/cluemaster_display
    daemon: simple
    restart-condition: always
    plugs:
      - home
      - desktop-legacy
      - desktop
      - wayland
      - x11
      - unity7
      - network
      - opengl
      - gsettings
      - pulseaudio
      - network-bind
      - screen-inhibit-control
      - audio-playback
      - shutdown
      - process-control
      - mount-observe
      - network-control

  cluemaster-mediadisplay:
    command: bin/run-daemon wayland-launch prepare-launch $SNAP/cluemaster_display
    plugs:
      - home
      - desktop-legacy
      - desktop
      - wayland
      - x11
      - unity7
      - network
      - opengl
      - gsettings
      - pulseaudio
      - network-bind
      - screen-inhibit-control
      - audio-playback
      - shutdown
      - process-control
      - mount-observe
      - network-control

environment:
  QT_QPA_PLATFORM: wayland
  QTCHOOSER_NO_GLOBAL_DIR: 1
  QT_SELECT: snappy-qt5

parts:
  copy-source-code:
    plugin: dump
    source: cluemaster_display/
    stage-packages:
      - ffmpeg
      - locales
      - libmpv1
      - va-driver-all
      - vdpau-driver-all
      - mesa-va-drivers
      - libvdpau-va-gl1
      - libglu1-mesa
      - samba-libs
      - git
      - python3-dbus
      - qtwayland5

  cluemaster-mediadisplay:
    after: [copy-source-code]
    plugin: python
    python-packages:
      - PyQt5==5.14.1
      - requests==2.22.0
      - git+https://github.com/hiransarkar21/python-mpv
      - simplejson==3.16.0
    stage-packages:
      - python3-pyqt5
      - python3-pyqt5.qtsvg
      - python3-pyqt5.qtmultimedia
      - python3-requests
      - python3-simplejson
      - python3

  desktop-files-and-icons:
    plugin: dump
    source: snap/gui/
    organize: 
      "cluemaster-mediadisplay.desktop": "usr/share/applications/"
      "cluemaster-mediadisplay.png": "usr/share/applications/"
    stage:
      - usr/share/applications/cluemaster-mediadisplay.desktop
      - usr/share/applications/cluemaster-mediadisplay.png

  extras:
    plugin: dump
    source: static/
    organize: 
      "prepare-launch": "bin/"

  desktop-qt5:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: qt
    plugin: make
    make-parameters: ["FLAVOR=qt5"]
    build-packages:
      - build-essential
      - qtbase5-dev
      - dpkg-dev
    stage-packages:
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libqt5gui5
      - libgdk-pixbuf2.0-0
      - libqt5svg5 # for loading icon themes which are svg
      - try: [appmenu-qt5] # not available on core18
      - locales-all
      - xdg-user-dirs
      - fcitx-frontend-qt5

  mir-kiosk-snap-launch:
    plugin: dump
    source: https://github.com/MirServer/mir-kiosk-snap-launch.git
    override-build: |
      echo "snapctl set app=rssnews" >> $SNAPCRAFT_PART_BUILD/meta/hooks/install
      echo "[ -e \"\$SNAP/apps/\$(snapctl get app)\" ] || snapctl set app=rssnews" >> $SNAPCRAFT_PART_BUILD/meta/hooks/post-refresh
      $SNAPCRAFT_PART_BUILD/build-with-plugs.sh network opengl wayland
    stage-packages:
      - inotify-tools

layout:
  /usr/share/libdrm/amdgpu.ids:
    symlink: $SNAP/usr/share/libdrm/amdgpu.ids
  /etc/glvnd:
    bind: $SNAP/etc/glvnd
  /etc/fonts:
    bind: $SNAP/etc/fonts
  /etc/xdg:
    bind: $SNAP/etc/xdg
  /usr/share/X11/xkb:
    bind: $SNAP/usr/share/X11/xkb
  /usr/share/fonts:
    bind: $SNAP/usr/share/fonts
  /usr/share/glvnd:
    bind: $SNAP/usr/share/glvnd
  /usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5:
    bind: $SNAP/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5

The content of my prepare-launch script

#!/bin/sh

echo "Prepairing launch ..."
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH="$SNAP/usr/lib/x86_64-linux-gnu/samba":$LD_LIBRARY_PATH
export PYTHONPATH="$SNAP/usr/lib/python3/dist-packages"
echo "Environment variables setup complete ..."

if [ ! -d "$SNAP_USER_DATA/.config/autostart" ];
then
  mkdir -p $SNAP_USER_DATA/.config/autostart
  ln -sfnt $SNAP_USER_DATA/.config/autostart/ $SNAP/usr/share/applications/cluemaster-mediadisplay.desktop
fi

exec "$@"

I installed the snap on my Ubuntu core but it shows nothing just a black.

Thanks in advance.

you should monitor your journal while restarting the daemon, that should give you some hints about failures/issues …

Hi @ogra. Thanks for the reply. I got the following output when I ran

snap logs  cluemaster-mediadisplay

Output:

2021-09-01T12:09:04Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[572]: Prepairing launch ...
2021-09-01T12:09:04Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[572]: Environment variables setup complete ...
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: Failed to load client buffer integration: wayland-egl
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: qt.qpa.wayland: No shell integration named "xdg-shell" found
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: qt.qpa.wayland: No shell integration named "xdg-shell-v6" found
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: qt.qpa.wayland: No shell integration named "wl-shell" found
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: qt.qpa.wayland: No shell integration named "ivi-shell" found
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: qt.qpa.wayland: Loading shell integration failed.
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: qt.qpa.wayland: Attempted to load the following shells ("xdg-shell", "xdg-shell-v6", "wl-shell", "ivi-shell")
2021-09-01T12:09:06Z cluemaster-mediadisplay.cluemaster-mediadisplay-daemon[1277]: xkbcommon: ERROR: couldn't find a Compose file for locale "C.UTF-8"

hmm, is your ubuntu-frame (or mir-kiosk) up and running on that device ?

yes, the snap is running on the ubuntu core

which of the two are you using ?

I am using Mir-kiosk

Another point i forgot to mention is that, is tried this article : https://ubuntu.com/tutorials/wayland-kiosk#4-test-your-application-supports-wayland

And it worked. The app was running inside the container.

perhaps @alan_g has an idea here ?

Sorry, I don’t know much about PyQt: this looks like some “shell integration” components are missing from the snap, but I can’t point to what these are.

The fact that your application works when installed outside the snap indicates that it can find these components in that environment. Maybe you can find some clues by observing what it uses there?

The plugin referenced is provided by qtwayland. You may also need to point QT_PLUGIN_PATH to the right location.

QT_DEBUG_PLUGINS may help to pinpoint the problem.

I have converted my app into a X11 kiosk snap. And its working! Thanks for taking time to look into my issue. Here is the snapcraft.yaml : Cannot start snap, stuck after "Watches established"