Yet another thread on Firefox + VAAPI

As apparently many others, I’ve been trying to get hardware acceleration of videos in Firefox by VAAPI to work, without much success.
I’ve been following the instructions on the arch wiki and from what I understand, my hardware should definitely support it, too.
What I’ve acchieved so far:
Firefox uses Webrender, vainfo output seems fine, I think, environment variable (MOZ_EGL_X11=1) is set, playing a youtube video using mpv works with minimal CPU use, as I would expect - but in Firefox CPU use always jumps to ~15-20% for 1080p videos on my 6C/12T CPU.

Here’s my system info:

System:
  Kernel: 5.9.3-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.2.0 
  parameters: BOOT_IMAGE=/vmlinuz-5.9-x86_64 
  root=UUID=... rw 
  cryptdevice=UUID=...:cryptroot quiet 
  udev.log_priority=3 mem_sleep_default=deep 
  Desktop: KDE Plasma 5.20.2 tk: Qt 5.15.1 info: latte-dock wm: kwin_x11 
  dm: SDDM Distro: Manjaro Linux 
Machine:
  Type: Laptop System: LENOVO product: 81YM v: IdeaPad 5 14ARE05 
  serial: <filter> Chassis: type: 10 v: IdeaPad 5 14ARE05 serial: <filter> 
  Mobo: LENOVO model: LNVNB161216 v: No DPK serial: <filter> UEFI: LENOVO 
  v: DTCN20WW(V1.06) date: 06/09/2020 
Battery:
  ID-1: BAT1 charge: 44.9 Wh condition: 56.5/56.5 Wh (100%) volts: 12.3/11.5 
  model: 0x53 0x4D 0x50 0x00 0x32 0x30 0x 0x4C 0x31 0x39 0x4D 0x33 0x50 0x5650 
  type: Li-ion serial: <filter> status: Discharging cycles: 50 
CPU:
  Info: 6-Core model: AMD Ryzen 5 4600U with Radeon Graphics bits: 64 
  type: MT MCP arch: Zen family: 17 (23) model-id: 60 (96) stepping: 1 
  microcode: 8600104 L2 cache: 3072 KiB 
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm 
  bogomips: 50323 
  Speed: 1397 MHz min/max: 1400/2100 MHz boost: enabled Core speeds (MHz): 
  1: 1397 2: 1397 3: 1397 4: 1397 5: 1397 6: 1397 7: 1397 8: 1397 9: 1397 
  10: 1397 11: 1396 12: 1397 
  Vulnerabilities: Type: itlb_multihit status: Not affected 
  Type: l1tf status: Not affected 
  Type: mds status: Not affected 
  Type: meltdown status: Not affected 
  Type: spec_store_bypass 
  mitigation: Speculative Store Bypass disabled via prctl and seccomp 
  Type: spectre_v1 
  mitigation: usercopy/swapgs barriers and __user pointer sanitization 
  Type: spectre_v2 mitigation: Full AMD retpoline, IBPB: conditional, IBRS_FW, 
  STIBP: conditional, RSB filling 
  Type: srbds status: Not affected 
  Type: tsx_async_abort status: Not affected 
