Page MenuHomeSolus

Firefox VAAPI test task for AMD/Intel GPUs w/OSS drivers
Open, HighPublic

Assigned To
Authored By
ermo
Jun 11 2023, 1:30 PM
Referenced Files
Restricted File
Jun 20 2023, 7:24 PM
Restricted File
Jun 20 2023, 7:24 PM

Description

This task outlines the procedure for testing that ffmpeg-driven VAAPI acceleration in Firefox is considered "working". For this test to pass, when Firefox is playing videos, we verify the GPU on the system is used for rendering.

Note: The Budgie and MATE desktop environments do not yet support Wayland. Gnome currently has support disabled on Solus for now but will be enabled soon™

Prerequisites:

  • Install libva-utils which will allow you to run vainfo

Smoke Test

Run vainfo. Make sure you see sane output like VA-API version, driver version, and a lot of lines with VAEntrypointVLD.

If you get any errors, ❌ STOP ❌ . VAAPI is not working correctly on the system.

Further setup

GPU Check and Firefox config
  • Firefox requires a GPU with support for OpenGL 3.2 or newer or GLES 3.0 or newer to enable hardware acceleration. Verify your hardware supports this with glxinfo | grep "OpenGL.*profile version" for OpenGL and eglinfo | grep version for GLES
  • To support 4k video in Firefox, go to about:config
    • Ensure media.mediasource.webm.enabled is set to true
    • Also make sure you don't have any addons that prefer / force the H264 codec (ideally, run Firefox with a profile that has no extensions installed)
If you have an AMD GPU

Set the following environment variable

LIBVA_DRIVER_NAME=radeonsi
If you have an Intel GPU
  • Install intel-media-driver to support VAAPI.
  • Install intel-gpu-tools to be able to run intel_gpu_top
If you have an nVidia GPU there's a little extra setup:
  • The nvidia-vaapi-driver and nvidia-glx-driver packages must be installed
  • You need to add a kernel boot flag. Create the file /etc/kernel/cmdline.d/10-nvidia.conf and add nvidia-drm.modeset=1, then reboot.
  • Run sudo clr-boot-manager mount-boot
    • UEFI: Check cat /boot/loader/entries/Solus-*.conf | grep nvidia-drm.modeset=1
    • BIOS: Check sudo cat /boot/grub/grub.cfg | grep nvidia-drm.modeset=1
  • Verify that dmesg | grep nvidia-modeset returns output
  • Verify that the kernel is currently loaded with nvidia-modeset with grep nvidia-drm.modeset /proc/cmdline
  • The following environment variables need to be set in your bashrc / zshrc / fish variables:
MOZ_DISABLE_RDD_SANDBOX=1
EGL_PLATFORM=wayland
__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/10_nvidia.json
LIBVA_DRIVER_NAME=nvidia
Firefox setup
  • In Firefox, navigate to about:config
    • Look for the property media.ffmpeg.vaapi.enabled. Create it if it doesn't exist. Set this to "true". Ensure the following values are set as follows:
      • widget.dmabuf.force-enabled true
      • media.rdd-ffmpeg.enabled true
      • gfx.x11-egl.force-enabled true
      • gfx.webrender.software false
  • Restart FF and navigate to about:support and check these under the GPU section:
    • Under Graphics, "Compositing" should be "WebRender" (not "WebRender (Software)")
    • Under GPU#1, "VAAPI" should exist and have
      • available by default
      • force_enabled by user: Force enabled by pref (not present for Intel)
      • blocklisted by env: Blocklisted by gfxinfo (not present for Intel)

Testing

nVidia test:

  1. Start Firefox.
  2. In terminal run nvidia-smi. Note any firefox processes and the Memory-Usage.
  3. Start up a YouTube video.
  4. Re-run nvidia-smi. There should still be firefox process(es), and the Memory-Usage increases, this verifies that Firefox is using hardware rendering.

Intel test:

  1. Start up a YouTube video.
  2. Run sudo intel_gpu_top. You should see the memory utilization go up.

AMD test:

YouTube tests:

Start firefox in terminal so you can see if there are any errors. In particular, look for anything with "VA-API".

MOZ_LOG="PlatformDecoderModule:5" MOZ_X11_EGL=1 firefox

You don't want to see "Failed to create VA-API device context"

Test the following videos at 1080p60 and use right-click -> stats for nerds. If things are working, there should be a field Codecs with something like VP9X (verifying the VP9 codec is in use), and opus

