Wayland crash with Electron 2

Hi, having some trouble getting a snap to run on platforms that use the Wayland window manager since upgrading our codebase to Electron 2.0.0. So far we’ve been able to get the snap working on the following…

  • Ubuntu 16.10
  • Ubuntu 17.10 (with x11 window manager)
  • Ubuntu 18.04

But we’re seeing it not work on the following…

  • Ubuntu 17.10 (with Wayland window manager)
  • Fedora 27

When we launch the app it quits shortly after, no error to the console. Using strace we’re able to get a non-sensible 1 exit code but no other useful information.

I’ve put a barebones example repo together that demonstrates the problem. It’s the simplest electron app that just loads ubuntu in a window. You can give it try with the following…

git clone https://github.com/Thomas101/snaptest.git
cd snaptest/wayland_crash
npm install
npm run package
snapcraft

Then on the host machine run…
snap install test_1_0_0.snap --dangerous

Any help or a point in the right direction would be really appreciated, we’ve been scratching our heads for a while here! Thanks!

Try adding the following to snapcraft.yaml and rebuilding the snap:

apps:
  test:
    […]
    environment:
      DISABLE_WAYLAND: 1
    […]

If it is getting disconnected from the display server, one thing that might be worth trying is to set WAYLAND_DEBUG=1 in the environment when running the app. This will turn on a lot of debug logging in the libwayland-client library.

I’ve seen cases where clear error messages from the server were not surfaced by GTK but could be seen in the libwayland-client debug logs, so it is possible that might give a hint about what is going on.

Also, are you saying that your app always fails on Wayland, or just when it is packaged as a snap?

@oSoMoN setting DISABLE_WAYLAND=1 seems to work as a workaround on both Ubuntu 17 & Fedora! Thank you!

@jamesh the app works as expected with Wayland when not using Snap. E.g. just running ./test from the test-linux-x64 generated directory in the repo.

Trying a run with WAYLAND_DEBUG=1 we don’t get any additional logging out - this is also the case if we run the unsnapped version. e.g. WAYLAND_DEBUG=1 ./test

It might also be worth noting that the previous version of Electron (1.8.*) was working fine with this config & Wayland. I think Electron moved from gtk-2 to gtk-3 between 1.8 and 2.0. I was wondering if this could be the cause of any of the problems?

IIRC, GTK 2.0 doesn’t support Wayland, so you’d likely have been running via Xwayland (the service that allows legacy X11 apps to display on a Wayland desktop). So Electron 2 might be the first time your app tried to run under Wayland natively.

@jamesh You know more about it than me, so that could be the case. Does adding the DISABLE_WAYLAND=1 basically cause it to run via Xwayland in the same way?

Yes. See the logic here: https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/common/desktop-exports#L168.

Perfect, that’s really helpful! Thanks everyone :slight_smile:

Note for the record, setting ELECTRON_ENABLE_LOGGING=1 can make electron much more verbose. I’ve found it helpful in debugging similar issues
-G

1 Like

Any idea why it still works under Wayland without snap? It seems like more electron snaps are having the same issue: