Firefox vaapi acceleration broken with PRIME (intel+nvidia)

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.

done

[geminis3@helios300 ~]$ inxi -Fazy
System:
  Kernel: 5.4.77-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.2.0 
  parameters: BOOT_IMAGE=/boot/vmlinuz-5.4-x86_64 
  root=UUID=eed8d975-1eaf-4bfe-8d77-e098495e039b rw quiet apparmor=1 
  security=apparmor udev.log_priority=3 
  Desktop: KDE Plasma 5.20.3 tk: Qt 5.15.1 wm: kwin_x11 dm: SDDM 
  Distro: Manjaro Linux 
Machine:
  Type: Laptop System: Acer product: Predator G3-571 v: V1.22 serial: <filter> 
  Mobo: KBL model: Sienta_KLS v: V1.22 serial: <filter> UEFI: Insyde v: 1.22 
  date: 03/15/2019 
Battery:
  ID-1: BAT1 charge: 43.0 Wh condition: 43.0/48.9 Wh (88%) volts: 16.8/15.2 
  model: LG 004B384234314341 type: Li-ion serial: <filter> status: Full 
CPU:
  Info: Quad Core model: Intel Core i7-7700HQ bits: 64 type: MT MCP 
  arch: Kaby Lake family: 6 model-id: 9E (158) stepping: 9 microcode: DE 
  L2 cache: 6144 KiB 
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx 
  bogomips: 44817 
  Speed: 900 MHz min/max: 800/3800 MHz Core speeds (MHz): 1: 900 2: 900 3: 900 
  4: 899 5: 900 6: 900 7: 900 8: 900 
  Vulnerabilities: Type: itlb_multihit status: KVM: Split huge pages 
  Type: l1tf 
  mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable 
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable 
  Type: meltdown mitigation: PTI 
  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 generic retpoline, IBPB: conditional, 
  IBRS_FW, STIBP: conditional, RSB filling 
  Type: srbds mitigation: Microcode 
  Type: tsx_async_abort status: Not affected 
