The quest for building a plain wayland electron kiosk

Awesome, i can confirm scrolling works well on my test Pi4 now !!

1 Like

An ubuntu-frame build with Mir 2.5 is now on stable.

1 Like

Hi, any advice how to grant access to a serial-port? (my end goal is to use the webSerial Api)

I have added - serial-port to apps.electron-kiosk-wayland.plugs then after build/install I connect to serial port with snap connect electron-kiosk-wayland:serial-port snapd:ft232rusbuart

I can see serial port connected with snap connections electron-kiosk-wayland (see bellow) however when I try to make connection via JS serial is not accessible. navigator.serial is undefined

root@dev01:~/electron-kiosk-main# snap connections electron-kiosk-wayland
Interface                 Plug                                     Slot                             Notes
audio-playback            electron-kiosk-wayland:audio-playback    :audio-playback                  -
browser-support           electron-kiosk-wayland:browser-support   :browser-support                 -
content[gnome-3-38-2004]  electron-kiosk-wayland:gnome-3-38-2004   gnome-3-38-2004:gnome-3-38-2004  -
content[gtk-3-themes]     electron-kiosk-wayland:gtk-3-themes      gtk-common-themes:gtk-3-themes   -
content[icon-themes]      electron-kiosk-wayland:icon-themes       gtk-common-themes:icon-themes    -
content[sound-themes]     electron-kiosk-wayland:sound-themes      gtk-common-themes:sound-themes   -
desktop                   electron-kiosk-wayland:desktop           :desktop                         -
desktop-legacy            electron-kiosk-wayland:desktop-legacy    :desktop-legacy                  -
gsettings                 electron-kiosk-wayland:gsettings         :gsettings                       -
hardware-observe          electron-kiosk-wayland:hardware-observe  -                                -
network                   electron-kiosk-wayland:network           :network                         -
network-bind              electron-kiosk-wayland:network-bind      :network-bind                    -
opengl                    electron-kiosk-wayland:opengl            :opengl                          -
process-control           electron-kiosk-wayland:process-control   -                                -
serial-port               electron-kiosk-wayland:serial-port       :ft232rusbuart                   manual
wayland                   electron-kiosk-wayland:wayland           :wayland                         manual
x11                       electron-kiosk-wayland:x11               :x11                             -

I also added udev to stage-packages as described in this comment by @ogra Serial port access for private repository. navigator.serial is still undefined

Have you tried running a shell inside the snap environment to see if access to /dev/ttyUSBx is actually blocked? Do you get any apparmor denials when the app tries to access the serial port?

I can access the shell via sudo snap run --shell electron-kiosk-wayland then cat /dev/ttyUSB0 the correct output is shown (print output from scale)

I see a few apparmor="DENIED" however I do not think it is related to /dev/ttyUSB0 access (see logs bellow)

