Introducing wpe-webkit-mir-kiosk snap

I’ve been messing with this on my PI and it’s really cool – thanks for the hard work!

My question relates to performance. When on various web pages like youtube, it seems pretty laggy and web pages don’t seem to scroll all that smoothly. Youtube videos are also very laggy on my 1080p screen (even when playing the videos @ 480p).

This article seems to show the performance as being much better than what I’m getting on my PI, but they are using the WPE Webkit fork of build root to build a custom image.

https://medium.com/@decrocksam/building-wpe-webkit-for-raspberry-pi-3-cdbd7b5cb362

I’m using a PI 3 B+. Is something not working (i.e. hardware acceleration) in this snap, that might be working in the WPE Webkit buildroot image? Or is all of this just a limitation of the PI’s slow processor?

@tobias Would it be possible to add an arm64 build for the wpe-webkit-mir-kiosk? I was testing the armhf version and it seemed to work well, but needed to switch to arm64 due to issues with other parts of the application I’m building. snap refuses to install wpe-webkit-mir-kiosk on arm64 (Ubuntu Core).

I tried cloning the git repository and building it myself, but that was also not successful.

I added arm64 to the auto-build architectures and the build went through fine. It’s currently released in latest/candidate, please give it a try and let me know it everything works :slight_smile: Then I’ll promote it to stable.

May I ask in which environment you tried to clone and build the snap? (OS, snapcraft version, builder etc.)

Hi Zane, sorry for the extremely late reply! I was busy with other things again.

I haven’t really tested the snap on a Pi 3B+ yet, on a 3B it works quite ok. TBH, our application is a text-focused web app without user interaction, though we have a widget for video and it worked fine in our tests. Is your Pi connected via WiFi or Ethernet? I tested YouTube with the snap during development, but that was on an amd64 machine running Ubuntu Core, so performance is not really comparable.

The article you linked was my initial inspiration to get WPE working in a snap. If I recall correctly, the buildroot image uses the RDK backend while my snap uses the (official and most supported) FDO backend. Might be the root cause for performance disparity.

In any case, maybe I can find the time to investigate low-hanging fruits for performance improvements.

@tobias Thank you! I’ll test it later today.

On my system, it is failing with the following error. OS is Ubuntu 18.04.2 LTS. Snapcraft version is 3.6. I get the same error with either SNAPCRAFT_BUILD_ENVIRONMENT=host or SNAPCRAFT_BUILD_ENVIRONMENT=multipass. The only change I made was adding architectures to the snapcraft.yaml to build on all and run on arm64.

: fatal error: wpe/webkit.h: No such file or directory

include <wpe/webkit.h>

       ^~~~~~~~~~~~~~

compilation terminated.
ninja: build stopped: subcommand failed.
Failed to run ‘cmake --build . – -j4’ for ‘cog’: Exited with code 1.
Verify that the part is using the correct parameters and try again.

This sounds like the build-snap dependency wpe-webkit-libs cannot be found. I had to work around the issue in my post Cmake part with build-snaps gets mangled include parameters by manually setting WEB_ENGINE_INCLUDE_DIRS, because I couldn’t find where cmake gets those wrong include path parameters from.

I guess that when building on the host, $SNAPCRAFT_PART_INSTALL is either not set or points to the wrong directory, so cog cannot find the required libraries.

I haven’t tested native builds on the host, but in my trial runs it worked fine in a launchpass VM.

Thanks for following up!

Please leave it as edge/beta channel for now. It loads fine and displays the page, but there are css issues and double-click issues. I don’t recall any css problems when I was testing on the armhf version. I think I added double-click after I did the armhf testing. Once I figure out whether the error is on my end or in wpe-webkit, I’ll let you know.

Good to know! FYI: You can activate the remote inspector with snap set wpe-webkit-mir-kiosk devmode=true. When enabled, open any WebKitGTK browser (e.g. GNOME Web / Epiphany) and visit inspector://ip-or-hostname-of-your-device-running-wpe:8080.

Just tested this on a Ubuntu Core 18 running on a VM and it works great! Thanks a lot for this @tobias !!

1 Like

Hi, I tried to add a new ca-cert under /etc/ssl/certs/ca-certificates.crt as I found some references to wpe-webkit using this location, but I keep getting TLS error when talking to our internal web-server using this cert.
Is the wpe-webkit-mir-kiosk built to look for additional ca-certs in /etc/ssl/certs/ca-certificates.crt?

Hi, thanks for the feedback. As WebKit is running fully confined within this snap, access to the host’s /etc/... wouldn’t be allowed by snapd. I use snapd’s layout feature to map /etc/ssl (where WebKit expects certs) to $SNAP/etc/ssl, see snapcraft.yaml.

You can test if that is the issue:

  1. Download the current stable release of wpe-webkit-mir-kiosk: snap download wpe-webkit-mir-kiosk. Caution: if you’re on an amd64 machine, add --beta before the snap name as it’s not released to stable yet – see @dbraunschweig 's comment above.
  2. Run unsquashfs -d debug <snap-file-name>.snap → This will create a directory named debug in your current working directory, with the snap’s contents inside.
  3. snap try debug will mount the snap as usual and with full confinement, only that the debug directory is fully writable.
  4. Place your CA cert in debug/etc/ssl and test if it works now (maybe run snap restart wpe-webkit-mir-kiosk.browser to restart the browser)

