Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode: fails to find libGLESv2.so.2, which causes gpu acceleration to be disabled #243372

Closed
stereomato opened this issue Jul 14, 2023 · 13 comments · Fixed by #245705
Closed

vscode: fails to find libGLESv2.so.2, which causes gpu acceleration to be disabled #243372

stereomato opened this issue Jul 14, 2023 · 13 comments · Fixed by #245705
Labels
0.kind: bug Something is broken

Comments

@stereomato
Copy link
Contributor

Describe the bug

I've been trying to see why vscode had rather laggy scrolling and high cpu usage when scrolling on wayland with NIXOS_OZONE_WL set to 1, and upon discovering code --verbose and code --status , I saw that the libGLESv2.so.2 library isn't found by it, causing the app to fall back to software rendering. Disabling the env variable and starting vscode like that shows that on xwayland it does start up with gpu acceleration.

Doing the same thing described here, VScode does start with GPU acceleration working. and no longer complains about the libGLESv2.so.2 library

Steps To Reproduce

Steps to reproduce the behavior:

  1. Start VScode with NIXOS_OZONE_WL=1 set and with the --verbose flag, so it starts with wayland support and outputs details about the startup and other stuff
  2. Notice how it complains about the libGLESv2.so.2 library.
  3. Run code --status to see check that it's indeed using software rendering.

Expected behavior

The library is found, there are no complaints, and GPU acceleration is enabled.

Additional context

I am on an Intel laptop.

Notify maintainers

