omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Hybrid AMD+NVIDIA laptops: global LIBVA_DRIVER_NAME=nvidia makes Firefox decode video on the CPU

Open littleme02 opened this issue 2 months ago • 5 comments

System

  • ASUS ProArt P16 H7606WM: Ryzen AI 9 HX 370 (Radeon 890M iGPU) + RTX 5070 Laptop (GB206)
  • Omarchy 4.0.0.alpha, Hyprland
  • Displays: internal panel, one monitor on the HDMI port (wired to the NVIDIA dGPU), one on USB-C → HDMI (iGPU)

What happens default/hypr/nvidia.lua sets LIBVA_DRIVER_NAME=nvidia (plus NVD_BACKEND=direct) session-wide whenever the NVIDIA GPU has GSP firmware. On a hybrid laptop, Firefox then tries to decode video through the NVIDIA VA-API driver, fails, and falls back to decoding on the CPU. about:support still lists hardware decoding as supported for every codec, even though it isn't actually used.

Measured while playing a YouTube livestream in Firefox:

LIBVA_DRIVER_NAME=nvidia (default) LIBVA_DRIVER_NAME=radeonsi
Firefox RDD (decoder) process ~44 % CPU ~5 % CPU
NVIDIA dGPU P5, ~11.7 W P8, ~4–7 W
CPU temperature ~58 °C ~49 °C (−9 °C)

The extra heat is enough to keep the laptop fans audibly spinning.

Steps to reproduce

  1. Run Omarchy on a hybrid AMD iGPU + NVIDIA (GSP) laptop.
  2. Play a video in Firefox and watch RDD Process in htop.
  3. Close Firefox, run LIBVA_DRIVER_NAME=radeonsi firefox, and play the same video. Decoder CPU usage drops sharply.

Expected On hybrid laptops, video decoding should default to the iGPU (the device driving the desktop), not the discrete NVIDIA card.

Suggestion Only set LIBVA_DRIVER_NAME=nvidia / NVD_BACKEND when the NVIDIA GPU is the only (or primary) GPU. On hybrid systems, leave them unset so libva picks the iGPU's driver. Apps that really want NVIDIA decoding can opt in per app.

Workaround A wrapper at ~/.local/bin/firefox containing LIBVA_DRIVER_NAME=radeonsi exec /usr/lib/firefox/firefox "$@", plus a user copy of firefox.desktop whose Exec= lines point to it.


Diagnosed and written up with Claude Code; measurements taken on my machine.

littleme02 avatar Sep 28 '26 13:09 littleme02

Thanks for the measurements. I think this is already fixed on quattro. Commit 6ecf4bf2 (Sep 13, "Only force NVIDIA VA-API/GLX env when NVIDIA drives the display") now sets LIBVA_DRIVER_NAME=nvidia only when the NVIDIA card is the boot VGA device (bin/omarchy-hw-nvidia-display). On a hybrid laptop where the Radeon iGPU drives the panel, it's left unset. NVD_BACKEND=direct is still set, but only the NVIDIA VA-API driver reads it. I couldn't confirm that the fix is in a tagged release yet.

Once you're on a build that has it, could you check that grep . /sys/bus/pci/devices/*/boot_vga shows the AMD device as 1, and that echo $LIBVA_DRIVER_NAME is empty in a new session? If both are true and Firefox decodes on the iGPU, this can be closed.

jandrusk avatar Oct 07 '26 13:10 jandrusk

Thanks, I tested the detection script from 6ecf4bf2 directly against this machine's sysfs. Unfortunately it still reports NVIDIA as the display GPU (exit 0), so LIBVA_DRIVER_NAME=nvidia would still be set.

The reason: the Strix Point iGPU (Radeon 890M) is PCI class 0x038000 (Display controller, not VGA), so the kernel doesn't create a boot_vga attribute for it at all:

$ cd /sys/bus/pci/devices && for d in 0000:65:00.0 0000:66:00.0; do echo "$d class=$(cat $d/class) vendor=$(cat $d/vendor)"; ls $d/boot_vga && cat $d/boot_vga; done
0000:65:00.0 class=0x030000 vendor=0x10de
0000:65:00.0/boot_vga
0
0000:66:00.0 class=0x038000 vendor=0x1002
ls: cannot access '0000:66:00.0/boot_vga': No such file or directory

No device has boot_vga=1, so the script falls into the "can't tell, assume NVIDIA" path.

