NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.39k stars 14.34k forks source link

Hardware acceleration for Chromium fails while Vulkan and VA-API are available #299773

Open credmp opened 8 months ago

credmp commented 8 months ago

Describe the bug

Chromium is unable to find a driver for Vulkan.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Enable OpenGL
    hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
    setLdLibraryPath = true;
    extraPackages = with pkgs; [
        vaapiVdpau
        libvdpau-va-gl
        nvidia-vaapi-driver
    ];
    };
    environment.sessionVariables = { LIBVA_DRIVER_NAME="nvidia"; };
  2. Ensure VA and Vulkan work

vainfo output:

nix-shell -p libva-utils --run vainfo
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.20.0
libva error: vaGetDriverNames() failed with unknown libva error
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /run/opengl-driver/lib/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.20.0)
vainfo: Driver version: VA-API NVDEC driver [egl backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

vulkan-info:

==========
VULKANINFO
==========

Vulkan Instance Version: 1.3.268

Instance Extensions: count = 23
===============================
        VK_EXT_acquire_drm_display             : extension revision 1
        VK_EXT_acquire_xlib_display            : extension revision 1
        VK_EXT_debug_report                    : extension revision 10
Snipped 5000 lines
  1. Observe chrome://gpu not enabling webgpu and throwing an error
libva error: /run/opengl-driver/lib/dri/nvidia_drv_video.so init failed
Warning: vkCreateInstance: Found no drivers!
Warning: vkCreateInstance failed with VK_ERROR_INCOMPATIBLE_DRIVER
    at CheckVkSuccessImpl (../../third_party/dawn/src/dawn/native/vulkan/VulkanError.cpp:101)

Expected behavior

I expected chrome to pick up the vulkan driver and provide webgpu and hardware acceleration

Screenshots

image

Additional context

The new MS Teams client in the browser seems to require hardware acceleration to keep being supported after march 31st.

Notify maintainers

Metadata

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

$ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.82, NixOS, 23.11 (Tapir), 23.11.5648.44733514b72e`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"home-manager-23.11.tar.gz, nixos-23.11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
credmp commented 8 months ago

Besides it not working with nvidia, it also does not work on my laptop using an i915 on board graphics chip.

credmp commented 8 months ago

I noted above that the new MS Teams seems to require webgpu to function correctly, it seems a lie. After a final hail-mary changing the user agent to a known entry, it will gladly load the new web ui... Still would like to solve the driver issue though.

Kiskae commented 8 months ago

Might be resolved by #293063 which fixes the ANGLE vulkan loader.

Running nixos-unstable chromium with the VK_LOADER_DEBUG=driver environment variable shows it does not find any icds, which leads me to think it is using the unpatched ANGLE vulkan loader.

Kiskae commented 8 months ago

@credmp I'm pretty the vulkan issue itself will be fixed by my PR, but could you try running chromium with VK_ADD_DRIVER_FILES=/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json and see if that fixes the libva issue? If it does then this should be fixed when the correct vulkan loader is used.

credmp commented 8 months ago

Running nixos-unstable chromium with the VK_LOADER_DEBUG=driver environment variable shows it does not find any icds, which leads me to think it is using the unpatched ANGLE vulkan loader.

True, it outputs the following (for sake of completeness):

DRIVER:            Searching for driver manifest files
DRIVER:               In following locations:
DRIVER:                  /home/arjen/.config/vulkan/icd.d
DRIVER:                  /etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/etc/xdg/vulkan/icd.d
DRIVER:                  /run/current-system/sw/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/vulkan/icd.d
DRIVER:                  /home/arjen/.local/share/vulkan/icd.d
DRIVER:                  /nix/store/z6f8mmayq23q4rc3g39l9z06gd6d0q2s-cups-2.4.7/share/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/vulkan/icd.d
DRIVER:                  /nix/store/ycv1q2dxxvsl24bx4j7zdmnp6b5y88gn-adwaita-icon-theme-45.0/share/vulkan/icd.d
DRIVER:                  /nix/store/j2v9q24rqg69964x1cnqxr34pqvsra0n-hicolor-icon-theme-0.17/share/vulkan/icd.d
DRIVER:                  /nix/store/80bnrnbvzl0f4yjg1b2m0941v7dg2gzs-gsettings-desktop-schemas-45.0/share/gsettings-schemas/gsettings-desktop-schemas-45.0/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/gsettings-schemas/gtk+3-3.24.41/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/gsettings-schemas/gtk4-4.12.5/vulkan/icd.d
DRIVER:                  /nix/store/qmq1whvfjhijwand4wagvb3ws89dx64a-desktops/share/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/share/vulkan/icd.d
DRIVER:                  /nix/profile/share/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/share/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/share/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/share/vulkan/icd.d
DRIVER:                  /run/current-system/sw/share/vulkan/icd.d
DRIVER:               Found no files
DRIVER:            Searching for driver manifest files
DRIVER:               In following locations:
DRIVER:                  /home/arjen/.config/vulkan/icd.d
DRIVER:                  /etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/etc/xdg/vulkan/icd.d
DRIVER:                  /run/current-system/sw/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/vulkan/icd.d
DRIVER:                  /home/arjen/.local/share/vulkan/icd.d
DRIVER:                  /nix/store/z6f8mmayq23q4rc3g39l9z06gd6d0q2s-cups-2.4.7/share/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/vulkan/icd.d
DRIVER:                  /nix/store/ycv1q2dxxvsl24bx4j7zdmnp6b5y88gn-adwaita-icon-theme-45.0/share/vulkan/icd.d
DRIVER:                  /nix/store/j2v9q24rqg69964x1cnqxr34pqvsra0n-hicolor-icon-theme-0.17/share/vulkan/icd.d
DRIVER:                  /nix/store/80bnrnbvzl0f4yjg1b2m0941v7dg2gzs-gsettings-desktop-schemas-45.0/share/gsettings-schemas/gsettings-desktop-schemas-45.0/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/gsettings-schemas/gtk+3-3.24.41/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/gsettings-schemas/gtk4-4.12.5/vulkan/icd.d
DRIVER:                  /nix/store/qmq1whvfjhijwand4wagvb3ws89dx64a-desktops/share/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/share/vulkan/icd.d
DRIVER:                  /nix/profile/share/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/share/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/share/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/share/vulkan/icd.d
DRIVER:                  /run/current-system/sw/share/vulkan/icd.d
DRIVER:               Found no files
DRIVER:            Searching for driver manifest files
DRIVER:               In following locations:
DRIVER:                  /home/arjen/.config/vulkan/icd.d
DRIVER:                  /etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/etc/xdg/vulkan/icd.d
DRIVER:                  /run/current-system/sw/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/vulkan/icd.d
DRIVER:                  /home/arjen/.local/share/vulkan/icd.d
DRIVER:                  /nix/store/z6f8mmayq23q4rc3g39l9z06gd6d0q2s-cups-2.4.7/share/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/vulkan/icd.d
DRIVER:                  /nix/store/ycv1q2dxxvsl24bx4j7zdmnp6b5y88gn-adwaita-icon-theme-45.0/share/vulkan/icd.d
DRIVER:                  /nix/store/j2v9q24rqg69964x1cnqxr34pqvsra0n-hicolor-icon-theme-0.17/share/vulkan/icd.d
DRIVER:                  /nix/store/80bnrnbvzl0f4yjg1b2m0941v7dg2gzs-gsettings-desktop-schemas-45.0/share/gsettings-schemas/gsettings-desktop-schemas-45.0/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/gsettings-schemas/gtk+3-3.24.41/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/gsettings-schemas/gtk4-4.12.5/vulkan/icd.d
DRIVER:                  /nix/store/qmq1whvfjhijwand4wagvb3ws89dx64a-desktops/share/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/share/vulkan/icd.d
DRIVER:                  /nix/profile/share/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/share/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/share/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/share/vulkan/icd.d
DRIVER:                  /run/current-system/sw/share/vulkan/icd.d
DRIVER:               Found no files
DRIVER:            Searching for driver manifest files
DRIVER:               In following locations:
DRIVER:                  /home/arjen/.config/vulkan/icd.d
DRIVER:                  /etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/etc/xdg/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/etc/xdg/vulkan/icd.d
DRIVER:                  /run/current-system/sw/etc/xdg/vulkan/icd.d
DRIVER:                  /etc/vulkan/icd.d
DRIVER:                  /home/arjen/.local/share/vulkan/icd.d
DRIVER:                  /nix/store/z6f8mmayq23q4rc3g39l9z06gd6d0q2s-cups-2.4.7/share/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/vulkan/icd.d
DRIVER:                  /nix/store/ycv1q2dxxvsl24bx4j7zdmnp6b5y88gn-adwaita-icon-theme-45.0/share/vulkan/icd.d
DRIVER:                  /nix/store/j2v9q24rqg69964x1cnqxr34pqvsra0n-hicolor-icon-theme-0.17/share/vulkan/icd.d
DRIVER:                  /nix/store/80bnrnbvzl0f4yjg1b2m0941v7dg2gzs-gsettings-desktop-schemas-45.0/share/gsettings-schemas/gsettings-desktop-schemas-45.0/vulkan/icd.d
DRIVER:                  /nix/store/askhmqjgv40k9apkr5p8ic3228aammh9-gtk+3-3.24.41/share/gsettings-schemas/gtk+3-3.24.41/vulkan/icd.d
DRIVER:                  /nix/store/3hcvaz4nwqcipxdlrddg5hjfz89s9v5q-gtk4-4.12.5/share/gsettings-schemas/gtk4-4.12.5/vulkan/icd.d
DRIVER:                  /nix/store/qmq1whvfjhijwand4wagvb3ws89dx64a-desktops/share/vulkan/icd.d
DRIVER:                  /home/arjen/.nix-profile/share/vulkan/icd.d
DRIVER:                  /nix/profile/share/vulkan/icd.d
DRIVER:                  /home/arjen/.local/state/nix/profile/share/vulkan/icd.d
DRIVER:                  /etc/profiles/per-user/arjen/share/vulkan/icd.d
DRIVER:                  /nix/var/nix/profiles/default/share/vulkan/icd.d
DRIVER:                  /run/current-system/sw/share/vulkan/icd.d
DRIVER:               Found no files
ERROR | DRIVER:    vkCreateInstance: Found no drivers!
credmp commented 8 months ago

Running nixos-unstable chromium with the VK_LOADER_DEBUG=driver environment variable shows it does not find any icds, which leads me to think it is using the unpatched ANGLE vulkan loader.

Running it results in the following additional output:

DEBUG | DRIVER:    Searching for ICD drivers named /nix/store/b1mnns1r35yp5418d1fxd0hzvmxif609-nvidia-x11-535.129.03-6.1.82/lib/libGLX_nvidia.so.0
INFO | DRIVER:     linux_read_sorted_physical_devices:
INFO | DRIVER:          Original order:
INFO | DRIVER:                [0] NVIDIA GeForce RTX 3050
INFO | DRIVER:          Sorted order:
INFO | DRIVER:                [0] NVIDIA GeForce RTX 3050
INFO | DRIVER:     linux_read_sorted_physical_devices:
INFO | DRIVER:          Original order:
INFO | DRIVER:                [0] NVIDIA GeForce RTX 3050
INFO | DRIVER:          Sorted order:
INFO | DRIVER:                [0] NVIDIA GeForce RTX 3050
DEBUG | DRIVER:    Copying old device 0 into new device 0
libva error: /run/opengl-driver/lib/dri/nvidia_drv_video.so init failed
Kiskae commented 8 months ago

Running it results in the following additional output:

Lastly try with NVD_LOG=1 which enables additional logging in the nvidia-vaapi driver.

credmp commented 8 months ago

Lastly try with NVD_LOG=1 which enables additional logging in the nvidia-vaapi driver.

Here we go:

    258345.731480139 [358758-358758] ../src/vabackend.c:2140       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 31
    258345.731490098 [358758-358758] ../src/vabackend.c:2149       __vaDriverInit_1_0 Now have 0 (0 max) instances
    258345.731492161 [358758-358758] ../src/vabackend.c:2172       __vaDriverInit_1_0 Selecting EGL backend
    258345.736015606 [358758-358758] ../src/backend-common.c:  31            isNvidiaDrmFd Invalid driver for DRM device: amdgpu
    258345.736020805 [358758-358758] ../src/vabackend.c:2200       __vaDriverInit_1_0 Exporter failed

interestingly it references amdgpu in the output...

Kiskae commented 8 months ago

Lastly try with NVD_LOG=1 which enables additional logging in the nvidia-vaapi driver.

Here we go:

    258345.731480139 [358758-358758] ../src/vabackend.c:2140       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 31
    258345.731490098 [358758-358758] ../src/vabackend.c:2149       __vaDriverInit_1_0 Now have 0 (0 max) instances
    258345.731492161 [358758-358758] ../src/vabackend.c:2172       __vaDriverInit_1_0 Selecting EGL backend
    258345.736015606 [358758-358758] ../src/backend-common.c:  31            isNvidiaDrmFd Invalid driver for DRM device: amdgpu
    258345.736020805 [358758-358758] ../src/vabackend.c:2200       __vaDriverInit_1_0 Exporter failed

interestingly it references amdgpu in the output...

I suspect chromium is explicitly blacklisting the NVIDIA GPU and thus passing the other device to libva. Which then leads to that check failing inside the libva driver.

credmp commented 8 months ago

yes, it seems like that. However using --ignore-gpu-blocklist does not change it.