Wpe-webkit-mir-kiosk restart after `mir-kiosk` refresh

Use case

I’m building a kiosk-style appliance which uses Canonical’s mir-kiosk snap as a base for my wpe-webkit-mir-kiosk browser snap. The appliance doesn’t have any keyboard attached, and does not use a GUI desktop.

Problem statement

Every time mir-kiosk is refreshed, the display server is restarted and thus our browser snap temporarily loses the display context, resulting in a black screen. That is expected and how snap refreshes work, but it leaves the browser in a defunct state even after mir-kiosk comes back up. Restarting the browser snap manually (snap restart or a complete system reboot) resolves the issue, but this is not very user-friendly for appliance-style use cases.

Prior to building the WPE snap, I experimented with Canonical’s PoC chromium-mir-kiosk snap (now deprecated). Chromium shuts down when the display context goes away, which means I could just use the restart-condition handler provided by snapd (thread, contrib on Launchpad). This doesn’t work with WPE however; it just reports that the [wayland?] output was removed:

Debug settings:

  export G_MESSAGES_DEBUG=all
  export LIBGL_DEBUG=verbose
  export WAYLAND_DEBUG=1


2020-04-20T08:59:13Z -[24019]: received frame 1 with 36 payload
2020-04-20T08:59:13Z -[24019]: message: delivering 1 with 36 length
# I run snap restart mir-kiosk
2020-04-20T08:59:14Z -[24009]: Removed output 5 # <<---
2020-04-20T08:59:16Z -[24019]: received frame 1 with 36 payload
2020-04-20T08:59:16Z -[24019]: message: delivering 1 with 36 length
2020-04-20T08:59:19Z -[24019]: received frame 1 with 36 payload
2020-04-20T08:59:19Z -[24019]: message: delivering 1 with 36 length
2020-04-20T08:59:22Z -[24019]: received frame 1 with 36 payload
2020-04-20T08:59:22Z -[24019]: message: delivering 1 with 36 length
2020-04-20T08:59:25Z -[24019]: received frame 1 with 36 payload

Am I missing something obvious? I looked through WebKit’s build flags and mir-kiosk’s configuration options, but can’t find a clue to what might be a proper fix for this. Any ideas welcome :smile:

Well, while this smells like a bug in wpe to me … as a hackish workaround you could seed inotify-tools and have a “daemon watchdog shell script” using inotifywait that uses snapctl stop / snapctl start to forcefully restart the browser if the socket went away.

1 Like

Thanks! I’ll try that. For reference, I asked WPE developers on IRC (#webkit @ freenode) about this and they asked me to file an issue with cog, the reference web app container for WPE WebKit. Please do chime in if I missed something.

1 Like