@eadwu @Synthetica9 @maxeaubrey @bobby285271 @Enzime

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 6.3.11, NixOS, 23.11 (Tapir), 23.11.20230706.3c74875`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.15.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@stereomato stereomato added the 0.kind: bug Something is broken label Jul 14, 2023
@SuperSandro2000
Copy link
Member

Whats the exact log? vscode vendors that library and it is located in our package at lib/vscode/libGLESv2.so.

@stereomato
Copy link
Contributor Author

stereomato commented Jul 20, 2023

Relevant lines from NIXOS_OZONE_WL=1 vscode --verbose
[347618:0719/215414.133193:ERROR:egl_util.cc(44)] Failed to load GLES library: libGLESv2.so.2: libGLESv2.so.2: cannot open shared object file: No such file or directory [347618:0719/215414.134162:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization [347632:0719/215414.151686:ERROR:egl_util.cc(44)] Failed to load GLES library: libGLESv2.so.2: libGLESv2.so.2: cannot open shared object file: No such file or directory [347632:0719/215414.152695:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization

@eadwu
Copy link
Member

eadwu commented Jul 20, 2023

--enable-features=UseOzonePlatform --ozone-platform=wayland

@999eagle
Copy link
Contributor

999eagle commented Jul 20, 2023

Same error happens on VSCodium where running with NIXOS_OZONE_WL=1 on Wayland frequently crashes on startup.
straceing codium --verbose yields a lot of openat(AT_FDCWD, "/nix/store/.../lib/libGLESv2.so.2", ...) = -1 ENOENT lines before the logged error, including this particularly interesting one:

openat(AT_FDCWD, "/nix/store/kkb8w8jg1as4n9hqn4638pds7m544xzs-vscodium-1.80.0.23188/lib/vscode/libGLESv2.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
The file /nix/store/kkb8w8jg1as4n9hqn4638pds7m544xzs-vscodium-1.80.0.23188/lib/vscode/libGLESv2.so.2 doesn't actually exist, only /nix/store/kkb8w8jg1as4n9hqn4638pds7m544xzs-vscodium-1.80.0.23188/lib/vscode/libGLESv2.so does, so apparently VSCodium is looking for libGLESv2.so.2 while only libGLESv2.so is vendored.

If libglvnd is added to the LD_LIBRARY_PATH, /nix/store/4a2wldbmd9pmnkkv3ayn6gzl2hj2v2xh-libglvnd-1.6.0/lib/libGLESv2.so.2 is found as a symlink to the actual library and straceing again confirms that this library is loaded by VSCodium.

Edit: Adding ln -sf libGLESv2.so $out/lib/vscode/libGLESv2.so.2 to postInstall fails with different error messages, so probably there's something broken with the vendored library:

[108323:0720/095401.685910:ERROR:gpu_init.cc(523)] Passthrough is not supported, GL is egl, ANGLE is                                                                                                              
[108323:0720/095401.686043:ERROR:gl_surface_egl.cc(324)] No suitable EGL configs found.                                                                                                                           
[108323:0720/095401.686078:ERROR:gl_display.cc(508)] EGL Driver message (Error) eglCreatePbufferSurface: eglCreatePbufferSurface                                                                                  
[108323:0720/095401.686100:ERROR:gl_surface_egl.cc(1111)] eglCreatePbufferSurface failed with error EGL_BAD_CONFIG                                                                                                
[108323:0720/095401.686122:ERROR:gpu_info_collector.cc(80)] gl::GLContext::CreateOffscreenGLSurface failed                                                                                                        
[108323:0720/095401.686143:ERROR:gpu_info_collector.cc(348)] Could not create surface for info collection.                                                                                                        
[108323:0720/095401.686187:ERROR:gpu_init.cc(87)] CollectGraphicsInfo failed.                                                                                                                                     
[108323:0720/095401.687193:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization

@SuperSandro2000
Copy link
Member

Edit: Adding ln -sf libGLESv2.so $out/lib/vscode/libGLESv2.so.2 to postInstall fails with different error messages, so probably there's something broken with the vendored library:

I would guess that's because the drivers to not abi match. I would recommend to rm the vendored shared object and symlink libglvnd to the correct location.

Also we should investigate if we can remove/replace the other vendored libraries.

@joaojacome
Copy link

@999eagle

Adding libglvnd to the library path did the trick for me, thanks!

pkgs.vscodium.overrideAttrs(old: {
  libPath = lib.makeLibraryPath [pkgs.libglvnd];
})

@stereomato
Copy link
Contributor Author

I can't get it to work with vscode sadly.

vscode = super.vscode.overrideAttrs (super: { libPath = lib.makeLibraryPath [pkgs.libglvnd]; });

@dan4ik605743
Copy link
Member

How soon will the changes get into nixos-unstable?

@drupol
Copy link
Contributor

drupol commented Jul 29, 2023 via email

@drupol
Copy link
Contributor

drupol commented Jul 29, 2023

You can follow the PR here: https://nixpk.gs/pr-tracker.html?pr=245705

@anilanar
Copy link
Contributor

anilanar commented Aug 9, 2023

This is still broken for me:

Failed to load GLES library: /nix/store/pj28fgr2jj4wn5az6x26px6dsbgc09p7-vscodium-1.80.2.23209/lib/vscode/libGLESv2.so

In fact, that file is missing. libGLESv2.so.2 is missing too. As expected, due to last PR merged.

I can confirm that the wrapper script contains:

LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+':'$LD_LIBRARY_PATH':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/':''/nix/store/1k87lf3ar245hg06kw4fynv4vmcj6pzc-libglvnd-1.6.0/lib'':'/':'}
LD_LIBRARY_PATH='/nix/store/1k87lf3ar245hg06kw4fynv4vmcj6pzc-libglvnd-1.6.0/lib'$LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH#':'}
LD_LIBRARY_PATH=${LD_LIBRARY_PATH%':'}
export LD_LIBRARY_PATH

So what gives? How did this work for others but not me?

@anilanar
Copy link
Contributor

anilanar commented Aug 9, 2023

I'm guessing the last PR fixed it for wayland/NIXOS_OZONE_WL but broke it for others?

Edit:

I can confirm that I have gpu acceleration when I pin vscode nixpkgs to e8d56b9 which is the parent commit of #245705.

I also tried the following, linking libglvnd's libGLESv2 into vscode directory. The error changed and terminal rendering completely broke with a black screen:

      postInstall = ''
        ln -sf ${pkgs.libglvnd}/lib/libGLESv2.so $out/lib/vscode/libGLESv2.so
      '';

@stereomato
Copy link
Contributor Author

please open a bug @anilanar !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants