Electron kiosk snap won't run

Hi, I’m trying to follow the tutorial to snap the hello world Electron app. It worked fine up to step 3 (got the Electron app running on Ubuntu Classic), but after step 4 (convert into a kiosk app) the snap won’t run on either Ubuntu Classic (on my desktop) or Ubuntu Core (an armhf build running on a
Raspberry Pi 3).

Ubuntu Classic

On Ubuntu Classic the issue seems to be that it can’t find a Wayland socket, but the suggested fix for this doesn’t seem to work. One thing that isn’t clear to me from the tutorial is whether on Ubuntu Classic miral-kiosk and the electron-hello-world-kiosk apps should be running as root or my user, but no combination seems to work.

If I run the electron app as my user I get:

/snap/electron-hello-world-kiosk/x2/bin/xwayland-kiosk-launch: line 117: /var/snap/electron-hello-world-kiosk/x2/i3.config: Permission denied

and if I run it with sudo I get:

Error: Unable to find a valid Wayland socket in /run/user/0

Ubuntu Core

On Ubuntu Core if I run it as my user I get:

Error: Unable to find a valid Wayland socket in /run/user/1000
Is a Wayland server running?
You could try running as root

and if I run it with sudo I get:

[18706:0720/112140.582507:FATAL:atom_main_delegate.cc(194)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
/snap/electron-hello-world-kiosk/x1/bin/xwayland-kiosk-launch: line 151: 18706 Trace/breakpoint trap   "$@"
/snap/electron-hello-world-kiosk/x1/bin/xwayland-kiosk-launch: line 1: kill: (-18140) - No such process

I’m wondering if there’s some mismatch of user id between the Wayland socket and the Electron snap, but I’m a bit lost to be honest.

If it helps, here are links to the snapcraft.yaml and the amd64 & armhf builds:

Note that I had to add unzip to build-packages to get it to build, which isn’t mentioned in the tutorial.

Hi @benfrancis,

The kiosk set up runs the apps as snap services, meaning they run as root. The tutorials are written with that assumption. So running “as your user” is not working by design at the moment.

Can you confirm mir-kiosk is running on your devices? journalctl -u snap.mir-kiosk* can give you a hint why, if it is not.

@Saviq thanks for responding. Below is the output of ps and journalctl.

$ ps aux | grep mir-kiosk

root       855  2.1  4.1 162600 39192 ?        Ssl  18:33   0:07 /snap/mir-kiosk/1892/usr/bin/miral-kiosk
benfran+  9561  0.0  0.0   3864   524 pts/0    S+   18:39   0:00 grep --color=auto mir-kiosk

$ sudo journalctl -u snap.mir-kiosk*

-- Logs begin at Thu 2019-07-25 18:31:45 UTC, end at Thu 2019-07-25 18:35:37 UTC. --
Jul 25 18:33:19 localhost systemd[1]: Started Service for snap application mir-kiosk.mir-kiosk.
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.170411] <information> mirserver: Starting
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.174181] < - debug - > mirserver: Using Linux VT subsystem for sessi
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.175188] <information> mircommon: Loading modules from: /snap/mir-ki
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.175455] <information> mircommon: Loading module: /snap/mir-kiosk/18
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.175581] <information> mircommon: Loading module: /snap/mir-kiosk/18
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.175643] <information> mircommon: Loading module: /snap/mir-kiosk/18
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.185726] <information> mesa-kms: EGL platform does not support EGL_K
Jul 25 18:33:45 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:45.186905] < -warning- > mesa-kms: Failed to detect whether device /de
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.246650] <information> mirplatform: Found graphics driver: mir:mesa-
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.290719] <information> mirplatform: Found graphics driver: mir:mesa-
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.291810] <information> mirserver: Selected driver: mir:mesa-kms (ver
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.293967] < -warning- > mesa-kms: Failed to detect whether device /de
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.294141] <information> mesa-kms: Using DRM device /dev/dri/card0
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.313560] < - debug - > mesa-kms: No EDID data available on connector
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.313725] < -warning- > mesa-kms: Unable to determine the current dis
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.319186] <information> mesa-kms: DRM device details:
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.319419] <information> mesa-kms: /dev/dri/card0: using driver vc4 [B
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.319629] <information> mesa-kms:         Output: HDMI-A-1 (connected
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.319689] <information> mesa-kms:                 Mode: 1360×768@59.9
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.319774] < - debug - > miral: Display config using layout: 'default'
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.320072] <information> miral: Display config:
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: 8>< ---------------------------------------------------
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: layouts:
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: # keys here are layout labels (used for atomically switching between them)
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: # when enabling displays, surfaces should be matched in reverse recency order
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:   default:                         # the default layout
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:     cards:
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:     # a list of cards (currently matched by card-id)
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:     - card-id: 0
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:       HDMI-A-1:
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         # This output supports the following modes: 1360x768@59.9
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         #
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         # Uncomment the following to enforce the selected configuration.
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         # Or amend as desired.
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         #
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         # state: enabled        # {enabled, disabled}, defaults to enabled
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         # mode: 1360x768@59.9        # Defaults to preferred mode
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         # position: [0, 0]        # Defaults to [0, 0]
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]:         # orientation: normal        # {normal, left, right, inverted}, defaults to norm
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: 8>< ---------------------------------------------------
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.320593] < -warning- > mesa-kms: drmModeCrtcSetGamma failed: Functio
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.380125] <information> mesa-kms: Detected single-GPU DisplayBuffer. 
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.419929] <information> mirserver: Using hardware cursor
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.493508] <information> mircommon: Loading modules from: /snap/mir-ki
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.494879] <information> mircommon: Loading module: /snap/mir-kiosk/18
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.495690] <information> mircommon: Loading module: /snap/mir-kiosk/18
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.496457] <information> mircommon: Loading module: /snap/mir-kiosk/18
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.528907] <information> mirserver: Selected input driver: mir:evdev-i
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.529933] <information> mesa-buffer-allocator: Bound WaylandAllocator
Jul 25 18:33:50 localhost mir-kiosk.mir-kiosk[855]: [2019-07-25 18:33:50.530044] < -warning- > mirserver: Cannot set Wayland protocol filter

