Error When Snapped A App Using xwayland-kiosk-helper and snapcraft-desktop-helpers

In short, I’m trying to build a snap from my electron app,

first, I’m using this tutorial :
https://tutorials.ubuntu.com/tutorial/electron-kiosk#2
it’s successfully compiled, and running and showing in mir-kiosk vt4, but when I want to input it with keyboard, it’s error, blank screen, restart again, input keyboard again, blank screen, restart again, and so on…

until finally I decide to compile my electron app to deb first and using .deb for snapcraft,
with https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml and https://github.com/MirServer/xwayland-kiosk-helper, next combine the repo files, with basic X11-based kiosk app like in this tutorial (https://tutorials.ubuntu.com/tutorial/x11-kiosk#8),
I try make a configuration for snapcraft.yaml is like this :

name: app-kiosk-snap
version: 1
summary: app Kiosk Snap
description: |
  App Kiosk Snap

confinement: strict

apps:
  app-kiosk-snap:
    daemon: simple
    restart-condition: always
    command: "desktop-launch xwayland-kiosk-launch $SNAP/opt/app-kiosk/app-kiosk"
    environment:
      XWAYLAND_FULLSCREEN_WINDOW_HINT: 'class="app-kiosk"'
    slots: [ x11 ]
    plugs:
    - browser-sandbox
    - network
    - network-bind
    - opengl
    - pulseaudio
    - wayland
    - x11-plug

plugs:
  browser-sandbox:
    interface: browser-support
    allow-sandbox: true
  x11-plug: 
    interface: x11

parts:
  app-kiosk:
    plugin: dump
    source: debian/app-kiosk_1.0.0_amd64.deb
    source-type: deb
    after: [desktop-gtk2,xwayland-kiosk-helper,app-terminal]
    stage-packages:
      - libasound2
      - libgconf2-4
      - libnotify4
      - libnspr4
      - libnss3
      - libpcre3
      - libpulse0
      - libxss1
      - libxtst6
  app-terminal:
    plugin: dump
    source: debian/app-terminal-0.26.12-linux-amd64.deb
    source-type: deb
    after: [desktop-gtk2,xwayland-kiosk-helper]
    stage-packages:
      - libasound2
      - libgconf2-4
      - libnotify4
      - libnspr4
      - libnss3
      - libpcre3
      - libpulse0
      - libxss1
      - libxtst6
  xwayland-kiosk-helper:
    plugin: cmake
    source: xwayland-preload
    after: [desktop-gtk2]
    build-packages:
      - build-essential
    stage-packages:
      - xwayland
      - i3
      - libegl1-mesa
      - libgl1-mesa-glx
    stage:
      - -lib/libxwayland-preload.so
  desktop:
    plugin: nil
  gtk2:
    source: .
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk2"]
    build-packages:
      - libgtk2.0-dev
    stage-packages:
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libgtk2.0-0
      - libgdk-pixbuf2.0-0
      - libglib2.0-bin
      - libgtk2.0-bin
      - unity-gtk2-module
      - libappindicator1
      - locales-all
      - ibus-gtk
      - libibus-1.0-5
  desktop-gtk2:
    source: .
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk2"]
    build-packages:
      - build-essential
      - libgtk2.0-dev
    stage-packages:
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libgtk2.0-0
      - libgdk-pixbuf2.0-0
      - libglib2.0-bin
      - libgtk2.0-bin
      - unity-gtk2-module
      - locales-all
      - libappindicator1
      - xdg-user-dirs
      - ibus-gtk
      - libibus-1.0-5

I install it with snap install --dangerous --devmode ./app-kiosk-snap.snap

but it’s return error that gtk2 not support wayland :
like this the snap logs app-kiosk-snap

2019-01-06T04:18:57Z app-kiosk-snap.app-kiosk-snap[16687]: Warning: GTK2 does not support Wayland!
2019-01-06T04:18:57Z systemd[1]: snap.app-kiosk-snap.app-kiosk-snap.service: Main process exited, code=exited, status=1/FAILURE
2019-01-06T04:18:57Z systemd[1]: snap.app-kiosk-snap.app-kiosk-snap.service: Failed with result 'exit-code'.
2019-01-06T04:18:57Z systemd[1]: snap.app-kiosk-snap.app-kiosk-snap.service: Service hold-off time over, scheduling restart.
2019-01-06T04:18:57Z systemd[1]: snap.app-kiosk-snap.app-kiosk-snap.service: Scheduled restart job, restart counter is at 55.
2019-01-06T04:18:57Z systemd[1]: Stopped Service for snap application app-kiosk-snap.app-kiosk-snap.
2019-01-06T04:18:57Z systemd[1]: snap.app-kiosk-snap.app-kiosk-snap.service: Start request repeated too quickly.
2019-01-06T04:18:57Z systemd[1]: snap.app-kiosk-snap.app-kiosk-snap.service: Failed with result 'exit-code'.
2019-01-06T04:18:57Z systemd[1]: Failed to start Service for snap application app-kiosk-snap.app-kiosk-snap.

Anyone can help me resolve this issue? I’m using electronjs app compile it to deb, and use the deb to be installed in snap

mention :
@alan_g and @greyback

Edited:
FYI: in Ubuntu Desktop 1804, the app-kiosk and app-terminal is successfully running,
and I try using miral (Mir on X) like :

miral-app -kiosk -launcher 'Xwayland -wr :1'
DISPLAY=:1 app-kiosk
DISPLAY=:1 app-terminal

It’s successfuly running too…

What is the error? Is it in Mir? Or in your app?

@alan_g I don’t know yet, I think it’s xwayland problem…

it’s work well when no input, but when I have to input username n password using keyboard, it’s restarted, and go to homepage again,
when I compile and install deb it’s work well , snap it without xwayland-kiosk-launch (not kiosk app) it’s work well too…
And when I running using Mir on X, it’s work well too…
I think the problem is in desktop-launch / xwayland-kiosk-launch (xwayland / desktop-gtk2)
But I’m not sure either…