Apr  1 10:51:44 dev02 systemd[1]: Started Service for snap application electron-kiosk-wayland.electron-kiosk-wayland.
Apr  1 10:51:44 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8139]: MESA-LOADER: failed to retrieve device information
Apr  1 10:51:44 dev02 kernel: [ 1543.662324] kauditd_printk_skb: 59 callbacks suppressed
Apr  1 10:51:44 dev02 kernel: [ 1543.662330] audit: type=1400 audit(1680306704.920:445): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/sys/devices/platform/2300000.pci/pci0000:00/0000:00:0a.0/vendor" pid=8139 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:44 dev02 kernel: [ 1543.662334] audit: type=1400 audit(1680306704.924:446): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/sys/devices/platform/2300000.pci/pci0000:00/0000:00:0a.0/vendor" pid=8139 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:44 dev02 kernel: [ 1543.689464] audit: type=1400 audit(1680306704.948:447): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/sys/devices/platform/2300000.pci/pci0000:00/0000:00:0a.0/vendor" pid=8139 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:44 dev02 kernel: [ 1543.689506] audit: type=1400 audit(1680306704.948:448): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/sys/devices/platform/2300000.pci/pci0000:00/0000:00:0a.0/vendor" pid=8139 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:44 dev02 kernel: [ 1543.689638] audit: type=1400 audit(1680306704.948:449): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/sys/devices/platform/2300000.pci/pci0000:00/0000:00:0a.0/vendor" pid=8139 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:44 dev02 kernel: [ 1543.689696] audit: type=1400 audit(1680306704.948:450): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/sys/devices/platform/2300000.pci/pci0000:00/0000:00:0a.0/vendor" pid=8139 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:44 dev02 kernel: [ 1543.691784] audit: type=1326 audit(1680306704.952:451): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=8139 comm="electron-quick-" exe="/snap/electron-kiosk-wayland/x1/electron-helloworld/electron-quick-start" sig=0 arch=c00000b7 syscall=122 compat=0 ip=0xffffb998ec14 code=0x50000
Apr  1 10:51:45 dev02 kernel: [ 1543.755619] audit: type=1326 audit(1680306705.016:452): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=8139 comm="electron-quick-" exe="/snap/electron-kiosk-wayland/x1/electron-helloworld/electron-quick-start" sig=0 arch=c00000b7 syscall=274 compat=0 ip=0xffffb82128c4 code=0x50000
Apr  1 10:51:45 dev02 kernel: [ 1543.757647] audit: type=1400 audit(1680306705.016:453): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/proc/8164/mem" pid=8164 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:45 dev02 kernel: [ 1543.757808] audit: type=1400 audit(1680306705.016:454): apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/proc/8164/mem" pid=8164 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Apr  1 10:51:44 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8139]: message repeated 2 times: [ MESA-LOADER: failed to retrieve device information]
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8181]: MESA-LOADER: failed to retrieve device information
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8181]: message repeated 2 times: [ MESA-LOADER: failed to retrieve device information]
Apr  1 10:51:45 dev02 ubuntu-frame.daemon[3536]: [2023-04-01 10:51:45.228894] <information> frame: New surface for snap="electron-kiosk-wayland" with title="electron-quick-start"
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8181]: [8181:0401/105145.249718:ERROR:gl_display.cc(504)] EGL Driver message (Error) eglInitialize: DRI2: failed to find EGLDevice
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8181]: [8181:0401/105145.264689:ERROR:gpu_init.cc(523)] Passthrough is not supported, GL is egl, ANGLE is
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8181]: [8181:0401/105145.269150:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8213]: MESA-LOADER: failed to retrieve device information
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8213]: message repeated 2 times: [ MESA-LOADER: failed to retrieve device information]
Apr  1 10:51:45 dev02 electron-kiosk-wayland.electron-kiosk-wayland[8193]: [8193:0401/105145.308862:ERROR:command_buffer_proxy_impl.cc(128)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
Apr  1 10:51:45 dev02 ubuntu-frame.daemon[3536]: [2023-04-01 10:51:45.374029] <information> frame: Surface for snap="electron-kiosk-wayland" retitled to "RYW DMS" (was "electron-quick-start")

Yeah, so this is an application problem, not really one with the interface. Your app has access to the device… I’d start taking a look at the javascript console, perhaps you can make out something from there…

thanks @ogra I did have some issues re SSL and setDevicePermissionHandler. both resolved now. I can package electron and run locally (on a mac) and all works correctly.

however when I run as snap I now see the following apparmor error

AVC apparmor="DENIED" operation="open" profile="snap.electron-kiosk-wayland.electron-kiosk-wayland" name="/sys/devices/platform/2300000.pci/pci0000:00/0000:00:0a.0/vendor" pid=3016 comm="electron-quick-" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

I noticed your other comment here Raw-usb access to /sys/devices/platform/usb** re hardware-observe. From my snap connections output above it looks like hardware-observe is already connected.

I did try snap connect electron-kiosk-wayland:hardware-observe it made no difference

any other advice?

try adding and connecting the raw-usb plug too …

Thanks @ogra that worked!

for anyone else with a similar issue, changes needed to get serial access in electron-kiosk-wayland working are:

  1. add udev to parts.app.stage-packages
  2. add serial-port & raw-usb to apps.app.plugs
  3. after install add connections to hardware-observe, raw-usb & serial-port
snap connect electron-kiosk-wayland:hardware-observe
snap connect electron-kiosk-wayland:raw-usb
snap connect electron-kiosk-wayland:serial-port snapd:ft232rusbuart
1 Like