You cropped a bit of output on the right, but from what I can see above at least mir-kiosk is running fine.

Can you see an orange fade-out when the device boots? Can you see a mouse cursor when moving a mouse? Can you see wayland-* files in /run/0/?

On Ubuntu Classic the mir-kiosk snap needs to be installed with --devmode to work “as intended” but, as it takes over the display, this isn’t a very convenient way to run things during development.

I’d recommend using this approach when testing your snap on desktop:

Just a sidenote … beyond the missing unzip in build-packages, the snapcraft.yaml at:

also does not have

    daemon: simple

set for the application … so this can not really work …

EDIT: oops, ignore that, there is a second step to turn it into a kiosk app later in the tutorial (this is really confusing, especially since the first one can not really work on core)

Actually I didn’t crop it, that’s how it appeared in the terminal.

Yes

In /run/user/0 I can:

root@localhost:~# ls /run/user/0/
snap.electron-hello-world-kiosk  wayland-0  wayland-0.lock

Hmm, I don’t think I have the mir-kiosk snap installed on desktop. I followed the instructions in the Wayland kiosk tutorial which the X11 kiosk and Electron kiosk tutorials build upon. That includes installing these apt packages:

$ sudo apt install mir-demos mir-graphics-drivers-desktop

And later running miral-kiosk:

$ miral-kiosk&

By the time you’ve made it through those three tutorials it’s all quite confusing so I wouldn’t be surprised if I’m doing something wrong. It would be easier to follow if the Electron kiosk tutorial just stood alone and only covered the steps needed for an Electron kiosk.

