ogra1 / electron-kiosk-simplified

3 stars 0 forks source link

Electron app does not open after restarting. #1

Closed Shakib1126 closed 3 years ago

Shakib1126 commented 3 years ago

I have built my electon kiosk for ubuntu following all your steps. i have completed building a snap for it and also tested it using " snap run " command. But after i restart or poweroff my system, the application does not launch on boot. Means its still not a kisok ubuntu app.

NOTE : I have kept confinement as " devmode " in the entire process. Does this have something to do with above problem?

ogra1 commented 3 years ago

snap run is not supposed to work at all since this snap is designed as a daemon ... can you point me to your snapcraft.yaml ? also make sure that mir-kiosk is properly up and running and you have connected all necessary snap interfaces, without these the snap can not start ...

EDIT: oops, i just noticed your note on "devmode" above ... with devmode set the interfaces are indeed not a hard requirement (though your logs will be flooded with messages then) ... but you will still need a wayland compositor like mir-kiosk running that the snap can consume nontheless ...

Shakib1126 commented 3 years ago
name: electron-hello-world-kiosk
version: '0.1'
summary: Hello World Electron app for a Kiosk
description: |
  Simple Hello World Electron app as an example of a HTML5 Kiosk
base: core18
confinement: devmode
grade: devel
compression: lzo

apps:
  electron-hello-world-kiosk:
    daemon: simple
    extensions: [ gnome-3-28 ]
    restart-condition: always
    command: desktop-launch xwayland-kiosk-launch $SNAP/electron-helloworld/electron-quick-start --no-sandbox
    plugs:
      - browser-support
      - 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:
  electron-helloworld:
    plugin: nodejs
    source: .
    override-build: |
      npm install electron-packager
      ./node_modules/.bin/electron-packager . --overwrite \
          --platform=linux --output=release-build --prune=true
      cp -v -R ./electron-linux-x64 $SNAPCRAFT_PART_INSTALL/electron-helloworld
    stage-packages:
      - libnspr4
      - libnss3
    build-snaps:
      - node/14/stable

    build-environment:
      - PATH: /snap/bin:$PATH

  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 ]

here is my entire snapcraft.yaml file. i also get this error when i run the snap for testing. My app opens after the "snap run electron-hello-world-kiosk " command but it also shows the below error

_XSERVTransSocketCreateListener: failed to bind listener
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: failed to create listener for unix
glamor: EGL version 1.4:
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Error:            Illegal keycode 569 (must be in the range 8-255 inclusive)
>                   Value of "maximum" not changed
> Error:            Illegal keycode 372 for name <I372>
>                   Must be in the range 8-255 inclusive
> Error:            Illegal keycode 380 for name <I380>
>                   Must be in the range 8-255 inclusive
> Error:            Illegal keycode 382 for name <I382>
>                   Must be in the range 8-255 inclusive
> Error:            Illegal keycode 569 for name <I569>
>                   Must be in the range 8-255 inclusive
Errors from xkbcomp are not fatal to the X server
ogra1 commented 3 years ago

_XSERVTransSocketCreateListener: failed to bind listener _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed _XSERVTransMakeAllCOTSServerListeners: failed to create listener for unix glamor: EGL version 1.4:

well, the wayland socket that mir-kiosk provides is usually owned by root and not writable for normal users, so this error is no surprise ... as i said above already, the app is designed as a daemon (which runs as root) ... do you have a full log from a run as daemon (after "snap install" (or snap restart electron-hello-world-kiosk) it should automatically try to start and log all failures in your system journal ... is mir-kiosk fully up and running (do you see a black screen with a mouse cursor) ?

Shakib1126 commented 3 years ago

okayy. No i do not see a black screen with a mouse cursor. I guess my mir-kiosk is not installed. Can you provide me a link or step by which i can make mir-kiosk fully up and running. And once i have my mir-kiosk running, would it work on booting?

btw appreciate your prompt reply.

ogra1 commented 3 years ago

you need make sure there is no desktop session running (stop whatever display manager you run), then snap install mir-kiosk ... once you saw the orange flash and get a mouse cursor you have the compositor up and running ... then restarting your app should make it show up on screen.

EDIT: regarding the "start on boot", you should make sure to not use a desktop install but rather server or Ubuntu Core, a desktop install will always claim the screen with the login display manager by default (while you can indeed "sudo systemctl stop --disable gdm", it is cleaner to just start off a non-graphical system here)

Shakib1126 commented 3 years ago

i just used the command you gave to stop my display manager. The screen went black and thers only a cursor there. I am not able to type or do anything. how do i snap install mir-kiosk now?

ogra1 commented 3 years ago

log in to a terminal session (try ctrl-atl-f2 or f3 or so to get a login prompt) and do sudo snap install mir-kiosk ...

Shakib1126 commented 3 years ago

Hey. Thankyou for your guidance. I was finally able to run my kiosk app. It was mir-kiosk which was the problem and also i was using ubuntu desktop.

I have one query. My application uses some docker services for backend processing. So to start those services we have to start by writing some commands. I want to know is there any way we can add those commands inside our yaml file so that when our app starts the command runs and start our docker services?

ogra1 commented 3 years ago

you can surely write a script that you launch as oneshot daemon and that uses the docker interface, but i'd suggest opening a topic on https://forum.snapcraft.io for this (i'm not really familiar with the docker interface or docker itself, personally i only use lxd for containers, on the forum you will find people more familiar with docker and using docker from snaps)