Twitch tests:

IF and only if the above works, test the following Twitch video(s) and use right-click -> stats for nerds to check that HW accel is enabled

  • (...)
  • (...)

Helpful for visuals re. what a test could look like

Firefox Hardware Video Decoding Using VAAPI & Wayland

Report format example:

GPU: Radeon RX Vega 64
Desktop: KDE Plasma Desktop (X11 + Wayland sessions both tested)
System: Up to date -unstable install

Result: Acceleration confirmed working under both X11, XWayland (the default in a Wayland session with the command supplied above?) and Wayland native (MOZ_LOG="PlatformDecoderModule:5" MOZ_X11_EGL=1 MOZ_ENABLE_WAYLAND=1 firefox in a terminal)

Event Timeline

ermo triaged this task as High priority.
ermo edited projects, added Software; removed Lacks Project.

Assigning this to Joey for him to fill out the preferred result format and good video test cases

GPU: Radeon RX Vega 64
Desktop: KDE Plasma Desktop (X11 + Wayland sessions both tested)
System: Up to date -unstable install

Result: Acceleration confirmed working under both X11, XWayland (the default in a Wayland session with the command supplied above?) and Wayland native (MOZ_LOG="PlatformDecoderModule:5" MOZ_X11_EGL=1 MOZ_ENABLE_WAYLAND=1 firefox)

Thanks for the writeup!

I'm a bit concerned re. the necessary manual fiddling re. environment variables for the VA-API backend, as this won't make it trivial to enable hardware decoding automagically?

GPU: AMD Radeon RX 560
Desktop: Budgie Desktop (X11 only)
System: Up to date -unstable install

Result: As far as I can tell, acceleration is working fine. The log has no VA-API failures and the Stats for Nerds on Youtube shows av1/opus in use.

I'm not sure if all the about:config steps are necessary for AMD, as I thought that Firefox enables hardware acceleration by default on AMD (and maybe Intel) systems on Linux, but it doesn't hurt to have it laid out to force it.

An easy way to check for Nvidia cards is :

nvidia-smi dmon

And look if enc ( encoder ) or dec ( decoder ) do sth. while you play a visible video.

You can also look at those stats in the nvidia settings manager.

Sadly i can't test this feature directly, because i switched distro's cause .. well.

Hi,

I tested it and I don't have that "Under GPU#1, "VAAPI" should exist and have".
On the first video the codec shows as av01 and on the second vp9.
Does this means that is working correctly?
AMD rx580 on unstable fully updated Plasma.

Test Result: Failed

GPU: nVidia / Intel GPU on laptop
Desktop: KDE Plasma Desktop (X11 + Wayland sessions both tested)
System: Up to date -unstable install

    1. X11
  • vainfo has good information
  • When playing one of the videos, ran
  • Stats for nerds shows vp09

Started Firefox from command line. Output has errors, attached.

In about:support there is no VAAPI entry under the GPU. Under "Important Modified Preferences". There are numerous errors, screenshot attached.

Troubleshooting

Found this https://github.com/elFarto/nvidia-vaapi-driver/issues/131 which suggested installing intel-media-driver. Did that, rebooted, no change.

Source: https://discourse.ubuntu.com/t/enabling-accelerated-video-decoding-in-firefox-on-ubuntu-21-04/22081
media.ffvpx.enabled to false. Disables the internal software decoders for VP8/VP9, which currently overrule hardware accelerated video.

  • had been set to true, changed to false

media.rdd-vpx.enabled to false. Needed due to Firefox trying to put some video decoding in a remote video process 165. This currently breaks accelerated VP8/VP9 video decoding.

  • had been set to true, changed to false

media.navigator.mediadatadecoder_vpx_enabled to true. Enables hardware decoding for WebRTC, which is used on web based video conferencing apps. Already set to true.

Source:
https://discourse.ubuntu.com/t/enabling-accelerated-video-decoding-in-firefox-on-ubuntu-21-04/22081/24
media.rdd-process.enabled - had been true, set to false.

Restarted Firefox, still see errors in about:support, and in command line

{F10877424}

{F10877427}

GPU: Mesa Intel® HD Graphics 620
Desktop: KDE Plasma Desktop (X11 + Wayland sessions both tested)
System: Up to date install (not unstable)

Result: Acceleration confirmed working under both X11, XWayland (the default in a Wayland session with the command supplied above?) and Wayland native