electron: [Bug]: segfault on startup at gpu_init.cc under native Wayland
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
16.0.7
What operating system are you using?
Other Linux
Operating System Version
Arch
What arch are you using?
x64
Last Known Working Electron version
15.3.5
Expected Behavior
Electron to start successfully.
Actual Behavior
Electron crashes immediately upon startup.
ERROR:gpu_init.cc(457) Passthrough is not supported, GL is egl, ANGLE is
zsh: segmentation fault (core dumped) electron
Testcase Gist URL
No response
Additional Information
This is confirmed to be happening on a number of other distros on this Signal issue report. asciinema recording. I will happily provide more information if need be.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 29
- Comments: 15 (4 by maintainers)
Commits related to this issue
- signal-desktop: 5.27.1 -> 5.28.0 This update breaks Ozone/Wayland due to an Electron update [0]. This isn't ideal but we cannot block Signal-Desktop updates indefinitely based on that. It's an upstre... — committed to primeos/nixpkgs by primeos 2 years ago
- signal-desktop: 5.27.1 -> 5.28.0 This update breaks Ozone/Wayland due to an Electron update [0]. This isn't ideal but we cannot block Signal-Desktop updates indefinitely based on that. It's an upstre... — committed to NixOS/nixpkgs by primeos 2 years ago
- signal-desktop: 5.27.1 -> 5.28.0 This update breaks Ozone/Wayland due to an Electron update [0]. This isn't ideal but we cannot block Signal-Desktop updates indefinitely based on that. It's an upstre... — committed to NixOS/nixpkgs by primeos 2 years ago
Thanks. The problem is that electron still calls to X11 objects despite them being null.
See https://github.com/electron/electron/blob/main/shell/browser/native_window_views.cc#L279. <— That’s fundamentally incorrect. Chromium has migrated from non-Ozone builds, which used non-Ozone/X11 by default, to Ozone builds[1], which uses Ozone/X11 by default with Wayland chosen if --ozone-platform flag is passed. Thus, there is no point to pass the --enable-features=UseOzonePlatform flag since M95 [2]. The flag was left until M98[3] just for the gardening purposes and it’s no longer in Chromium. Last, the USE_X11 ifdef and the use_x11 gn arg have also been removed after all the gardening was completed in M98[4][5].
That’s the reason it segfaults.
[1] https://source.chromium.org/chromium/chromium/src/+/cecaf7e62fa3daddc51120e06a52e1777e36f05e [2] https://chromiumdash.appspot.com/commit/cecaf7e62fa3daddc51120e06a52e1777e36f05e [3] https://chromiumdash.appspot.com/commit/5d0f7a98e295248609dc2bad9209d7f387374e03 [4] https://chromiumdash.appspot.com/commit/cd3d129061f1ee453fb06af7b998f948c3582874 [5] https://chromiumdash.appspot.com/commit/6d244dbb18098e85b019248a6d207f5735dd8558
It also seems to be a race condition. If I start slack several times in a row (with ozone on wayland), it will eventually not crash.
I’m seeing the same issue with
--enable-features=UseOzonePlatform --ozone-platform=wayland
on various Electron versions installed from NPM, including:Output:
All older versions up to 16.0.8 instead run into #32487, so they fail to start before this crash… Arch Linux backported the patches proposed in that PR, so they already get the new crash behavior of Electron 17+ with Electron 16 and the latest Sway.
@msisov oops, sorry I’ve pasted the wrong example, that was indeed an unrelated error (although it shouldn’t cause a segfault either).
It’s probably best to look at the outputs in this thread (there are many): https://github.com/signalapp/Signal-Desktop/issues/5719 E.g. from the original/first post (without the Signal-Desktop output):
Here’s the output on my system when
libGLESv2.so.2
can be found but https://github.com/electron/electron/pull/32603#issuecomment-1022908675 is likely a better example for that case:That D-Bus error should also be unrelated and fixable at the packaging / Linux distribution’s side (or my setup):
But IMO that should normally be optional and it definitely shouldn’t cause a segfault.
Based on this issue and the linked issues, many users on different distributions are affected. However, it also seems to work on some distributions (e.g., Arch Linux, I think - but apparently not for all users).
Anyway, I had no luck to get it to work on my distribution (even when trying to use different GPU related flags, e.g., for SwiftShader). E.g. (not sure which of them are currently supposed to work and which not - they’re changing faster than I can keep up with and may of the old flags result in
[13322:0207/211626.899668:ERROR:gl_factory.cc(148)] Requested GL implementation (gl=none,angle=none) not found in allowed implementations: [(gl=egl-gles2,angle=none),(gl =egl-angle,angle=swiftshader),(gl=swiftshader-gl,angle=none)].
- looks like only very few combinations are left):--use-gl=egl
(etc.)--use-angle=swiftshader
(etc.)--disable-gpu-sandbox
--disable-gpu
@msisov does Electron 17.0.0 work on your Linux setup?
That’s also good to know. I was actually wondering about that since at least Chromium and Google Chrome seem to ship a
libGLESv2.so
as well. It is a wrapper from ANGLE, IIRC.https://gist.github.com/brandonweeks/28f3ef35515e7cdd487a4df98bed5cff
Here is the backtrace from Electron 17.0.0 on NixOS, after resolving the
libGLESv2.so.2
issue.I think this particular error message is a red herring. I always see this error when launching both Chromium and Electron on Wayland even though the apps run just fine afterwards.
FWIW I can also reproduce the startup crash when launching Electron 16 on Wayland but only when using the official electron package from Arch Linux.
When installing the same electron version from
npm
/yarn
(e.g.:yarn global add electron@16.0.7
), it no longer crashes at startup and the Electron window is displayed properly.This seems to suggest it might be an Arch Linux packaging issue that may be caused by some of the distribution specific patches.
However, while looking into this, I did find out that all Electron versions based on Chromium version 98+ (e.g.:
electron@17.0.0-alpha.4+
) fail to start on Wayland. The last Electron version that I can still run on Wayland seems to beelectron@17.0.0-alpha.3
which is based on Chromium 96.@mitchchn suggested that it might be related to
WindowStateWatcher
but I haven’t looked into it to see if it’s the same issue.I suspect @msisov’s a62362f and Electron’s outstanding work to integrate it in #31382 are at least tangentially related to this crash due to the
electron::WindowStateWatcher
connection./cc @deepak1556
Check the strace output when you start electron with Ozone/Wayland. Here is the example of my machine -
It should definitely try to open a system libGLESv2 unless it fails to initialize GL and uses swiftshader/swangle
Here is an example if run Chromium with SwAngle (angle + swiftshader, which is a successor of swiftshader. the legacy swiftshader support has been dropped in the upstream recently).