Graphics:
  Device-1: AMD Renoir vendor: Lenovo driver: amdgpu v: kernel bus ID: 04:00.0 
  chip ID: 1002:1636 
  Device-2: Syntek Integrated Camera type: USB driver: uvcvideo bus ID: 1-3:2 
  chip ID: 174f:244c serial: <filter> 
  Display: x11 server: X.Org 1.20.9 compositor: kwin_x11 driver: amdgpu 
  FAILED: ati unloaded: modesetting alternate: fbdev,vesa display ID: :0 
  screens: 1 
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.0x11.2") 
  s-diag: 582mm (22.9") 
  Monitor-1: eDP res: 1920x1080 hz: 60 dpi: 158 size: 309x174mm (12.2x6.9") 
  diag: 355mm (14") 
  OpenGL: renderer: AMD RENOIR (DRM 3.39.0 5.9.3-1-MANJARO LLVM 10.0.1) 
  v: 4.6 Mesa 20.2.1 direct render: Yes 
Audio:
  Device-1: AMD vendor: Lenovo driver: snd_hda_intel v: kernel bus ID: 04:00.1 
  chip ID: 1002:1637 
  Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor vendor: Lenovo 
  driver: snd_rn_pci_acp3x v: kernel alternate: snd_pci_acp3x bus ID: 04:00.5 
  chip ID: 1022:15e2 
  Device-3: AMD Family 17h HD Audio vendor: Lenovo driver: snd_hda_intel 
  v: kernel bus ID: 04:00.6 chip ID: 1022:15e3 
  Sound Server: ALSA v: k5.9.3-1-MANJARO 

and vainfo:

vainfo: VA-API version: 1.9 (libva 2.9.1)
vainfo: Driver version: Mesa Gallium driver 20.2.1 for AMD RENOIR (DRM 3.39.0, 5.9.3-1-MANJARO, LLVM 10.0.1)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

What I have not tried so far is something like h264ify, but Youtube seems to use VP9, which should be supported by Renoir’s iGPU.

Any suggestions?

2 Likes

Indeed Firefox VAAPI is broken in Manjaro, tried the KDE live USB today and Firefox outputs errors when using VAAPI and fallbacks to CPU decoding.

1 Like

Manjaro Unstable works fine on my end with manjaro-vaapi installed using Intel video.

Dont just make unsubstantiated claims because you cant configure it.
Theres nothing making it not work on manjaro when it would work on Arch, etc.

For my part it seems to work fine.

Which parts?
What packages do you have installed that you believe are required?
What firefox settings have you configured?

These firefox options are probably the ones in about:config

gfx.webrender.all > true
gfx.webrender.enabled > true
layers.acceleration.force-enabled > true
# media.ffmpeg.dmabuf-textures.enabled > true
media.ffmpeg.vaapi-drm-display.enabled > true
media.ffmpeg.vaapi.enabled > true
# media.ffvpx.enabled > false

(the ones commented out are probably not required but may be nice)

2 Likes

I’ve installed the vaapi-related packeges and seem to have hardware acceleration working fine e.g. in mpv, and to some degree, vlc (which seems to have other issues there, but those probably don’t belong here).
Yet, in Firefox, I always get the same high CPU, no matter what.

I’ve rechecked the options in about:config, but they are already set accordingly.

I have a Renoir CPU as well. Working fine here.

Start Firefox like this and check if it spits out lines with “VA-API” in it:
(Play a video and then check for vaapi…)

MOZ_LOG="PlatformDecoderModule:5" firefox

Stupid question - where does the log end up?
The console output doesn’t contain anything about vaapi, though, only numerous of those:

  [Child 74713: Main Thread]: D/PlatformDecoderModule Sandbox decoder rejects requested type
[Child 74713: Main Thread]: D/PlatformDecoderModule Sandbox decoder supports requested type
[Child 74713: MediaController #2]: D/PlatformDecoderModule Sandbox decoder supports requested type
[Child 74713: MediaController #2]: D/PlatformDecoderModule Sandbox decoder supports requested type
[Child 74713: MediaController #2]: D/PlatformDecoderModule Sandbox decoder supports requested type
[Child 74713: MediaController #2]: D/PlatformDecoderModule Sandbox decoder supports requested type
[Child 74713: MediaPDecoder #1]: D/PlatformDecoderModule AudioTrimmer[0x7f131f9b9660] ::Decode: sample[0,21000] no trimming information
[RDD 74972: MediaPDecoder #2]: D/PlatformDecoderModule OpusDataDecoder[0x7f8e06f650b0] ::Decode: Opus decoder skipping 312 of 960 frames
[Child 74713: MediaPDecoder #1]: D/PlatformDecoderModule AudioTrimmer[0x7f131f9b9660] ::HandleDecodedResult: sample[0,21000] (decoded[0,13500] no trimming needed
[RDD 74972: MediaPDecoder #1]: D/PlatformDecoderModule DAV1DDecoder[0x7f8e06fa2ab0] ::GetPicture: Decode error: -11
[RDD 74972: MediaPDecoder #3]: D/PlatformDecoderModule DAV1DDecoder[0x7f8e06fa2ab0] ::GetPicture: Decode error: -11

Seems you are trying to play a video with AV1 codec.
That codec is not supported to be decoded in hw by renoir.
Try some other video with VP9 or H264 for example.

https://www.youtube.com/watch?v=8Kb8s0P9D4I

Same CPU use - hovers around ~10% total, which is about one core fully occupied.
And still no mention whatsoever of vaapi:

[Child 81972: MediaPDecoder #4]: D/PlatformDecoderModule AudioTrimmer[0x7f44f145afc0] ::HandleDecodedResult: sample[34401000,34421000] (decoded[34394500,34414500] no trimming needed
[Child 81972: MediaPDecoder #4]: D/PlatformDecoderModule Got one frame output with pts=32800000 dts=32800000 duration=40000 opaque=-9223372036854775808
[Child 81972: MediaPDecoder #4]: D/PlatformDecoderModule AudioTrimmer[0x7f44f145afc0] ::Decode: sample[34421000,34441000] no trimming information
[Child 81972: MediaPDecoder #5]: D/PlatformDecoderModule AudioTrimmer[0x7f44f145afc0] ::HandleDecodedResult: sample[34421000,34441000] (decoded[34414500,34434500] no trimming needed
[Child 81972: MediaPDecoder #5]: D/PlatformDecoderModule Got one frame output with pts=32840000 dts=32840000 duration=40000 opaque=-9223372036854775808
[Child 81972: MediaPDecoder #5]: D/PlatformDecoderModule AudioTrimmer[0x7f44f145afc0] ::Decode: sample[34441000,34461000] no trimming information
[Child 81972: MediaPDecoder #4]: D/PlatformDecoderModule AudioTrimmer[0x7f44f145afc0] ::HandleDecodedResult: sample[34441000,34461000] (decoded[34434500,34454500] no trimming needed

If I picked a AV1 vid, that was by accident, I had also tried various VP9 before.

Yeah then, it’s indeed not switched on.

Try this config setting:
gfx.webrender.all = true

And then start with:
MOZ_EGL_X11=1 MOZ_LOG="PlatformDecoderModule:5" firefox

No, no change, but that’s no wonder, I had already set all of those variables…

Ok, sorry, no clue then. Working for me on cinnamon unstable.

1 Like

By the way, which driver is being used by vaapi on your system?
Did you also install vdpau or just vaapi?

$ pacman -Qs 'libva|vdpau|mesa|amd'   
amd-ucode 20201113.r1774.2ea8667-1
    Microcode update files for AMD CPUs
glu 9.0.1-2
    Mesa OpenGL Utility library
lib32-libva 2.8.0-1
    Video Acceleration (VA) API for Linux (32-bit)
lib32-libva-mesa-driver 20.2.2-2
    VA-API implementation for gallium (32-bit)
lib32-libva-vdpau-driver 0.7.4-6
    VDPAU backend for VA API (32-bit)
lib32-libvdpau 1.4-1
    Nvidia VDPAU library
lib32-mesa 20.2.2-2
    An open-source implementation of the OpenGL specification (32-bit)
lib32-mesa-vdpau 20.2.2-2
    Mesa VDPAU drivers (32-bit)
lib32-vulkan-intel 20.2.2-2
    Intels Vulkan mesa driver (32-bit)
lib32-vulkan-radeon 20.2.2-2
    Radeons Vulkan mesa driver (32-bit)
libva 2.9.1-1
    Video Acceleration (VA) API for Linux
libva-mesa-driver 20.2.2-2
    VA-API implementation for gallium
libva-utils 2.9.1-1
    Intel VA-API Media Applications and Scripts for libva
libva-vdpau-driver 0.7.4-4
    VDPAU backend for VA API
libvdpau 1.4-1
    Nvidia VDPAU library
libvdpau-va-gl 0.4.2-3
    VDPAU driver with OpenGL/VAAPI backend
mesa 20.2.2-2
    An open-source implementation of the OpenGL specification
mesa-demos 8.4.0-4
    Mesa demos and tools incl. glxinfo + glxgears
mesa-vdpau 20.2.2-2
    Mesa VDPAU drivers
mhwd-amdgpu 19.1.0-1
    MHWD module-ids for amdgpu
vamp-plugin-sdk 2.10.0-1 (pro-audio)
    The Vamp audio analysis plug-in system
vdpauinfo 1.4-1
    Command line utility for querying the capabilities of a VDPAU device
vulkan-intel 20.2.2-2
    Intels Vulkan mesa driver
vulkan-radeon 20.2.2-2
    Radeons Vulkan mesa driver
xf86-video-amdgpu 19.1.0-2 (xorg-drivers)
    X.org amdgpu video driver

(I removed some local things unrelated)

1 Like

Thanks!

Only differences I spot are that I was missing libvdpau-va-gl, which I have installed now (no change) and you are on a slightly newer version of some mesa packages. Are you using Testing branch?

I am on Unstable. So makes sense.

I doubt that the slightly newer Mesa branch is responsible here, but if so, it will eventually fix itself…

In the meantime, I might check out creating a new Firefox profile or play around with a few other settings. It’s strange, though, vaapi works in mpv, but is completely ignored in Firefox…

I found the solution! It’s actually rather simple and I was being stupid…

It’s not MOZ_EGL_X11=1, it’s MOZ_X11_EGL=1 :man_facepalming:

I guess it’s possible, that in the process of trying to fix this issue, I might have done something else, e.g. set a variable I had forgot earlier, or installed some missing package - but ultimately the issue was the above setting.
I had previously misspelled it and never checked on it thereafter.

Well, at least it works now, CPU use is much lower, just a few hours lost over it… :smiley:

Good you found it.
BTW … my preferred way of changing the firefox default env vars is like this:

  • Copy firefox.desktop file from /usr/share/applications to ~/.local/share/applications

  • Edit each Exec line to contain your values like this (I also set some for plasma integration):

Exec=/usr/bin/sh -c "MOZ_X11_EGL=1 GTK_USE_PORTAL=1 /usr/lib/firefox/firefox %u"
Exec=/usr/bin/sh -c "MOZ_X11_EGL=1 GTK_USE_PORTAL=1 /usr/lib/firefox/firefox --new-window %u"
Exec=/usr/bin/sh -c "MOZ_X11_EGL=1 GTK_USE_PORTAL=1 /usr/lib/firefox/firefox --private-window %u"

Then whenever you start FF from a key combo or link or menu … it will use your variables.
(and you arent editing a system file, which also means it wont overwrite during an update etc)

1 Like

A post was merged into an existing topic: Vaapi errors with intel i965