If that resolves the issue, I see two ways to accommodate custom certificates in this snap:

  1. If WPE/WebKit supports additional lookup CA cert lookup paths through runtime parameters, we can add a configuration item to place the cert in $SNAP_DATA. I’ll have to look that up in the options or check back with the WK/WPE developers.
  2. If WK checks only one path, we could change the layout to point to $SNAP_DATA and move the default CA certificates there during snap installation via an install hook. Afterwards, you can move your custom certificate to this location from outside the snap. $SNAP_DATA is just a shorthand for /var/snap/<snap-name>/current/.

Please let me know if the steps above help. Please also note that wpe-webkit-mir-kiosk is just a side-product of my main job, so I can’t promise a timeframe or really anything except good intentions :smile: Also, (pull/merge) requests are welcome.

3 Likes

Hi Tobias,

Works great on Ubuntu core.
I’m trying to run this snap on Ubuntu server on Raspberry Pi. Installs fine, but if I run mir-kiosk all I get is an empty screen with mouse pointer.

What is the proper way to start it?

Excuse me for the newbie question.

Unfortunately this did not help. mir-kiosk starts automatically, but again, all I see is a black screen with mouse pointer. journalctl shows the following:
Dec 11 18:59:55 u1804wpesnap cog[2993]: Platform setup failed: Could not open Wayland display
Dec 11 18:59:55 u1804wpesnap cog[2993]: WebKitWebViewBackend* webkit_web_view_backend_new(wpe_view_backend*, GDestroyNo$
Dec 11 18:59:55 u1804wpesnap cog[2993]: Could not instantiate any WPE backend.
Dec 11 18:59:55 u1804wpesnap wpe-webkit-mir-kiosk.browser[2668]: /snap/wpe-webkit-mir-kiosk/26/bin/launch-wpe: line 29:$
Dec 11 18:59:55 u1804wpesnap systemd[1]: snap.wpe-webkit-mir-kiosk.browser.service: Main process exited, code=exited, s$
Dec 11 18:59:55 u1804wpesnap systemd[1]: snap.wpe-webkit-mir-kiosk.browser.service: Failed with result ‘exit-code’.
Dec 11 18:59:56 u1804wpesnap systemd[1]: snap.wpe-webkit-mir-kiosk.browser.service: Service hold-off time over, schedul$
Dec 11 18:59:56 u1804wpesnap systemd[1]: snap.wpe-webkit-mir-kiosk.browser.service: Scheduled restart job, restart coun$
Dec 11 18:59:56 u1804wpesnap systemd[1]: Stopped Service for snap application wpe-webkit-mir-kiosk.browser.
Dec 11 18:59:56 u1804wpesnap systemd[1]: Started Service for snap application wpe-webkit-mir-kiosk.browser.
Dec 11 19:00:22 u1804wpesnap wpe-webkit-mir-kiosk.browser[3038]: realpath: ‘’: No such file or directory

This is the problem. The question is “why?”

You say that mir-kiosk is running and displaying black screen with a cursor. So the socket needed by wpe-webkit-mir-kiosk should exist.

You can confirm that by looking for /run/user/0/wayland-0:

sudo find /run/user/0

Assuming the socket exists, the question is “why does wpe-webkit-mir-kiosk fail to open it?”.

Can you check dmesg?

dmesg | grep wpe-webkit-mir-kiosk

I suspect the reason will be an AppArmor “DENIED” when opening the file (because I can’t think of another reason). If that guess is right, check the wpe-webkit-mir-kiosk connections:

snap connections wpe-webkit-mir-kiosk

And make sure the “wayland” interface is connected. If not, connect it:

snap connect wpe-webkit-mir-kiosk:wayland

And try again:

snap restart wpe-webkit-mir-kiosk

Thanks for helping me with this, here are the results of the checks I made, based on your suggestions:

  • /run/user/0/wayland-0 is there
  • no entries containing “Denied” in dmseg, quite a lot containing “Allowed”
  • wayland interface connection is there

My environment is a clean ubuntu 18.04.3 64 bit server installation, running on VirtualBox vm with mir-kiosk and wpe-webkit-mir-kiosk (beta) snaps installed.

is there any particular reason that you require the server edition ? (just asking because the mir+wpe kiosk setup is a lot easier and simpler on ubuntu core, if you do not actually require particular features of server i’d consider switching over if i was you :slight_smile: )

Well, my end goal is to be able to run it on Raspbian lite on RPI 3/4. And so far I see similar behavior there and on Ubuntu server. But Ubuntu server running on a PC is way faster and much more convenient and I use it for troubleshooting.

I know this is Ubuntu Desktop, not Ubuntu Server. But the differences in running snaps are mostly between “Core” and “Classic” system, so this discussion (especially the final recipe) might help:

Still the same. I read somewhere that the WAYLAND_DIPLSAY environment variable may not be set and causing this problem.