Shakib1126 commented 3 years ago

will the kiosk mode run on ubuntu server? as i have some specific requirements and ubuntu core will not be able to fulfill it

ogra1 commented 3 years ago

if mir-kiosk runs it should work fine ... i'm curious though, what are those requirements (i havent seen anything UC wouldnt fulfill yet unless it is around multi-user usage (which Ubuntu Core isnt really designed for))

Shakib1126 commented 3 years ago

Will there be any issue with mir-kiosk if there are nvidia drivers and GPU installed on the system. ?

ogra1 commented 3 years ago

nvidia should work fine with either the nouveau or nvidia propriatary drivers, though i guess on ubuntu core you would be limited to nouveau

Shakib1126 commented 3 years ago

Okayy. Actually couple of days ago i made my ubuntu desktop into electron kisok nd it worked perfectly. But now my electron app does not takes the screen. All i see is a black screen with cursor, and also after setting mir-kiosk daemon = true , there is no orangish fade. To add, i am not able to see my wayland files in /run/user/0. Is there a wayland socket issue? Nd if yes how can it be resolved?

Shakib1126 commented 3 years ago

These are my error logs.

+ mkdir -p /root/snap/mir-kiosk/6458/.config/
+ grep -vE (^vt=|^console-provider=vt|^display-layout=) /var/snap/mir-kiosk/6458/miral-kiosk.config
+ exec /snap/mir-kiosk/6458/bin/run-miral
[2021-01-29 10:50:47.255326] <information> mirserver: Starting
[2021-01-29 10:50:47.257818] < - debug - > mirserver: Not using logind for session management: Seat has no active session
[2021-01-29 10:50:47.258058] < - debug - > mirserver: Using Linux VT subsystem for session management
[2021-01-29 10:50:47.258115] <information> mircommon: Loading modules from: /snap/mir-kiosk/6458/usr/lib/x86_64-linux-gnu/mir/server-platform
[2021-01-29 10:50:47.258150] <information> mircommon: Loading module: /snap/mir-kiosk/6458/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-gbm-kms.so.19
[2021-01-29 10:50:47.258161] <information> mircommon: Loading module: /snap/mir-kiosk/6458/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-wayland.so.19
[2021-01-29 10:50:47.258170] <information> mircommon: Loading module: /snap/mir-kiosk/6458/usr/lib/x86_64-linux-gnu/mir/server-platform/server-x11.so.19
[2021-01-29 10:50:47.258177] <information> mircommon: Loading module: /snap/mir-kiosk/6458/usr/lib/x86_64-linux-gnu/mir/server-platform/input-evdev.so.7
[2021-01-29 10:50:47.259710] < - debug - > gbm-kms: MIR_MESA_KMS_DISABLE_MODESET_PROBE is set
[2021-01-29 10:50:47.259721] < -warning- > gbm-kms: Failed to detect whether device /dev/dri/card0 supports KMS, continuing with lower confidence
[2021-01-29 10:50:47.279258] <information> gbm-kms: Detected software renderer: llvmpipe (LLVM 11.0.0, 256 bits)
[2021-01-29 10:50:47.279917] <information> mirserver: Found graphics driver: mir:gbm-kms (version 2.2.0) Support priority: 128
[2021-01-29 10:50:47.279933] <information> mirserver: Found graphics driver: mir:wayland (version 2.2.0) Support priority: 0
[2021-01-29 10:50:47.279949] <information> mirserver: Found graphics driver: mir:x11 (version 2.2.0) Support priority: 0
[2021-01-29 10:50:47.280078] <information> mirserver: Selected driver: mir:gbm-kms (version 2.2.0)
[2021-01-29 10:50:47.280359] < - debug - > gbm-kms: MIR_MESA_KMS_DISABLE_MODESET_PROBE is set
[2021-01-29 10:50:47.280368] < -warning- > gbm-kms: Failed to detect whether device /dev/dri/card0 supports KMS, but continuing anyway
[2021-01-29 10:50:47.280378] <information> gbm-kms: Using DRM device /dev/dri/card0
ERROR: /build/mir-K7y0Z4/mir-2.2.0/src/platforms/common/server/kms-utils/drm_mode_resources.cpp(41): 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
ogra1 commented 3 years ago

well, this looks like a Mir issue, you should perhaps file it in the mir project: https://github.com/MirServer/mir/issues