Hardware acceleration for firefox with proprietary nvidia drivers

I wanted to enable hardware acceleration as videos were lagging so I used this VA-API implemention using NVIDIA’s NVDEC. I compiled it changed the firefox config options and set the environment variable in my zsh config (except the __EGL_VENDOR_LIBRARY_FILENAMES as zsh states the file /usr/share/glvnd/egl_vendor.d/10_nvidia.json is not present even though it is present). Still it doesn’t work Video Engine Utilization is always at 0.

NVD_BACKEND=direct NVD_LOG=1 IBVA_DRIVER_NAME=nvidia vainfo                                                                          ✔  50s  
Trying display: wayland
Trying display: x11
libva error: vaGetDriverNames() failed with unknown libva error
      1759.946339685 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/vabackend.c:2140       __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 10
      1759.946367342 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/vabackend.c:2149       __vaDriverInit_1_0 Now have 0 (0 max) instances
      1759.946384872 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/vabackend.c:2175       __vaDriverInit_1_0 Selecting Direct backend
      1759.960210653 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/backend-common.c:  31            isNvidiaDrmFd Invalid driver for DRM device: amdgpu
      1759.960332876 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/direct/direct-export-buf.c:  85      direct_initExporter Found NVIDIA GPU 0 at /dev/dri/renderD129
      1759.960339441 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/direct/nv-driver.c: 246            init_nvdriver Initing nvdriver...
      1759.960370939 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/direct/nv-driver.c: 264            init_nvdriver NVIDIA kernel driver version: 550.67, major version: 550, minor version: 67
      1759.960378203 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/direct/nv-driver.c: 271            init_nvdriver Got dev info: 100 1 0 fe
vainfo: VA-API version: 1.20 (libva 2.20.1)
vainfo: Driver version: VA-API NVDEC driver [direct backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      1760.093689433 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/vabackend.c:2050              nvTerminate Terminating 0x55f22c7394e0
      1760.093832468 [5183-5183] ../nvidia-vaapi-driver-0.0.11/src/vabackend.c:2064              nvTerminate Now have 0 (0 max) instances

ffmpeg compiled with vaapi support

ffmpeg -hwaccels                                                                                                                             ✔ 
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13.2.1 (GCC) 20230801
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Hardware acceleration methods:
vdpau
cuda
vaapi
qsv
drm
opencl
vulkan

Plz help.

Hi @Adilol,

As far as I’m aware my Firefox uses hardware acceleration. I have set things a long time ago and have actually forgotten most, if not all of it. Nevertheless, these are my settings:

https://i.imgur.com/RCKSigI.png

Just open a new tab, enter and browse to about:config and change those settings. If they don’t exist, feel free to create them.

Hope it helps!

1 Like

The first step is:

sudo nano /etc/default/grub

In /etc/default/grub “add” nvidia_drm.modeset=1 to the GRUB_CMDLINE_LINUX_DEFAULT line

Mit ctrl+O und enter (save) and exit with ctrl+x

sudo update-grub

Just add this command to the line, DO NOT REPLACE anything.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash udev.log_priority=3 nvidia_drm.modeset=1 "
GRUB_CMDLINE_LINUX=""

like this?

nvidia_drm.modeset=1 "

yeah looks good, besides the additional space at the end its not needed… i mean between the command and "

thnx I will try it

Play a video in firefox and while its playing, open another tab and check:

about:support under MEDIA are the video codecs are listed Software/HW Acceleration.

The Video Engine Utilization is still 0 and the codecs show that only h264 and v9 are hardware supported. I am using an extension to block all video formats except those 2

1 Like

See

https://wiki.archlinux.org/title/Firefox#Hardware_video_acceleration

You must install libva-nvidia-driver

As i wrote, it was only step1, you need still activate it in about:config
media.ffmpeg.vaapi.enabled True

I suspect you meant about:config there.

1 Like

yeah true, mistake… i edit that quick :slight_smile:

1 Like

and set in etc/environment

MOZ_DISABLE_RDD_SANDBOX=1

FYI, it’s in the repos as libva-nvidia-driver.

1 Like

Is that really needed?
I think it might have been on certain setups a long time ago (2 years or so?).
Its certainly a security compromise - so do check if you really want/need it.

Ah. Found old bug report that is now closed/fixed.

PS - A note - using /etc/environment means it would be applied everywhere. So it may also affect thunderbird and anything else that might recognize it.

In the future, for things like this, you might consider using a custom .desktop file in ~/.local/share/applications, rather than setting the env var in /etc/environment, to avoid such things.

2 Likes

You are right. You don’t need it anymore.

done man then?

Thank you I am experiencing screen tearing very often until I restart my Ff (sometimes need to do this 2,3 times). That is on Yt (with Enhancer add-on) or sports streaming but I suppose anywhere.

I am only experiencing tearing elsewhere when my monitors slept and I haven’t re-logged in yet. So that’s not too bad, a quick re-login if session is mostly reopened.
But the Ff issue also happen/ed < I hope
also on fresh logins.

Will try your settings (until now, no tearing) and haven’t installed libva-nvidia-driver yet.
Recommended?

:man_shrugging:

I’ve also NEVER experienced any screen tearing, anywhere, anywhen. Because I tend to cap my refresh rates.