danvd / wlroots-eglstreams

A modular Wayland compositor library with EGLStreams support
MIT License
105 stars 11 forks source link

sway crashes "failed to initialize EGL context", "could not initialize EGL" #29

Closed colemickens closed 3 years ago

colemickens commented 3 years ago
cole@porty ~
❯ ls -al /dev/dri*
total 0
drwxr-xr-x   3 root root        100 Sep 15 17:14 .
drwxr-xr-x  20 root root       4040 Sep 15 17:15 ..
drwxr-xr-x   2 root root         80 Sep 15 17:14 by-path
crw-rw----+  1 root video  226,   0 Sep 15 17:14 card0
crw-rw-rw-   1 root render 226, 128 Sep 15 17:14 renderD128

~
❯ groups
cole wheel audio video dialout keys input kvm render

~
❯ sway --my-next-gpu-wont-be-nvidia
00:00:00.001 [sway/main.c:60] !!! Proprietary Nvidia drivers are in use !!!
00:00:00.002 [wlr] [libseat] [libseat/backend/seatd.c:78] Could not connect to socket /run/seatd.sock: No such file or directory
00:00:00.006 [wlr] [render/egl.c:593] Failed to initialize EGL context
00:00:00.006 [wlr] [render/gles2/renderer.c:789] Could not initialize EGL
sway: render/gles2/renderer.c:39: gles2_get_renderer: Assertion `wlr_renderer_is_gles2(wlr_renderer)' failed.
zsh: IOT instruction (core dumped)  sway --my-next-gpu-wont-be-nvidia

Originally posted by @colemickens in https://github.com/danvd/wlroots-eglstreams/issues/28#issuecomment-920478539

colemickens commented 3 years ago

This is on NixOS, with a package from nixpkgs-wayland, and with an NVIDIA 3080:

05:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3080] (rev a1)
❯ cat /proc/cmdline         
BOOT_IMAGE=(hd0,gpt1)//kernels/1y3lzh8c80zchjzbhh9iv2jj2kl174gc-linux-5.13.16-bzImage init=/nix/store/5afcbkvaj2ahlscvd6y4rq08d0kwqgpz-nixos-system-porty-21.11pre-git/init mitigations=off loglevel=4 nvidia-drm.modeset=1
colemickens commented 3 years ago

Here's a proper debug log:

~ 8s
❯ cat /tmp/sway.log  
00:00:00.000 [INFO] [sway/main.c:310] Sway version 1.6
00:00:00.000 [INFO] [sway/main.c:311] wlroots version 0.15.0
00:00:00.001 [INFO] [sway/main.c:118] Linux porty 5.13.16 #1-NixOS SMP Sun Sep 12 07:00:00 UTC 2021 x86_64 GNU/Linux
00:00:00.001 [INFO] [sway/main.c:134] Contents of /etc/os-release:
00:00:00.001 [INFO] [sway/main.c:118] NAME=NixOS
00:00:00.001 [INFO] [sway/main.c:118] ID=nixos
00:00:00.001 [INFO] [sway/main.c:118] VERSION="21.11 (Porcupine)"
00:00:00.001 [INFO] [sway/main.c:118] VERSION_CODENAME=porcupine
00:00:00.001 [INFO] [sway/main.c:118] VERSION_ID="21.11"
00:00:00.001 [INFO] [sway/main.c:118] BUILD_ID="21.11pre-git"
00:00:00.001 [INFO] [sway/main.c:118] PRETTY_NAME="NixOS 21.11 (Porcupine)"
00:00:00.001 [INFO] [sway/main.c:118] LOGO="nix-snowflake"
00:00:00.001 [INFO] [sway/main.c:118] HOME_URL="https://nixos.org/"
00:00:00.001 [INFO] [sway/main.c:118] DOCUMENTATION_URL="https://nixos.org/learn.html"
00:00:00.001 [INFO] [sway/main.c:118] SUPPORT_URL="https://nixos.org/community.html"
00:00:00.001 [INFO] [sway/main.c:118] BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
00:00:00.001 [INFO] [sway/main.c:106] LD_LIBRARY_PATH=/nix/store/306vm2lwlrif5vpihm8w1a9gjl29xcsz-pipewire-0.3.34-jack/lib
00:00:00.001 [INFO] [sway/main.c:106] LD_PRELOAD=
00:00:00.001 [INFO] [sway/main.c:106] PATH=/run/wrappers/bin:/home/cole/.nix-profile/bin:/etc/profiles/per-user/cole/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/home/cole/.config/zsh/plugins/powerlevel10k-config:/home/cole/.config/zsh/plugins/powerlevel10k:/home/cole/.config/zsh/plugins/zsh-fast-syntax-highlighting
00:00:00.001 [INFO] [sway/main.c:106] SWAYSOCK=
00:00:00.001 [ERROR] [sway/main.c:60] !!! Proprietary Nvidia drivers are in use !!!
00:00:00.001 [DEBUG] [sway/server.c:49] Preparing Wayland server initialization
00:00:00.002 [ERROR] [wlr] [libseat] [libseat/backend/seatd.c:78] Could not connect to socket /run/seatd.sock: No such file or directory
00:00:00.002 [INFO] [wlr] [libseat] [libseat/libseat.c:70] Backend 'seatd' failed to open seat, skipping
00:00:00.005 [INFO] [wlr] [libseat] [libseat/libseat.c:67] Seat opened with backend 'logind'
00:00:00.005 [INFO] [wlr] [backend/session/session.c:110] Successfully loaded libseat session
00:00:00.005 [INFO] [wlr] [backend/backend.c:282] Found 1 GPUs
00:00:00.005 [INFO] [wlr] [backend/drm/backend.c:175] Initializing DRM backend for /dev/dri/card0 (nvidia-drm)
00:00:00.005 [DEBUG] [wlr] [backend/drm/drm.c:89] Using atomic DRM interface
00:00:00.005 [DEBUG] [wlr] [backend/drm/drm.c:102] ADDFB2 modifiers supported
00:00:00.005 [INFO] [wlr] [backend/drm/drm.c:270] Found 4 DRM CRTCs
00:00:00.005 [INFO] [wlr] [backend/drm/drm.c:191] Found 12 DRM planes
00:00:00.007 [INFO] [wlr] [render/egl.c:198] Supported EGL client extensions: EGL_EXT_platform_base EGL_EXT_device_base EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions EGL_KHR_debug EGL_KHR_platform_x11 EGL_EXT_platform_x11 EGL_EXT_platform_device
00:00:00.007 [DEBUG] [wlr] [render/egl.c:469] EGL_EXT_device_enumeration not supported
00:00:00.007 [DEBUG] [wlr] [render/egl.c:589] KHR_platform_gbm not supported
00:00:00.007 [ERROR] [wlr] [render/egl.c:593] Failed to initialize EGL context
00:00:00.007 [ERROR] [wlr] [render/gles2/renderer.c:789] Could not initialize EGL
00:00:00.007 [DEBUG] [wlr] [render/wlr_renderer.c:308] Failed to create GLES2 renderer
00:00:00.007 [INFO] [wlr] [render/pixman/renderer.c:521] Creating pixman renderer
00:00:00.007 [DEBUG] [wlr] [render/eglstreams_allocator.c:96] Created EGLStreams allocator
00:00:00.007 [INFO] [sway/main.c:358] Starting sway version 1.6
00:00:00.007 [DEBUG] [sway/server.c:74] Initializing Wayland server
sway: render/gles2/renderer.c:39: gles2_get_renderer: Assertion `wlr_renderer_is_gles2(wlr_renderer)' failed.