Note that #11690 was verified on AMD Phoenix, where the iGPU is VGA-class and has boot_vga=1. The Strix Point iGPU (Ryzen AI 300) is class 0x0380 instead, so AMD + NVIDIA laptops with Strix Point will still get the NVIDIA env, unlike the Phoenix and Intel cases in #11690 and #13785.

A signal that does work here: the internal panel's DRM connector belongs to the AMD device.

$ for c in /sys/class/drm/card*-eDP-*; do echo "$c: $(cat $c/status), device $(basename $(readlink -f $c/device/device))"; done
/sys/class/drm/card1-eDP-1: connected, device 0000:66:00.0

So checking which PCI device owns a connected eDP connector and treating NVIDIA as the display GPU only when it owns the connected eDP (or when there's no eDP at all, as on desktops) would cover hybrid laptops whose iGPU isn't VGA-class. I'd expect this to apply to recent AMD APUs in general, but I've only checked this one machine.

Also: this isn't in a tagged release yet (I'm on 4.0.4), so I can't verify the end-to-end behaviour yet.

littleme02 avatar Oct 07 '26 15:10 littleme02

Thanks, and you're right, I was wrong that 6ecf4bf2 covers this. omarchy-hw-nvidia-display only looks at boot_vga, and the Strix Point iGPU is class 0x0380, so it has no boot_vga attribute. No device claims it, and the script falls through to "assume NVIDIA".

Your connector-ownership idea is what #13659 ("Only export NVIDIA env when NVIDIA drives a display") implements. It checks which GPU owns a connected DRM connector first (skipping Writeback), and only falls back to boot_vga when connectors are on both GPUs or none. On your machine, card1-eDP-1 connected on the AMD device would make it exit 1, so LIBVA_DRIVER_NAME would stay unset. If you can, run that branch's bin/omarchy-hw-nvidia-display against your sysfs (echo $? should print 1) and report on #13659. A real Strix Point data point would help it land.

One case to watch: with an external monitor on a port wired to the NVIDIA card, both GPUs have connected outputs, so it falls back to boot_vga and still picks NVIDIA on this machine.

jandrusk avatar Oct 08 '26 13:10 jandrusk

Tested #13659 on this machine. It fixes the laptop-only case but not with an external monitor on an NVIDIA-wired port. Details in https://github.com/omacom/omarchy/pull/13659#issuecomment-6062146319

littleme02 avatar Oct 08 '26 14:10 littleme02

Reviewed by Claude Opus 5.5 and Codex Medium. #13659 fixes this, and it is now linked so this issue closes when it merges.

Why quattro still sets LIBVA_DRIVER_NAME=nvidia here. bin/omarchy-hw-nvidia-display on quattro decides only from boot_vga. The Radeon 890M has PCI class 0x038000, so it has no boot_vga attribute, and the RTX card's is 0. With no device claiming it, the detector falls back to "assume NVIDIA", and default/hypr/nvidia.lua exports LIBVA_DRIVER_NAME=nvidia and __GLX_VENDOR_LIBRARY_NAME=nvidia.

What #13659 changes. At its head 2f5212d, the detector first asks which GPU owns a connected built-in panel (eDP, LVDS, DSI). That is the rule Aquamarine uses to pick Hyprland's primary GPU, and it comes before boot_vga. Only after that does it look at which GPUs have any connected display, and then at boot_vga. Both of your layouts stop at the panel check, with the eDP on AMD, and get exit 1: panel only, and panel plus USB-C on AMD plus HDMI on NVIDIA. That matches what you measured on the real machine at 2f5212d. The VA-API and GLX overrides are then not set.

What it leaves as it is:

  • NVD_BACKEND=direct is still exported. Only NVIDIA's own VA-API driver reads it, so it does not route Firefox to NVIDIA.
  • Detection happens once, when Hyprland loads its config. With the NVIDIA modules taken out of the initramfs, as in your hibernate workaround, an AMD panel already visible still answers AMD. The hibernate resume failure itself is a separate problem and is not touched here.
  • What has been checked is the detector's exit code, not Firefox decoding end to end. Once #13659 is in a build you run, a fresh login without your LIBVA_DRIVER_NAME=radeonsi override should show echo $LIBVA_DRIVER_NAME empty and the RDD process back near the 5 % you measured.

Nothing was run on a worker for this issue. The fix is verified as its own item on #13659. Codex Medium traced the same detector logic against your sysfs listings and reached the same answer for both layouts. It was given this conclusion to check and may have read this session's notes, so its agreement is not guaranteed to be independent. It added the point above that the end-to-end Firefox result is still unconfirmed.

Whether and when #13659 lands is up to the maintainer.

omarchybot avatar Oct 13 '26 04:10 omarchybot