HW accelerated video decoding on Firefox (Fedora 38, AMD iGPU and GTX 1650 dGPU)

My setup is:

  • Notebook Acer Nitro 5 with AMD Renoir iGPU and GTX 1650 dGPU
  • Fedora 38
  • GNOME 44 on Wayland
  • Firefox 116
  • Nvidia driver 535.98
  • nvidia-vaapi-driver package installed

Firefox’s about:support page shows:

Compositing = WebRender
GPU 1
Active = Yes
Description = AMD Radeon Graphics (renoir, LLVM 16.0.6, DRM 3.52, 6.4.11-200.fc38.x86_64)
GPU 2
Active = No
Vendor ID = 0x10de
Device ID = 0x1f99

If I run Firefox with DRI_PRIME=1, Compositing changes to WebRender (Software), llvmpipe is reported as active GPU 1, and HARDWARE_VIDEO_DECODING is reported as

runtime | unavailable | Force disabled by gfxInfo | Blocklisted; failure code FEATURE_FAILURE_VIDEO_DECODING_TEST_FAILED

Some relevant Firefox settings have been modified:

media.ffmpeg.vaapi.enabled = true
media.hardware-video-decoding.force-enabled = true

These shell env vars are set:

MOZ_DISABLE_RDD_SANDBOX=1
MOZ_ENABLE_WAYLAND=1
NVD_BACKEND=direct
LIBVA_DRIVER_NAME=nvidia
XDG_SESSION_TYPE=wayland
EGL_PLATFORM=wayland

So, the question is: is it possible to enable HW accelerated video decoding on Firefox with this setup? If so, what am I missing?

Thanks!

I guess the first obstacle is enabling Firefox to correctly detect and use the GTX 1650 as GPU #1 on Wayland.

Maybe you should try without those Wayland wars unset first.

And for avoiding DRI_PRIME var at every launch, you might wanna try editing firefox.desktop to have it set in there.

Hi @VulkanGuy ,

I just tried again without setting the environment vars, and the result was pretty much the same: GPU #1 is detected as llvmpipe, and WebRender falls back to software rendering.

EDIT: running from the console, this is the output:

❯ DRI_PRIME=1 firefox
libEGL warning: egl: failed to create dri2 screen
libEGL warning: egl: failed to create dri2 screen
libEGL warning: egl: failed to create dri2 screen

Also, regardless of the environment variables, if I try to start Firefox from GNOME launcher with the “Launch using Discrete Graphics Card”, Firefox becomes unable to render its content, all windows open completely transparent (only the frames are displayed).

Yes, I will definitely do that once I come to a working solution, but thanks for the suggestion anyway ;-)

FYI DRI_PRIME=1 is not the proper variable for nvidia, just saying
http://us.download.nvidia.com/XFree86/Linux-x86_64/535.104.05/README/primerenderoffload.html

Nice @mmbossoni , thanks for pointing that out!

By setting __NV_PRIME_RENDER_OFFLOAD=1 before launching Firefox, I get the same result as if I had launched it with GNOME’s “Launch using discrete graphics card” option: Firefox’s windows are not rendered. This is how it looks like (had to take a picture):

And this is the console output:

Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Crash Annotation GraphicsCriticalError: |[C0][GFX1-]: CompositorBridgeChild receives IPC close with reason=AbnormalShutdown (t=132.041) Exiting due to channel error.
Crash Annotation GraphicsCriticalError: |[C0][GFX1-]: CompositorBridgeChild receives IPC close with reason=AbnormalShutdown (t=1Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Crash Annotation GraphicsCriticalError: |[C0][GFX1-]: CompositorBridgeChild receives IPC close with reason=AbnormalShutdown (t=135.595) Killed

Only thing I can think of is wayland x xwayland problems.
If you are running wayland, try running firefox in both modes, wayland and xwayland and see which one works. (MOZ_ENABLE_WAYLAND= 1 to enabled wayland mode, 0 to disable/run in xwayland)
If you are on X11, double check egl platform and play with Firefox EGL settings (enabled/disabled) ( MOZ_X11_EGL variable to quick check
But at this point, I would also check firefox bugtracker

I tried with MOZ_ENABLE_WAYLAND=0 and __NV_PRIME_RENDER_OFFLOAD=1, and the result was pretty much the same, except with black windows instead of transparent ones. One thing worth noticing is that Firefox still reports window protocol as being “wayland” with these settings, don’t know if this was expected.

Also, it’s worth noticing that without setting

NVD_BACKEND=direct
MOZ_DISABLE_RDD_SANDBOX=1
EGL_PLATFORM=wayland
LIBVA_DRIVER_NAME=nvidia

Firefox reports that hardware video decoding is available, at least for VP9. This is a step in the right direction, although I would rather be using Nvidia for video decoding instead of Renoir.

I will also post this to Firefox lists to see if they are able to help (I’ve already posted to Fedora’s discussion forum).