Though, I fear from the log lines that maybe this isn't properly patched? Not sure...

colemickens commented 3 years ago

I suspect it has to do with egl-wayland/nvidia/nixos stuff: https://github.com/NixOS/nixpkgs/issues/75131

Ugh nvidia, ugh.

danvd commented 3 years ago

The reason is in this line: [DEBUG] [wlr] [render/egl.c:469] EGL_EXT_device_enumeration not supported This extension must be present, else it falls back to gdm/software rendering. sway doesn't work with it.

Could you please post your lsmod | grep nvidia and eglinfo output ?

hansihe commented 3 years ago

I had this problem as well. Turns out some libglvnd versions only support EGL_EXT_device_base, which is specified to contain the functionality of both EGL_EXT_device_query and EGL_EXT_device_enumeration.

https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_device_base.txt

RESOLVED: This extension initially included both of these abilities. To allow simpler implementations to add only the ability to query the device of an existing EGLDisplay, this extension was split into two separate extensions:

EGL_EXT_device_query EGL_EXT_device_enumeration

The presence of this extension now only indicates support for both of the above extensions.

This patch seems to fix this problem on my system.

diff --git a/render/egl.c b/render/egl.c
index 23b8412d..0498e6ca 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -210,11 +210,11 @@ static struct wlr_egl *egl_create(void) {
    egl->exts.EXT_platform_device = check_egl_ext(client_exts_str,
            "EGL_EXT_platform_device");

-   if (check_egl_ext(client_exts_str, "EGL_EXT_device_enumeration")) {
+   if (check_egl_ext(client_exts_str, "EGL_EXT_device_base") || check_egl_ext(client_exts_str, "EGL_EXT_device_enumeration")) {
        load_egl_proc(&egl->procs.eglQueryDevicesEXT, "eglQueryDevicesEXT");
    }

-   if (check_egl_ext(client_exts_str, "EGL_EXT_device_query")) {
+   if (check_egl_ext(client_exts_str, "EGL_EXT_device_base") || check_egl_ext(client_exts_str, "EGL_EXT_device_query")) {
        egl->exts.EXT_device_query = true;
        load_egl_proc(&egl->procs.eglQueryDeviceStringEXT,
            "eglQueryDeviceStringEXT");
danvd commented 3 years ago

Thanks a lot, @hansihe! Pushed your changes.

colemickens commented 3 years ago

screenshot-1632791767

It works, this is great, thanks!