Graphics:
  Device-1: Intel HD Graphics 630 vendor: Acer Incorporated ALI driver: i915 
  v: kernel bus ID: 00:02.0 chip ID: 8086:591b 
  Device-2: NVIDIA GP106M [GeForce GTX 1060 Mobile] 
  vendor: Acer Incorporated ALI driver: nvidia v: 455.45.01 
  alternate: nouveau,nvidia_drm bus ID: 01:00.0 chip ID: 10de:1c20 
  Device-3: Chicony HD WebCam type: USB driver: uvcvideo bus ID: 1-9:4 
  chip ID: 04f2:b5f7 
  Display: x11 server: X.Org 1.20.9 compositor: kwin_x11 
  driver: modesetting,nvidia alternate: fbdev,intel,nouveau,nv,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-1 res: 1920x1080 hz: 60 dpi: 142 size: 344x193mm (13.5x7.6") 
  diag: 394mm (15.5") 
  OpenGL: renderer: Mesa Intel HD Graphics 630 (KBL GT2) v: 4.6 Mesa 20.2.2 
  direct render: Yes 
Audio:
  Device-1: Intel CM238 HD Audio vendor: Acer Incorporated ALI 
  driver: snd_hda_intel v: kernel bus ID: 00:1f.3 chip ID: 8086:a171 
  Sound Server: ALSA v: k5.4.77-1-MANJARO 
Network:
  Device-1: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter 
  vendor: Lite-On driver: ath10k_pci v: kernel port: 4000 bus ID: 02:00.0 
  chip ID: 168c:003e 
  IF: wlp2s0 state: up mac: <filter> 
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  vendor: Acer Incorporated ALI driver: r8169 v: kernel port: 3000 
  bus ID: 03:00.1 chip ID: 10ec:8168 
  IF: enp3s0f1 state: down mac: <filter> 
Drives:
  Local Storage: total: 1.02 TiB used: 15.72 GiB (1.5%) 
  SMART Message: Unable to run smartctl. Root privileges required. 
  ID-1: /dev/nvme0n1 vendor: Western Digital model: WDS100T2B0C-00PXH0 
  size: 931.51 GiB block size: physical: 512 B logical: 512 B speed: 31.6 Gb/s 
  lanes: 4 serial: <filter> rev: 211070WD scheme: GPT 
  ID-2: /dev/sda vendor: Kingston model: SA400S37120G size: 111.79 GiB 
  block size: physical: 512 B logical: 512 B speed: 6.0 Gb/s serial: <filter> 
  rev: B1E2 scheme: GPT 
Partition:
  ID-1: / raw size: 111.49 GiB size: 109.24 GiB (97.98%) 
  used: 15.72 GiB (14.4%) fs: ext4 dev: /dev/sda2 
Swap:
  Kernel: swappiness: 60 (default) cache pressure: 100 (default) 
  ID-1: swap-1 type: file size: 2.00 GiB used: 0 KiB (0.0%) priority: -2 
  file: /swapfile 
Sensors:
  System Temperatures: cpu: 52.5 C mobo: 29.8 C 
  Fan Speeds (RPM): N/A 
Info:
  Processes: 241 Uptime: 10m Memory: 15.53 GiB used: 1.68 GiB (10.8%) 
  Init: systemd v: 246 Compilers: gcc: 10.2.0 Packages: pacman: 1277 lib: 365 
  flatpak: 0 Shell: Bash v: 5.0.18 running in: konsole inxi: 3.1.08

No it doesn’t, I already have manjaro-vaapi package installed and Firefox setup correctly.

[geminis3@helios300 ~]$ vainfo --display drm --device /dev/dri/renderD128
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
vaInitialize failed with error code -1 (unknown libva error),exit

default vainfo output

[geminis3@helios300 ~]$ vainfo
vainfo: VA-API version: 1.9 (libva 2.9.1)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.4.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

setting LIBVA_DRIVER_NAME=i965 now gives

[geminis3@helios300 ~]$ vainfo --display drm --device /dev/dri/renderD128
libva error: /usr/lib/dri/i965_drv_video.so init failed
vaInitialize failed with error code -1 (unknown libva error),exit

now iHD

[geminis3@helios300 ~]$ LIBVA_DRIVER_NAME=iHD vainfo --display drm --device /dev/dri/renderD128    
DRM_IOCTL_I915_GEM_APERTURE failed: Invalid argument
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
libva error: /usr/lib/dri/iHD_drv_video.so init failed
vaInitialize failed with error code 18 (invalid parameter),exit

And what about

mhwd -li
[geminis3@helios300 ~]$ mhwd -li
> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-455xx-prime            2020.10.04               false            PCI
     video-modesetting            2020.01.13                true            PCI


Warning: No installed USB configs!

First it seems like your initial output is using the iHD alright.

Kinda funny you get the other outputs.

I guess I wonder 2 things … do you have linux-firmware installed?
Same goes for libvdpau-va-gl ?

Oh … also … ls /dev/dri … I notice I get a error running on ‘card0’ but not ‘renderD128’ there

yes

no, but just installed no difference

If that helps, this is my output on Ubuntu live ISO

ubuntu@ubuntu:~$ vainfo --display drm --device /dev/dri/renderD128
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
ubuntu@ubuntu:~$ vainfo --display drm --device /dev/dri/renderD129
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nouveau_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Mesa Gallium driver 20.0.8 for NV136
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc

EDIT: looks like outputs are somehow inverted on Manjaro, from the Ubuntu output D128 appears to be the iGPU and D129 the Nvidia dGPU

So there we are. Different addresses.
I am guessing that now when you point it at the correct location it works?
(and conversely if you use prime-run and check vdpau on the opposite it works)

Again … your output when you dont manually choose the path seems to verify it is working fine.

If your issue is with the performance of some application then maybe we could look at that.

The problem is that Firefox seems to be using D128 for VAAPI calls, Chromium or VLC works without problems. Btw VDPAU it’s not supported by Firefox so it’s VAAPI or nothing if you want accelerated video playback.

Like I said on Ubuntu distros Firefox gets the correct VAAPI location and works fine on my laptop but I prefer Manjaro tbh.

I wonder then.
What about using the environment variable with it?

LIBVA_DRIVER_NAME=iHD firefox

(and the proper about:config edits, and MOZ_X11_EGL=1 if using X and not set already)

And further … can you check with removing libva-vdpau-driver ? I have a suspicion it may be forcing vaapi to try to use vdpau, which may look for the nvidia…


PS. Worst case scenario there is another variable which could set the path manually:
LIBVA_DRIVERS_PATH

It doesn’t works

[Child 1917, MediaDecoderStateMachine #1] WARNING: Decoder=7f94f98d3800 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - RefPtr<MediaSourceTrackDem
uxer::SamplesPromise> mozilla::MediaSourceTrackDemuxer::DoGetSamples(int32_t): manager is detached.: file /build/firefox/src/firefox-83.0/dom/media/MediaDec
oderStateMachine.cpp:3471
[Child 1917, MediaDecoderStateMachine #1] WARNING: Decoder=7f94f98d3800 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - RefPtr<MediaSourceTrackDem
uxer::SamplesPromise> mozilla::MediaSourceTrackDemuxer::DoGetSamples(int32_t): manager is detached.: file /build/firefox/src/firefox-83.0/dom/media/MediaDec
oderStateMachine.cpp:3471
[Child 1917, MediaDecoderStateMachine #1] WARNING: Decoder=7f94f98d3800 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - RefPtr<MediaSourceTrackDem
uxer::SamplesPromise> mozilla::MediaSourceTrackDemuxer::DoGetSamples(int32_t): manager is detached.: file /build/firefox/src/firefox-83.0/dom/media/MediaDec
oderStateMachine.cpp:3471
[Child 1917, MediaDecoderStateMachine #1] WARNING: Decoder=7f94f98d3800 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - RefPtr<MediaSourceTrackDem
uxer::SamplesPromise> mozilla::MediaSourceTrackDemuxer::DoGetSamples(int32_t): manager is detached.: file /build/firefox/src/firefox-83.0/dom/media/MediaDec
oderStateMachine.cpp:3471
[Child 1917, MediaDecoderStateMachine #1] WARNING: Decoder=7f94f98d3800 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - RefPtr<MediaSourceTrackDem
uxer::SamplesPromise> mozilla::MediaSourceTrackDemuxer::DoGetSamples(int32_t): manager is detached.: file /build/firefox/src/firefox-83.0/dom/media/MediaDec
oderStateMachine.cpp:3471
DRM_IOCTL_I915_GEM_APERTURE failed: Argumento inválido
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
libva error: /usr/lib/dri/iHD_drv_video.so init failed

Appears to be working now after manually adding i915 module to mkinitpcio

EDIT: vainfo now displays the correct info on D128, Nvidia propietary doesn’t supports VAAPI so I think it’s normal for D129 to give errors

[geminis3@helios300 ~]$ vainfo --display drm --device /dev/dri/renderD128
vainfo: VA-API version: 1.9 (libva 2.9.1)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.4.1 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
[geminis3@helios300 ~]$ vainfo --display drm --device /dev/dri/renderD129
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
vaInitialize failed with error code -1 (unknown libva error),exit

Ah.
Interesting to note.
I guess that isnt explicitly stated anywhere (like the archwiki for example).

I dont think we currently auto-add anything to mkinitcpio … but it could make sense to.
And in the case of optimus, it would make sense to put i915 there.

:thinking:

1 Like

I’m not the expert to measure the technical consequences of doing that by default but it will help newbie users with PRIME laptops, btw thanks for your kind help.

As we currently add configs during mhwd profile installation to xorg.conf.d I dont see why we couldnt do something similar with mkinitcpio. Its certainly something I set on all my systems.
(mine has sd_mod ahci ext4 amdgpu … including modules you know you use will generally result in quicker boot times if nothing else)
Thanks for reporting and troubleshooting :slight_smile:

1 Like

As a side note using optimus-manager to turn off the dGPU (I have a separate NVMe for Windows gaming) using nouveau and PCI power control also fixes the VAAPI problem without requiring to modify the mkinitpcio…

Just adding this if anyone with the same problem stumbles up to this thread and has a similar usercase.