The quest for building a plain wayland electron kiosk

weird, then i dont get why you end up in the InitializeSandbox() function above … this is clearly not expected …

I don’t know about InitializeSandbox() - I’ve confirmed --no-sandbox is on the commandline.

The actual error seems to be an “unsupported buffer format”:

[88320:0927/114058.910335:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
[3146446.951]  -> zwp_linux_dmabuf_v1@6.create_params(new id zwp_linux_buffer_params_v1@30)
[3146446.987]  -> zwp_linux_buffer_params_v1@30.add(fd 108, 0, 0, 3200, 16777215, 4294967295)
[3146447.032]  -> zwp_linux_buffer_params_v1@30.create_immed(new id wl_buffer@29, 800, 600, 875708993, 0)
[3146447.142]  -> zwp_linux_dmabuf_v1@6.create_params(new id zwp_linux_buffer_params_v1@26)
[3146447.168]  -> zwp_linux_buffer_params_v1@26.add(fd 105, 0, 0, 3200, 16777215, 4294967295)
[3146447.204]  -> zwp_linux_buffer_params_v1@26.create_immed(new id wl_buffer@25, 800, error in client communication (pid 88279)
600, 875708993, 0)
[3146447.277]  -> zwp_linux_dmabuf_v1@6.create_params(new id zwp_linux_buffer_params_v1@23)
[3146447.300]  -> zwp_linux_buffer_params_v1@23.add(fd 106, 0, 0, 3200, 16777215, 4294967295)
[3146447.348]  -> zwp_linux_buffer_params_v1@23.create_immed(new id wl_buffer@22, 800, 600, 875708993, 0)
[3146447.495] wl_display@1.error(zwp_linux_buffer_params_v1@30, 4, "Client requested unsupported format/modifier combination DRM_FORMAT_ABGR8888/DRM_FORMAT_MOD_INVALID (875708993/16777215,4294967")
[88279:0927/114058.989256:ERROR:wayland_event_watcher.cc(249)] Fatal Wayland communication error: Connection reset by peer

Seems odd that that has changed since Friday.

1 Like

do you have a build log to see if the electron version changed perhaps ?

EDIT: found it !
… my code just re-purposes the electron-quick-start example … seems they bumped it from electron 14 to 15 …

:man_shrugging: you can reproduce now?

i wish i could try, seems the latest nvidia update broke qemu-virgil on my machine, but i’ll move the snap to use its own package.json and pin it to 14

You can test the graphics without a VM. See my earlier post for how:

Digging a bit further, electron is (as logged) requesting a modifier format of DRM_FORMAT_MOD_INVALID and Mir doesn’t recognize this as valid (it isn’t in the list Mir supplies). Mutter, on receiving the same request, carries on regardless.

I’ve experimented with hacking Mir to allow DRM_FORMAT_MOD_INVALID, and with that change this snap displays sensibly. (I’ll go read the protocol to see if this is actually a reasonable behavior.)

[update]

The specification of zwp_linux_buffer_params_v1.add says:

        Warning: It should be an error if the format/modifier pair was not
        advertised with the modifier event. This is not enforced yet because
        some implementations always accept DRM_FORMAT_MOD_INVALID. Also
        version 2 of this protocol does not have the modifier event.

Mir, unlike “some implementations”, is treating this as an error.

1 Like

I built the electron app outside of the snap. For anyone else who wants to do that:

$ npm install electron-packager
$ git clone git@github.com:electron/electron-quick-start.git
$ cd electron-quick-start
$ curl https://raw.githubusercontent.com/ogra1/electron-kiosk-wayland/main/electron/main.js > main.js
$ npx electron-packager . --overwrite --platform=linux --output=release-build --prune=true
$ SNAP_URL='https://ubuntu.com/' WAYLAND_DISPLAY=wayland-1 electron-quick-start-linux-x64/electron-quick-start --enable-features=UseOzonePlatform --ozone-platform=wayland --disable-dev-shm-usage --no-sandbox

This opens up the Ubuntu homepage in an Electron app running on wayland-1. Experimenting with this, I found that all we have to do to make scrolling work on Mir is send .axis_source(finger):

The protocol specifies .axis_source is optional, but it looks like Electron ignores non-discrete scrolling without it.

1 Like

And I found that .axis_source(wheel) also “works” (without axis_discrete()).

1 Like

Electron/Wayland now working with (pre-release) Mir

What electron is doing is technically wrong, but Mir can be accommodating.

The result of these investigations are reflected on Mir master and are available from the ubuntu-frame “edge” channel:

snap refresh --edge ubuntu-frame

These changes will be included in Mir 2.5. Once that has been released, they will be reflected in the “beta”, “candidate” then “stable” channels for ubuntu-frame.

References

3 Likes

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