Electron apps can't find OpenGL

chrome://gpu report:
https://pastebin.com/raw/ap2Utyyn

Obisidian errors:
https://pastebin.com/raw/mWe1nsFn

OpenGL configuration:

	hardware.opengl = {
		enable = true;
		driSupport = true;
		driSupport32Bit = true;
		extraPackages = with pkgs; [
			intel-media-driver
			vaapiIntel
			vaapiVdpau
			libvdpau-va-gl
			mesa.drivers
		];
	};

Hey welcome to NixOS :smiley:

I believe this is the same issue as this one: Chrome - wayland

Which means it is related to a problem in Chrome’s codebase that hopefully will be resolved at some point.

1 Like

I hope so.
Maybe there is a possibility to roll back to a previous version of the package, because this problem appeared quite recently, just a day ago I didn’t encounter it, but after the last update everything broke.
Also people write that they do not encounter this problem in other packages (ungoogled-chromium), but I also have it in it.
Only flatpak version of chrome/chromedev works normally.

I belive I’ve got different issue, my errors completely different from guys errors.

GpuProcessHost: The GPU process exited normally. Everything is okay.
[3450:3450:1119/211139.851123:ERROR:angle_platform_impl.cc(44)] : Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.851265:ERROR:gl_display.cc(515)] : EGL Driver message (Critical) eglInitialize: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.851302:ERROR:gl_display.cc(786)] : eglInitialize OpenGL failed with error EGL_NOT_INITIALIZED, trying next display type
[3450:3450:1119/211139.851378:ERROR:angle_platform_impl.cc(44)] : Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.851412:ERROR:gl_display.cc(515)] : EGL Driver message (Critical) eglInitialize: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.851440:ERROR:gl_display.cc(786)] : eglInitialize OpenGLES failed with error EGL_NOT_INITIALIZED
[3450:3450:1119/211139.851466:ERROR:gl_display.cc(820)] : Initialization of all EGL display types failed.
[3450:3450:1119/211139.851497:ERROR:gl_ozone_egl.cc(26)] : GLDisplayEGL::Initialize failed.
[3450:3450:1119/211139.852942:ERROR:angle_platform_impl.cc(44)] : Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.853006:ERROR:gl_display.cc(515)] : EGL Driver message (Critical) eglInitialize: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.853035:ERROR:gl_display.cc(786)] : eglInitialize OpenGL failed with error EGL_NOT_INITIALIZED, trying next display type
[3450:3450:1119/211139.853092:ERROR:angle_platform_impl.cc(44)] : Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.853123:ERROR:gl_display.cc(515)] : EGL Driver message (Critical) eglInitialize: Could not dlopen native EGL: libEGL.so.1: cannot open shared object file: No such file or directory
[3450:3450:1119/211139.853151:ERROR:gl_display.cc(786)] : eglInitialize OpenGLES failed with error EGL_NOT_INITIALIZED
[3450:3450:1119/211139.853178:ERROR:gl_display.cc(820)] : Initialization of all EGL display types failed.
[3450:3450:1119/211139.853205:ERROR:gl_ozone_egl.cc(26)] : GLDisplayEGL::Initialize failed.
[3450:3450:1119/211139.854333:ERROR:viz_main_impl.cc(196)] : Exiting GPU process due to errors during initialization
GpuProcessHost: The GPU process exited normally. Everything is okay.
[3502:3502:1119/211139.907546:WARNING:angle_platform_impl.cc(49)] : RendererVk.cpp:1962 (initialize): ANGLE VMA version: 2003000
[3502:3502:1119/211139.911398:WARNING:sandbox_linux.cc(400)] : InitializeSandbox() called with multiple threads in process gpu-process.

So what exactly are you trying to run there? Obsidian? And is it crashing?

I’ve got such errors with chromium and obsidian, they aren’t crashing, but they laggy as hell because they are using software rendering.

okay, for some reason they are not laggy for me even though they show software rendering on wayland as well…

but apart from that, you can try running them in XWayland via executing env WAYLAND_DISPLAY= obsidian in a terminal for instance. If that does anything positive, you can write a little wrapper to always launch them like that. But let’s try and see if it has any effect first.

Edit: Another thing you can try is pass the --disable-gpu flag to the application when launching them. I had many issues with electron apps crashing on Wayland unless you pass this in recent months. Annoying, but the workaround does it’s thing.

Yes, they work fine with XWayland (but chrome still shows that is using software render), but I have a hidpi display, so XWayland is not my option).
So I will use the flatpak version of chrome until I find a solution.

The --disable-gpu flag only clears the errors, but doesn’t solve the problem

In XWayland I get hardware rendering. So that should work. So it looks like this for Brave on my desktop:

Graphics Feature Status
=======================
*   Canvas: Hardware accelerated
*   Canvas out-of-process rasterization: Disabled
*   Direct Rendering Display Compositor: Disabled
*   Compositing: Hardware accelerated
*   Multiple Raster Threads: Enabled
*   OpenGL: Enabled
*   Rasterization: Hardware accelerated
*   Raw Draw: Disabled
*   Skia Graphite: Disabled
*   Video Decode: Hardware accelerated
*   Video Encode: Hardware accelerated
*   Vulkan: Disabled
*   WebGL: Hardware accelerated
*   WebGL2: Hardware accelerated
*   WebGPU: Disabled
...
XDG_CURRENT_DESKTOP             : GNOME
XDG_SESSION_TYPE                : wayland
GDMSESSION                      : gnome
Ozone platform                  : x11

Also as stated earlier, when passing --disable-gpu I get basically no noticeable performance drop.

WAYLAND_DISPLAY= chromium
image
Still spamming error, but now about libGL

[37347:37347:1120/010222.734476:ERROR:angle_platform_impl.cc(44)] Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
ERR: Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
[37347:37347:1120/010222.734638:ERROR:gl_display.cc(515)] EGL Driver message (Critical) eglInitialize: Could not dlopen libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
[37347:37347:1120/010222.734695:ERROR:gl_display.cc(786)] eglInitialize OpenGL failed with error EGL_NOT_INITIALIZED, trying next display type

Maybe I messed up something in my nix configs?

The relevant section of my config for my Intel based laptop (8th gen i7 with Intel UHD something graphics) would look like this.

Fairly similar to yours I’d say.

  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
    extraPackages = with pkgs; [
      mesa_drivers
      intel-ocl
      beignet
      vaapiIntel
      vaapiVdpau
      libvdpau-va-gl
    ];
  };

  nixpkgs.config.packageOverrides = pkgs: {
    vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
  };

I am running Gnome/Wayland on that one and while I have to --disable-gpu on certain apps, or enforce XWayland on others, and things like that, I don’t the performance issues you well talking about.

dunno.
will stick with flatpaks for now

Tried disabling almost everything in my configs to leave only Hyprland, terminal and browser, but the problem didn’t go away.
Also tried to pass LD_LIBRARY_PATH: LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver/lib/ chromium, but no success.

Found a solution!
export LD_LIBRARY_PATH=$(nix build --print-out-paths --no-link nixpkgs#libGL)/lib
But that’s just a workaround.
gh issue link: chromium/electron/element-desktop on wayland fails to find libEGL.so · Issue #268490 · NixOS/nixpkgs · GitHub

1 Like

Have you tried GitHub - nix-community/nixGL: A wrapper tool for nix OpenGL application [maintainer=@guibou] ?

2 Likes

Opened a PR for this: obsidian: fix electron not being able to find libGL by yshui · Pull Request #282595 · NixOS/nixpkgs · GitHub