Desktop screen shot for mir-kiosk

Hi,

I have created an electron app that can take a desktop screenshot. It was working fine. Now I am trying to make an ubuntu core 20 according to https://github.com/ogra1/electron-kiosk-uc20.

But the screenshot taken is all black.

This is the UC18 snap (working desktop capture) sudo snap install pam-app --channel=latest/edge --devmode

$ sudo snap connections pam-app
Interface                 Plug                     Slot                             Notes
content[gnome-3-28-1804]  pam-app:gnome-3-28-1804  gnome-3-28-1804:gnome-3-28-1804  -
content[gtk-3-themes]     pam-app:gtk-3-themes     gtk-common-themes:gtk-3-themes   -
content[icon-themes]      pam-app:icon-themes      gtk-common-themes:icon-themes    -
content[sound-themes]     pam-app:sound-themes     gtk-common-themes:sound-themes   -
desktop                   pam-app:desktop          -                                -
desktop-legacy            pam-app:desktop-legacy   -                                -
gsettings                 pam-app:gsettings        -                                -
network                   pam-app:network          :network                         -
network-bind              pam-app:network-bind     :network-bind                    -
opengl                    pam-app:opengl           :opengl                          -
pulseaudio                pam-app:pulseaudio       -                                -
wayland                   pam-app:wayland          ubuntu-frame:wayland             -
x11                       pam-app:x11              -                                -

The UC20 snap

~$ sudo snap connections pam-app
Interface                 Plug                      Slot                             Notes
audio-playback            pam-app:audio-playback    -                                -
browser-support           pam-app:browser-support   :browser-support                 -
content[gnome-3-38-2004]  pam-app:gnome-3-38-2004   gnome-3-38-2004:gnome-3-38-2004  -
content[gtk-3-themes]     pam-app:gtk-3-themes      gtk-common-themes:gtk-3-themes   -
content[icon-themes]      pam-app:icon-themes       gtk-common-themes:icon-themes    -
content[sound-themes]     pam-app:sound-themes      gtk-common-themes:sound-themes   -
desktop                   pam-app:desktop           -                                -
desktop-legacy            pam-app:desktop-legacy    -                                -
gsettings                 pam-app:gsettings         -                                -
hardware-observe          pam-app:hardware-observe  -                                -
network                   pam-app:network           :network                         -
network-bind              pam-app:network-bind      :network-bind                    -
network-observe           pam-app:network-observe   -                                -
opengl                    pam-app:opengl            :opengl                          -
process-control           pam-app:process-control   -                                -
wayland                   pam-app:wayland           ubuntu-frame:wayland             -
x11                       pam-app:x11               -                                -

adding screencast-legacy made no differece

That’s what I’d expect.

You’re connecting your app to an X11 server (Xwayland) contained in the snap. The only client that server knows is your application, so when you capture the desktop from that X11 server there’s nothing to see.

How do I get around it? It did work before, using on core18 with https://github.com/MirServer/xwayland-kiosk-helper/tree/master

I have tried using wayland only https://github.com/ogra1/electron-kiosk-wayland

[38426:1110/211715.643887:ERROR:shared_x_display.cc(38)] Unable to open display

Is this because it is trying to use X11? Since there is none, it gives this error.

What else should I do?

Are you actually trying to create an IoT snap for use with Mir kiosk? Or a desktop snap for use with X11 based desktops?

The only way that X11 based screenshotting can work is by using X11 to connect to the desktop you want to screenshot. You can’t do that with ubuntu-frame or mir-kiosk as both are Wayland only. (As remarked above, using Xwayland as an intermediary doesn’t help for screenshotting.)

Some Wayland servers offer extensions for screenshotting, but that is not yet implemented by Mir, so that won’t work either.

An IoT snap with mir-kiosk for digital signage

But I did get the screen shot to work before. The only problem now is the new build stopped working. I don’t know why

name: pam-app
version: VERSION
summary: Digital signage app
description: Digital signage app
base: core18
confinement: strict
grade: devel
compression: lzo

apps:
  pam-app:
    daemon: simple
    stop-timeout: 1m
    extensions: [gnome-3-28]
    restart-condition: always
    command: snap/command-chain/desktop-launch xwayland-kiosk-launch $SNAP/pam/PAMApp --no-sandbox
    plugs:
      - network
      - network-bind
      - opengl
      - pulseaudio
      - wayland

layout:
  /usr/share/fonts:
    bind: $SNAP/usr/share/fonts

environment:
  XWAYLAND_FULLSCREEN_WINDOW_HINT: window_role="browser-window"

parts:
  pam-app-source:
    plugin: nil
    source: out
    override-build: |
      mkdir -p $SNAPCRAFT_PART_INSTALL/pam
      cp -R PAMApp-linux-x64/* $SNAPCRAFT_PART_INSTALL/pam
    stage-packages:
      - libnspr4
      - libasound2
      - libgconf-2-4
      - libnss3
      - libx11-xcb1
      - libxss1
      - libxtst6
    build-snaps:
      - node/14/stable

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

I don’t know why you think it worked: There is no support for screenshotting in mir-kiosk.

:man_shrugging:

while you can use the screencast-legacy interface to capture screenshots in a classic gnome desktop wayland session, the needed server side support might be missing in ubuntu-frame/mir-kiosk …