This isn’t a huge problem for me because I have two monitors plugged into my desktop PC.

for the tutorial issues i have filed:

Thanks very much for filing that @ogra. The updated tutorial doesn’t seem to have landed on tutorials.ubuntu.com yet, but following the updates that were made in the PR I was able to get this to work.

Side note: I do feel I need to dig a bit more into the security implications of Electron running as root with Chromium’s sandbox turned off as that seems like a problem for the real application I want to snap!

This should not be any problem given you are running under snap confinement. The kernel will take care of your security via apparmor, seccomp filtering, cgroups and namespaces. All you have done is to drop a duplicate sandbox running inside another one. If you run on core in some kind of appliance image you typically wont even have a user on the system anyway.

Hi guys,

I am trying make a python app run on mir-kiosk. I am very close and maybe you can help me. Here is my yaml:

name: pygame-demo
version: '0.0.1'
summary: Demo of using frame buffer from snappy

description: |
    PyGame bouncing ball on a snappy package
base: core18
confinement: devmode

layout:
    /usr/share/X11:
        bind: $SNAP/usr/share/X11
    /usr/share/tcltk:
        bind: $SNAP/usr/share/tcltk
    /usr/lib/tcltk:
        bind: $SNAP/usr/lib/tcltk

parts:
    xwayland-kiosk-helper:
        plugin: cmake
        source: https://github.com/MirServer/xwayland-kiosk-helper.git
        build-packages: [ build-essential ]
        stage-packages: [ xwayland, i3, libegl1-mesa ]

    pygame-demo:
        plugin: python
        python-version: python3
        source: .
        stage-packages: 
            - python3-tk

environment:
      XWAYLAND_FULLSCREEN_WINDOW_HINT: title="tk"

apps:
    pygame-demo:
        command: xwayland-kiosk-launch bin/pygame
        plugs:
        - wayland

I can run the example with glxgears. I get the following error though when I run: /snap/pygame-demo/x28/bin/xwayland-kiosk-launch: line 151: bin/pygame: No such file or directory

The launcher seems to look for the app run script in : /snap/pygame-demo/x28/usr/bin

But following the python snap tutorial: (https://snapcraft.io/docs/python-apps), the script is actually in: /snap/pygame-demo/x28/bin

I am having difficulty combining the two ideas.

Any help ?

Thanks in advance :slight_smile:

One reliable way would be to use an absolute path like $SNAP/bin/pygame.

Thank worked!! Thank u soo much

Hi @Saviq,

Looking for a bit more help. I have just included the layout and the parts involved.

Basically, I am trying to build pygame. It needs the sdl2-config file which it tries to find in /usr/bin/sdl2-config. So, what I tried to do is add a layout to bind the file. Nonetheless, it fails to find the file.

What I think might be possible issues:

  1. The layout is applied after the all the part is built ?
  2. Or stage-packages happens after python-packages ?
  3. The config file from pygame cannot use the binding for some reason.

Do u think any of these are reasonable ? And any suggestion ? Thanks in advance!

layout:
    /usr/bin/sdl2-config:
        bind-file: $SNAP/usr/bin/sdl2-config
parts:
    pygame-demo:
        plugin: python
        python-version: python3
        source: .
        python-packages: [pygame]
        stage-packages: [ libfreetype6-dev, libsdl2-dev ]

Hi @saiftyfirst, sorry for the late reply.

Layouts are only applied on an installed snap, not during building. If it’s a binary to be called, you should set your $PATH correctly, rather than using a layout, too.

Have a look at snapcraft-desktop-helpers, they should be helpful in setting up the environment.

Any case, it’d be helpful if you’d provide the error message, ideally the snapcraft.yaml, too, if possible.

@Saviq: I don’t suppose you have any advice on how this example might be made to work as the snap_daemon user rather than root, as I’m being asked to do in order to pass snap store review here? Are you aware of anyone getting xwayland-kiosk-launch to run as a non-root user?