canonical / iot-example-graphical-snap

Developer Guide for Embedding IoT GUI with Ubuntu Frame
MIT License
22 stars 11 forks source link

Electron-quick-start Snap Doesn't Run on Raspberry Pi 4 #8

Closed sambshapiro closed 1 year ago

sambshapiro commented 1 year ago

I'm following the tutorial here: https://discourse.ubuntu.com/t/packaging-an-electron-application-quick-start-as-an-iot-gui/29078

I have Ubuntu Desktop running on a Raspberry Pi 4. I was successfully able to get get a sample Electron app running within Ubuntu frame without being packaged into a snap. (Note that I was only successful here using the --platform-display-libs mir:x11 --platform-rendering-libs mir:x11 flags).

However, when I do the following set of steps to try to package & run the snap in Ubuntu Frame, the snap doesn't seem to ever run:

  1. export WAYLAND_DISPLAY=wayland-99
  2. ubuntu-frame --platform-display-libs mir:x11 --platform-rendering-libs mir:x11 &
  3. git clone https://github.com/MirServer/iot-example-graphical-snap.git
  4. cd iot-example-graphical-snap
  5. git branch -a
  6. git checkout Electron-quick-start
  7. snapcraft --use-lxd. (The reason I use lxd is because, without that flag, I get the following error: Unable to find an image matching "core20". Please use multipass find for supported remotes and images. - multipass find doesn't show core20).
  8. sudo snap install --dangerous *.snap
  9. sudo snap run iot-example-graphical-snap

This only ever results in:

$ sudo snap run iot-example-graphical-snap
Setting up watches.
Watches established.
|

And nothing else... Any idea what could be going on here? I am new to Ubuntu Frame and snaps generally.

AlanGriffiths commented 1 year ago

And nothing else... Any idea what could be going on here?

Yes, you're trying to run iot-example-graphical-snap as root, which means it cannot find the Ubuntu Frame running in your user session.

Try snap run iot-example-graphical-snap

Note that I was only successful here using the --platform-display-libs mir:x11 --platform-rendering-libs mir:x11 flags

You've clearly found a workaround for problems here, but could you share a console log from the failure without these flags? I'd like to see if we can improve things for the future.

sambshapiro commented 1 year ago

Try snap run iot-example-graphical-snap

When I try this, I get a permission denied error:

sam@grounded-rpi-1:~/Repositories/iot-example-graphical-snap$ snap run iot-example-graphical-snap
/snap/iot-example-graphical-snap/x1/usr/bin/wrapper: 7: exec: /snap/iot-example-graphical-snap/x1/electron-helloworld/electron-quick-start: Permission denied
sam@grounded-rpi-1:~/Repositories/iot-example-graphical-snap$ ls -la /snap/iot-example-graphical-snap/x1/
total 4
drwxr-xr-x 8 root root  123 Nov 18 10:12 .
drwxr-xr-x 3 root root 4096 Nov 18 10:31 ..
drwxrwxr-x 2 root root   72 Nov 18 10:12 bin
drwx------ 4 root root  517 Nov 17 16:15 electron-helloworld
drwxrwxr-x 7 root root   81 Nov 18 10:12 etc
drwxr-xr-x 3 root root   45 Nov 17 16:17 meta
drwxr-xr-x 4 root root   49 Nov 17 16:17 snap
drwxr-xr-x 7 root root  101 Nov 18 10:10 usr
sam@grounded-rpi-1:~/Repositories/iot-example-graphical-snap$ sudo chmod 777 /snap/iot-example-graphical-snap/x1/electron-helloworld/
chmod: changing permissions of '/snap/iot-example-graphical-snap/x1/electron-helloworld/': Read-only file system

You've clearly found a workaround for problems here, but could you share a console log from the failure without these flags? I'd like to see if we can improve things for the future.

Sure, here are the logs when I run ubuntu-frame without the extra flags:

sam@grounded-rpi-1:~/Repositories/iot-example-graphical-snap$ ubuntu-frame &
[1] 4946
sam@grounded-rpi-1:~/Repositories/iot-example-graphical-snap$ + [ /snap/ubuntu-frame/3901/bin/run-frame = --help ]
+ mkdir -p /home/sam/snap/ubuntu-frame/3901/.config/
+ grep -vE (^vt=|^console-provider=vt|^display-layout=) /var/snap/ubuntu-frame/3901/frame.config
+ exec /snap/ubuntu-frame/3901/bin/run-frame /snap/ubuntu-frame/3901/usr/local/bin/frame
+ [ /snap/ubuntu-frame/3901/usr/local/bin/frame = --help ]
+ dirname /run/user/1000/snap.ubuntu-frame
+ XDG_RUNTIME_DIR=/run/user/1000
+ export XDG_RUNTIME_DIR
+ mkdir -p /run/user/1000 -m 700
+ [ -n wayland-99 ]
+ [ -e /run/user/1000/wayland-99 ]
+ exec /snap/ubuntu-frame/3901/usr/local/bin/frame
[2022-11-18 10:05:33.159078] <information> mirserver: Starting
[2022-11-18 10:05:33.160191] < - debug - > mirserver: Not trying logind: "DISPLAY" is set and X need not have claimed the VT
[2022-11-18 10:05:33.160690] < - debug - > mirserver: Not using Linux VT subsystem for session management: Failed to mute keyboard
[2022-11-18 10:05:33.160783] < - debug - > mirserver: No session management supported
[2022-11-18 10:05:33.160853] <information> VT switch key handler: No VT switching support available: MinimalConsoleServices does not support VT switching
[2022-11-18 10:05:33.161329] <information> mircommon: Loading modules from: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform
[2022-11-18 10:05:33.161552] <information> mircommon: Loading module: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform/graphics-gbm-kms.so.20
[2022-11-18 10:05:33.161636] <information> mircommon: Loading module: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform/server-x11.so.20
[2022-11-18 10:05:33.161682] <information> mircommon: Loading module: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform/input-evdev.so.8
[2022-11-18 10:05:33.164996] <information> mirserver: Found display driver: mir:gbm-kms (version 2.9.0)
[2022-11-18 10:05:33.174872] < - debug - > gbm-kms: Quirks: checking device with devnode: /dev/dri/card1, driver vc4-drm
[2022-11-18 10:05:33.175909] <information> gbm-kms: Failed to probe DRM device: /build/mir-p5QAkY/mir-2.9.0/src/server/console/minimal_console_services.cpp(134): Throw in function virtual std::future<std::unique_ptr<mir::Device> > mir::MinimalConsoleServices::acquire_device(int, int, std::unique_ptr<mir::Device::Observer>)
Dynamic exception type: boost::wrapexcept<std::system_error>
std::exception::what: Failed to acquire DRM master: Operation not permitted

[2022-11-18 10:05:33.176663] < - debug - > gbm-kms: Quirks: checking device with devnode: (null), driver 
[2022-11-18 10:05:33.177201] < - debug - > gbm-kms: Quirks: checking device with devnode: (null), driver 
[2022-11-18 10:05:33.177718] < - debug - > gbm-kms: Quirks: checking device with devnode: (null), driver 
[2022-11-18 10:05:33.178396] < - debug - > gbm-kms: Quirks: checking device with devnode: /dev/dri/card0, driver v3d
[2022-11-18 10:05:33.178719] < -warning- > gbm-kms: Failed to detect whether device /dev/dri/card0 supports KMS, continuing with lower confidence
[2022-11-18 10:05:33.178986] <information> mirserver: Driver supports:
[2022-11-18 10:05:33.179086] <information> mirserver:   /devices/platform/v3dbus/fec00000.v3d/drm/card0 (priority 128)
[2022-11-18 10:05:33.179224] <information> mirserver: Found display driver: mir:x11 (version 2.9.0)
[2022-11-18 10:05:33.181324] <information> mirserver: Driver supports:
[2022-11-18 10:05:33.181454] <information> mirserver:   System (priority 192)
[2022-11-18 10:05:33.181670] <information> mirserver: Selected display driver: mir:gbm-kms (version 2.9.0)
[2022-11-18 10:05:33.185459] < - debug - > gbm-kms: Quirks: checking device with devnode: /dev/dri/card1, driver vc4-drm
[2022-11-18 10:05:33.186000] < -warning- > gbm-kms: Failed to open DRM device node /dev/dri/card1: /build/mir-p5QAkY/mir-2.9.0/src/server/console/minimal_console_services.cpp(134): Throw in function virtual std::future<std::unique_ptr<mir::Device> > mir::MinimalConsoleServices::acquire_device(int, int, std::unique_ptr<mir::Device::Observer>)
Dynamic exception type: boost::wrapexcept<std::system_error>
std::exception::what: Failed to acquire DRM master: Operation not permitted

[2022-11-18 10:05:33.187620] < - debug - > gbm-kms: Quirks: checking device with devnode: /dev/dri/card0, driver v3d
[2022-11-18 10:05:33.188337] < -warning- > gbm-kms: Failed to detect whether device /dev/dri/card0 supports KMS, but continuing anyway
[2022-11-18 10:05:33.188831] <information> gbm-kms: Using DRM device /dev/dri/card0
[2022-11-18 10:05:33.294947] <information> mirserver: Selected display driver: mir:x11 (version 2.9.0)
[2022-11-18 10:05:33.296728] <information> mircommon: Loading modules from: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform
[2022-11-18 10:05:33.297092] <information> mircommon: Loading module: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform/graphics-gbm-kms.so.20
[2022-11-18 10:05:33.297206] <information> mircommon: Loading module: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform/server-x11.so.20
[2022-11-18 10:05:33.297268] <information> mircommon: Loading module: /snap/ubuntu-frame/3901/usr/lib/aarch64-linux-gnu/mir/server-platform/input-evdev.so.8
[2022-11-18 10:05:33.300820] <information> mirserver: Found rendering driver: mir:gbm-kms (version 2.9.0)
[2022-11-18 10:05:33.306426] < - debug - > gbm-kms: Quirks: checking device with devnode: /dev/dri/card1, driver vc4-drm
[2022-11-18 10:05:33.739786] < - debug - > gbm-kms: Quirks: checking device with devnode: (null), driver 
[2022-11-18 10:05:33.740344] < - debug - > gbm-kms: Quirks: checking device with devnode: (null), driver 
[2022-11-18 10:05:33.740822] < - debug - > gbm-kms: Quirks: checking device with devnode: (null), driver 
[2022-11-18 10:05:33.741466] < - debug - > gbm-kms: Quirks: checking device with devnode: /dev/dri/card0, driver v3d
[2022-11-18 10:05:33.742307] < - debug - > gbm-kms: Quirks: checking device with devnode: /dev/dri/renderD128, driver v3d
[2022-11-18 10:05:33.757955] <information> mirserver: Driver supports:
[2022-11-18 10:05:33.758091] <information> mirserver:   /devices/platform/gpu/drm/card1 (priority 256)
[2022-11-18 10:05:33.758132] <information> mirserver:   /devices/platform/v3dbus/fec00000.v3d/drm/renderD128 (priority 256)
[2022-11-18 10:05:33.758196] <information> mirserver: Found rendering driver: mir:x11 (version 2.9.0)
[2022-11-18 10:05:33.758240] <information> mirserver: Driver supports:
[2022-11-18 10:05:33.758275] <information> mirserver:   System (priority 192)
[2022-11-18 10:05:33.758437] <information> mirserver: Selected rendering driver: mir:gbm-kms (version 2.9.0)
[2022-11-18 10:05:33.758577] <information> mirserver: Selected rendering driver: mir:gbm-kms (version 2.9.0)
[2022-11-18 10:05:33.758660] <information> mirserver: Selected rendering driver: mir:x11 (version 2.9.0)
ERROR: /build/mir-p5QAkY/mir-2.9.0/src/platforms/common/server/kms-utils/drm_mode_resources.cpp(39): Throw in function mir::graphics::kms::DRMModeResUPtr {anonymous}::resources_for_drm_node(int)
Dynamic exception type: boost::wrapexcept<std::system_error>
std::exception::what: Couldn't get DRM resources: Operation not supported
AlanGriffiths commented 1 year ago

drwx------ 4 root root 517 Nov 17 16:15 electron-helloworld

That is odd, but I can reproduce. Something has changed in the build environment since I wrote that. I've pushed a workaround to the branch, so if you git pull and rebuild the snap things should be working.

sambshapiro commented 1 year ago

Excellent yes that fixed it - thanks!