Firefox snap GPU detection and usage

Hello folks,

I recently upgraded to Ubuntu 22.04 and hence for the first time am using the Firefox snap package. I’m having a few problems particularly with video playback, where it looks like Firefox is not using the GPU effectively (video playback on e.g. YouTube can sometimes be very un-smooth and uses a lot of CPU).

First, Firefox detects only the integrated Intel graphics chipset but not the NVIDIA GPU that is also in my laptop. In addition, looking at the about:support page shows that a number of graphics options are blocklisted by gfxInfo, including HARDWARE_VIDEO_DECODING.

I’m not sure that the latter are different from the defaults for earlier non-snap installs, but I wanted to check if there were any known constraints with the snap package that might be causing the video playback issues or the failure to detect the GPU. As far as I can tell all the snap connections are as they should be, including the hardware-observe and opengl interfaces:

audio-playback            firefox:audio-playback                         :audio-playback                  -
audio-record              firefox:audio-record                           :audio-record                    -
avahi-observe             firefox:avahi-observe                          :avahi-observe                   -
browser-support           firefox:browser-sandbox                        :browser-support                 -
camera                    firefox:camera                                 :camera                          -
content[gnome-3-38-2004]  firefox:gnome-3-38-2004                        gnome-3-38-2004:gnome-3-38-2004  -
content[gtk-3-themes]     firefox:gtk-3-themes                           gtk-common-themes:gtk-3-themes   -
content[icon-themes]      firefox:icon-themes                            gtk-common-themes:icon-themes    -
content[sound-themes]     firefox:sound-themes                           gtk-common-themes:sound-themes   -
desktop                   firefox:desktop                                :desktop                         -
desktop-legacy            firefox:desktop-legacy                         :desktop-legacy                  -
gsettings                 firefox:gsettings                              :gsettings                       -
hardware-observe          firefox:hardware-observe                       :hardware-observe                -
home                      firefox:home                                   :home                            -
joystick                  firefox:joystick                               :joystick                        -
mount-control             firefox:host-hunspell                          :mount-control                   -
network                   firefox:network                                :network                         -
network-bind              firefox:network-bind                           :network-bind                    -
opengl                    firefox:opengl                                 :opengl                          -
personal-files            firefox:dot-mozilla-firefox                    :personal-files                  -
removable-media           firefox:removable-media                        :removable-media                 -
screen-inhibit-control    firefox:screen-inhibit-control                 :screen-inhibit-control          -
system-files              firefox:etc-firefox                            :system-files                    -
system-packages-doc       firefox:system-packages-doc                    :system-packages-doc             -
u2f-devices               firefox:u2f-devices                            :u2f-devices                     -
unity7                    firefox:unity7                                 :unity7                          -
upower-observe            firefox:upower-observe                         :upower-observe                  -
wayland                   firefox:wayland                                :wayland                         -
x11                       firefox:x11                                    :x11                             -

My system is using the nvidia-driver-525 if that is relevant to the GPU detection.

Apologies if this is not snap-related, but I wanted to check in case it’s a known limitation.

Thanks and best wishes,

  -- Joe

I don’t think this is related to snap. I’m on 22.04 with the same nvidia driver (and running xorg, not wayland) and compared about:support in the Snap version of Firefox 108b9 and Firefox 108 from the Mozilla PPA and got the same.

When executing /usr/bin/firefox from the terminal I get the following:

[GFX1-]: glxtest: VA-API test failed: failed to initialise VAAPI connection.

Even when force-enabling hardware video decoding through about:config it gets disabled.

You could try installing Firefox from the PPA to compare, but you’ll probably get the same issue

2 Likes

Belated thanks for the advice! You’re correct that the GPU detection is not related to the snap package. After some investigation I discovered that what I observed is down to the prime-select option, which is set to on-demand – hence the NVIDIA GPU is only used if I launch firefox with the “Launch using discrete graphics card” option.

If I prime-select nvidia and reboot, then the NVIDIA card is used by default, but that seems more sluggish than when the integrated Intel graphics are used for some reason, so I’ve gone back to the on-demand choice for the time being.

The VAAPI connection also fails on my system and that seems to be responsible for the failure to use hardware video decoding. I’ve installed the appropriate drivers and support packages on the host system as well as tweaking the Firefox flags.

Are you having issues with the VA-API connection when using the Intel GPU? I don’t have a machine with Intel graphics to test on right now, but as far as I know, using the Intel graphics should have Firefox properly connecting to VAAPI. If you force Intel graphics for Firefox and are able to get hardware acceleration in the Firefox snap, that’s likely the best you’re going to get (which should be fine for most browser things - if you’re just looking for hardware-accelerated video decoding, the Intel chip is likely to be as good as or better than the Nvidia chip when considering energy consumption too).

However, if you install Firefox from the Mozilla PPA and are able to get graphics acceleration but the snap version can’t, this is likely an issue with the snap packaging.

If you have some time to play with it, could you try that? Force the Intel graphics and compare the HARDWARE_VIDEO_DECODING results in about:support between the PPA and the Snap? If it’s different, we definitely want to report it to the maintainers of the FF Snap. If VAAPI still doesn’t work with the version installed from the PPA, it might be worth further investigating your system setup to see why.

If you really want to use the Nvidia GPU for Firefox and to use VAAPI, you could try installing This nvidia vaapi driver, but unless you want to upgrade to 22.10 you’ll be needing to build it yourself. It’s likely, though, that you’ll get a better overall experience if you just force Firefox to use the Intel GPU.

1 Like

@lengau, thanks so much for taking the time to follow up on this.

I haven’t been able to get the VAAPI connection working, either on this or on another machine that only has Intel graphics. I know that there have been issues with this related to the snap package sandboxing, but these are supposedly fixed as of FF 102, and I’m running 108.0.1.

I’ll describe both systems, and what I’ve done to try to (unsuccessfully so far) get hardware acceleration working. I’ll split this across several posts, and will explicitly note when I’m done.

System 1 (the system referred to in previous posts)

Overview

  • Lenovo ThinkPad P14s Gen 1 (2 years old), i7-10510U CPU @ 1.80GHz * 8, 32.0 GiB RAM. Hybrid graphics: NVIDIA Corporation GP108GLM [Quadro P520] / Mesa Intel® UHD Graphics (CML GT2)
  • OS: Ubuntu 22.04, upgraded in-place from an earlier 20.04 install (hence FF user profile is inherited from earlier install)
  • X11 windowing system (I don’t think I even see an option to log in with Wayland)
  • FF 108.0.1-1, snap rev 2211
  • FF add-ons: FF Multi-Account Containers, Privacy Badger, uBlock Origin
  • FF video playback worked fine in the earlier 20.04 install, the problems have shown up only since the 22.04 upgrade. Unfortunately I can’t readily compare before/after FF or prime-select settings, as I didn’t record them before the OS upgrade.
  • generally FF performance feels more sluggish since the 22.04 update: video playback is consistently a little out of sync (e.g. mouth movements a little behind spoken audio) and regularly gets to a point of the video playback seeming to take a lot of resources, get very sluggish (lots of dropped/skipped frames, high CPU usage), etc. etc.
  • video playback seems to get worse if the NVIDIA card is used, whether by using the “Launch using Discrete Graphics Card” option or by using prime-select nvidia so that the NVIDIA card is the default (in either case, the immediate desync is a bit more noticeable and the move to very-sluggish behaviour happens much faster: in the case of on-demand use of the NVIDIA card, that impact seems to persist even when I switch back to running FF using the Intel GPU)
  • using intel_gpu_top and nvtop clearly shows that neither GPU is being engaged for video playback

I’ve attempted to enable VAAPI as per the instructions here: https://ubuntuhandbook.org/index.php/2021/08/enable-hardware-video-acceleration-va-api-for-firefox-in-ubuntu-20-04-18-04-higher/

Intel driver setup

$ dpkg -l | grep -e "intel" -e "i965"
ii  i965-va-driver:amd64                       2.4.1+dfsg1-1                           amd64        VAAPI driver for Intel G45 & HD Graphics family
ii  intel-gpu-tools                            1.26-2                                  amd64        tools for debugging the Intel graphics driver
ii  intel-media-va-driver:amd64                22.3.1+dfsg1-1ubuntu1                   amd64        VAAPI driver for the Intel GEN8+ Graphics family
ii  intel-microcode                            3.20220809.0ubuntu0.22.04.1             amd64        Processor microcode firmware for Intel CPUs
ii  libdrm-intel1:amd64                        2.4.110-1ubuntu1                        amd64        Userspace interface to intel-specific kernel DRM services -- runtime
ii  xserver-xorg-video-intel                   2:2.99.917+git20210115-1                amd64        X.Org X server -- Intel i8xx, i9xx display driver

NVIDIA driver setup

$ dpkg -l | grep ^ii | grep nvidia
ii  libnvidia-cfg1-510:amd64                   510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA binary OpenGL/GLX configuration library
ii  libnvidia-common-510                       510.108.03-0ubuntu0.22.04.1             all          Shared files used by the NVIDIA libraries
ii  libnvidia-compute-510:amd64                510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA libcompute package
ii  libnvidia-compute-510:i386                 510.108.03-0ubuntu0.22.04.1             i386         NVIDIA libcompute package
ii  libnvidia-decode-510:amd64                 510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA Video Decoding runtime libraries
ii  libnvidia-decode-510:i386                  510.108.03-0ubuntu0.22.04.1             i386         NVIDIA Video Decoding runtime libraries
ii  libnvidia-egl-wayland1:amd64               1:1.1.9-1.1                             amd64        Wayland EGL External Platform library -- shared library
ii  libnvidia-encode-510:amd64                 510.108.03-0ubuntu0.22.04.1             amd64        NVENC Video Encoding runtime library
ii  libnvidia-encode-510:i386                  510.108.03-0ubuntu0.22.04.1             i386         NVENC Video Encoding runtime library
ii  libnvidia-extra-510:amd64                  510.108.03-0ubuntu0.22.04.1             amd64        Extra libraries for the NVIDIA driver
ii  libnvidia-fbc1-510:amd64                   510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-fbc1-510:i386                    510.108.03-0ubuntu0.22.04.1             i386         NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-gl-510:amd64                     510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  libnvidia-gl-510:i386                      510.108.03-0ubuntu0.22.04.1             i386         NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  nvidia-compute-utils-510                   510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA compute utilities
ii  nvidia-dkms-510                            510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA DKMS package
ii  nvidia-driver-510                          510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA driver metapackage
ii  nvidia-kernel-common-510                   510.108.03-0ubuntu0.22.04.1             amd64        Shared files used with the kernel module
ii  nvidia-kernel-source-510                   510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA kernel source package
ii  nvidia-prime                               0.8.17.1                                all          Tools to enable NVIDIA's Prime
ii  nvidia-settings                            525.60.13-0ubuntu1                      amd64        Tool for configuring the NVIDIA graphics driver
ii  nvidia-utils-510                           510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA driver support binaries
ii  screen-resolution-extra                    0.18.2                                  all          Extension for the nvidia-settings control panel
ii  xserver-xorg-video-nvidia-510              510.108.03-0ubuntu0.22.04.1             amd64        NVIDIA binary Xorg driver

I have also tried using the 525 driver direct from NVIDIA’s own CUDA repo, which seems to make matters even worse (for some reason, for both Intel and NVIDIA based browser runs). You can see one legacy of this as nvidia-settings is 525.60.13-0ubuntu1. I have not yet tried disabling the CUDA repo and reinstalling the NVIDIA packages, but can do so.

Mesa drivers

$ dpkg -l | grep mesa
ii  libegl-mesa0:amd64                         22.0.5-0ubuntu0.1                       amd64        free implementation of the EGL API -- Mesa vendor library
ii  libgl1-mesa-dri:amd64                      22.0.5-0ubuntu0.1                       amd64        free implementation of the OpenGL API -- DRI modules
ii  libgl1-mesa-dri:i386                       22.0.5-0ubuntu0.1                       i386         free implementation of the OpenGL API -- DRI modules
ii  libglapi-mesa:amd64                        22.0.5-0ubuntu0.1                       amd64        free implementation of the GL API -- shared library
ii  libglapi-mesa:i386                         22.0.5-0ubuntu0.1                       i386         free implementation of the GL API -- shared library
ii  libglu1-mesa:amd64                         9.0.2-1                                 amd64        Mesa OpenGL utility library (GLU)
ii  libglx-mesa0:amd64                         22.0.5-0ubuntu0.1                       amd64        free implementation of the OpenGL API -- GLX vendor library
ii  libglx-mesa0:i386                          22.0.5-0ubuntu0.1                       i386         free implementation of the OpenGL API -- GLX vendor library
ii  mesa-utils                                 8.4.0-1ubuntu1                          amd64        Miscellaneous Mesa utilities -- symlinks
ii  mesa-utils-bin:amd64                       8.4.0-1ubuntu1                          amd64        Miscellaneous Mesa utilities -- native applications
ii  mesa-va-drivers:amd64                      22.0.5-0ubuntu0.1                       amd64        Mesa VA-API video acceleration drivers
ii  mesa-vdpau-drivers:amd64                   22.0.5-0ubuntu0.1                       amd64        Mesa VDPAU video acceleration drivers
ii  mesa-vulkan-drivers:amd64                  22.0.5-0ubuntu0.1                       amd64        Mesa Vulkan graphics drivers
ii  mesa-vulkan-drivers:i386                   22.0.5-0ubuntu0.1                       i386         Mesa Vulkan graphics drivers

VAAPI packages

$ dpkg -l | grep -e "libva" -e "va-driver" -e "vaapi"
ii  gstreamer1.0-vaapi:amd64                   1.20.1-1ubuntu1                         amd64        VA-API plugins for GStreamer
ii  i965-va-driver:amd64                       2.4.1+dfsg1-1                           amd64        VAAPI driver for Intel G45 & HD Graphics family
ii  intel-media-va-driver:amd64                22.3.1+dfsg1-1ubuntu1                   amd64        VAAPI driver for the Intel GEN8+ Graphics family
ii  libva-drm2:amd64                           2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- DRM runtime
ii  libva-glx2:amd64                           2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- GLX runtime
ii  libva-wayland2:amd64                       2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- Wayland runtime
ii  libva-x11-2:amd64                          2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- X11 runtime
ii  libva2:amd64                               2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- runtime
ii  mesa-va-drivers:amd64                      22.0.5-0ubuntu0.1                       amd64        Mesa VA-API video acceleration drivers
ii  va-driver-all:amd64                        2.14.0-1                                amd64        Video Acceleration (VA) API -- driver metapackage

vainfo output

$ prime-select query
on-demand

$ vainfo
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.3.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

Firefox settings

Here are screenshots of the relevant about:support sections:

I have no idea where the MOZ_DISABLE_RDD_SANDBOX setting comes from: I can’t track it down in any of my profile/bashrc settings or in any of the system config directories. OTOH .viminfo suggests that I did at some point in history create a config file with that setting, which I now can’t find :-\ EDIT: disappeared after reboot so I think this was a red herring, I must have just manually set or exported it while trying stuff out.

Here are screenshots showing the modified gfx.* and media.* settings in about:config. I don’t know/understand where all the gfx.blacklist settings come from, or whether they were already set before the 22.04 upgrade.

TODO list

  • Try FF from the PPA
  • track down where the MOZ_DISABLE_RDD_SANDBOX env var is getting set EDIT: disappeared after reboot so I think this was a red herring.

System 2 (only Intel graphics)

Overview

  • Lenovo ThinkPad T420 (10 years old), 7-2640M CPU @ 2.80GHz × 4, 8.0 GiB RAM. Mesa Intel® HD Graphics 3000 (SNB GT2)
  • OS: Ubuntu 22.04, fresh install
  • Wayland windowing system (default login option)
  • FF 108.0.1-1, snap rev 2211
  • FF add-ons: Facebook Container, FF Multi-Account Containers, Privacy Badger, uBlock Origin
  • FF video playback works OK (for e.g. YouTube, Netflix, etc.) but can sometimes start to stutter after it’s been running for a while (my suspicion is this happens when CPU gets throttled due to heat)
  • using intel_gpu_top shows that hardware acceleration is not being exploited for video playback

Again, I’ve attempted to enable VAAPI as per the instructions here: https://ubuntuhandbook.org/index.php/2021/08/enable-hardware-video-acceleration-va-api-for-firefox-in-ubuntu-20-04-18-04-higher/

Intel driver setup

$ dpkg -l | grep -e "intel" -e "i965"
ii  i965-va-driver:amd64                       2.4.1+dfsg1-1                           amd64        VAAPI driver for Intel G45 & HD Graphics family
ii  intel-gpu-tools                            1.26-2                                  amd64        tools for debugging the Intel graphics driver
ii  intel-media-va-driver:amd64                22.3.1+dfsg1-1ubuntu1                   amd64        VAAPI driver for the Intel GEN8+ Graphics family
ii  intel-microcode                            3.20220809.0ubuntu0.22.04.1             amd64        Processor microcode firmware for Intel CPUs
ii  libdrm-intel1:amd64                        2.4.110-1ubuntu1                        amd64        Userspace interface to intel-specific kernel DRM services -- runtime
ii  xserver-xorg-video-intel                   2:2.99.917+git20210115-1                amd64        X.Org X server -- Intel i8xx, i9xx display driver

Mesa packages

$ dpkg -l | grep mesa
ii  libegl-mesa0:amd64                         22.0.5-0ubuntu0.1                       amd64        free implementation of the EGL API -- Mesa vendor library
ii  libgl1-mesa-dri:amd64                      22.0.5-0ubuntu0.1                       amd64        free implementation of the OpenGL API -- DRI modules
ii  libglapi-mesa:amd64                        22.0.5-0ubuntu0.1                       amd64        free implementation of the GL API -- shared library
ii  libglu1-mesa:amd64                         9.0.2-1                                 amd64        Mesa OpenGL utility library (GLU)
ii  libglx-mesa0:amd64                         22.0.5-0ubuntu0.1                       amd64        free implementation of the OpenGL API -- GLX vendor library
ii  mesa-va-drivers:amd64                      22.0.5-0ubuntu0.1                       amd64        Mesa VA-API video acceleration drivers
ii  mesa-vulkan-drivers:amd64                  22.0.5-0ubuntu0.1                       amd64        Mesa Vulkan graphics drivers

VAAPI packages

$ dpkg -l | grep -e "libva" -e "va-driver" -e "vaapi"
ii  i965-va-driver:amd64                       2.4.1+dfsg1-1                           amd64        VAAPI driver for Intel G45 & HD Graphics family
ii  intel-media-va-driver:amd64                22.3.1+dfsg1-1ubuntu1                   amd64        VAAPI driver for the Intel GEN8+ Graphics family
ii  libva-drm2:amd64                           2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- DRM runtime
ii  libva-wayland2:amd64                       2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- Wayland runtime
ii  libva-x11-2:amd64                          2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- X11 runtime
ii  libva2:amd64                               2.14.0-1                                amd64        Video Acceleration (VA) API for Linux -- runtime
ii  mesa-va-drivers:amd64                      22.0.5-0ubuntu0.1                       amd64        Mesa VA-API video acceleration drivers
ii  va-driver-all:amd64                        2.14.0-1                                amd64        Video Acceleration (VA) API -- driver metapackage

vainfo output

$ vainfo
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Sandybridge Mobile - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

Firefox settings

Here are screenshots of the relevant about:support sections:

Here’s a screenshot showing the modified media.* settings in about:config (there are no modified gfx.* settings).

TODO list

  • try FF from the PPA

System 2 (T420, Intel only) with PPA

I’ve uninstalled the snap package and replaced with the mozillateam PPA.

Again, about:support shows that hardware video decoding remains blocklisted by gfxInfo:

… and running with intel_gpu_top shows clearly that video playback is not using hardware acceleration. So it looks like the PPA-installed FF is still failing to make the VAAPI connection.

I’ve tried running it with LIBVA_DRIVER_NAME=i965 firefox just to make sure it’s not a driver-selection issue, but it seems not to be. I don’t see any glxtest error messages on the console, but perhaps I need to set a custom MOZ_LOG level for that?

Anyway, I guess that leaves us with the possibility that there is something wrong in the custom FF settings, or perhaps something wrong in how VAAPI support is installed on the host system – or perhaps that the hardware on my T420 is too old to support video decoding?

(As an aside, it’s mildly annoying that I can’t trivially switch between snap vs ppa while keeping the same firefox profile. Is there a trick here I’m missing?)

I’m not sure how to further proceed from here (I will keep digging a bit to see if any settings need further tweaks), so any thoughts/advice would be welcome.

EDIT: I’ve tried setting the media.hardware-video-decoding.force-enabled setting to true, it makes no difference.

W.r.t. system 1 (p14s with hybrid graphics), I’m starting to suspect that the problem here is driver-related:

  • the stuttery/laggy video gets much worse if anything other than the 510 NVIDIA driver is installed
  • the problem also seems to vanish if the laptop is used on its own and disconnected from the external monitors (usually I have it plugged in via USB-C to a pair of monitors chained with displayport)

That doesn’t explain the inability to get VAAPI working, but may explain the change in video playback performance between 20.04 and 22.04.

Wow, thank you for your detailed tests!

There’s a lot going on here (and it’s hard for me to be particularly useful since I don’t have Linux systems with Intel graphics - my Nvidia graphics are just plain “lol nah” for Firefox right now…)

The Firefox profiles thing: snap keeps the app configuration isolated inside of your ~/snap directory. So the PPA is using a profile from ~/.mozilla/firefox, while the snap instance is using a profile from ~/snap/firefox/common/mozilla/firefox. The isolation snap does would break things if you tried to symlink it so the snap uses ~/.mozilla/firefox, but you could symlink ~/.mozilla/firefox to the snap config directory as long as the PPA and the snap are running the same version of firefox. (If they’re not, version changes could mess up your profile, so please bear that in mind…)

This actually applies in general. I’ve got a few apps where I’ve either symlinked configuration or copied config directories around to compare snap vs. non-snap packages. Mostly that comes down to “hmm is this a snap issue? checks non-snap version nope, not a snap issue,” but it’s always good to check during the conversion to a tech that fundamentally changes the system so much.

Machine 1 (hybrid graphics)

I’ll bet that laptop has the DisplayPort/HDMI ports directly attached to the NVIDIA graphics card. So if you want to use external monitors at all, it’s going to use that card regardless. (I had a work laptop like this - internal would use the Intel graphics + PRIME, external would always use NVIDIA graphics, except for whatever reason the VGA port…)

I wasn’t actually aware of the Nvidia CUDA repository (I see it now though), as I tend to use the graphics drivers PPA instead. (Although looking at my machine right now I don’t seem to have that enabled either - I’ve just got the 525 driver directly from the Jammy repos.)

Is there a way to disable the Nvidia graphics in the firmware and try the newer laptop in a configuration where the OS only detects the Intel GPU? (This should also mean the external displays don’t work, if your laptop has the same config as my old work laptop.) I have an hypothesis that Firefox’s gfxinfo is detecting the nvidia graphics and bailing out. If Firefox successfully connects to VAAPI at that point I think that’s likely the answer. As to what we can do about it (if anything) I don’t know, but I’m guessing a bug report to Mozilla would be warranted at that point. Semi-related, in reading this bug I found out that they have a latest/candidate/core22 channel, which uses the 22.04 snap core. It’s possible that the newer vaapi could allow the snap to work where it otherwise wouldn’t, but if the PPA-installed copy isn’t working I think it’s unlikely that that’s the issue.

Machine 2 (Intel-only)

There’s a currently-unconfirmed bug on the mozilla side about not using hardware acceleration on Wayland (though this adds the further complexity of the reporter using Flatpak). Maybe compare Wayland and X and see if you get different results? (A matrix of X/Wayland and PPA/snap would be useful to compare)

EDIT: Since different wayland compositors are different, which desktop environment are you using?

EDIT 2: I just noticed that you pointed out that Firefox on machine 2 is using XWayland, so make that a matrix of ppa/snap and X/Xwayland/Wayland. You should be able to force Firefox to use Wayland by setting the environment variable MOZ_ENABLE_WAYLAND=1

Thanks for the detailed thoughts and feedback! I’ll report back when I have updates on some of your ideas, but for now a few quick responses.

No, the 2 monitors are linked via displayport and then the central one connects to my laptop’s USB-C port (so the monitors wind up supplying the laptop’s power too). I managed to get this setup to work even when using prime-select intel, but IIRC it was more sluggish than usual. So I think when other prime-select settings are chosen, something is probably happening via the NVIDIA card, even if it’s just passing on renderings already generated via the intel card.

Using prime-select intel makes no difference to whether VAAPI works with FF, BTW :slightly_frowning_face: But there definitely is an issue related to the multi-monitor setup – the video playback desync pretty much vanishes when the laptop is used on its own, disconnected from the monitors.

That wasn’t an issue when I had 20.04 installed, so in between kernel update, NVIDIA and intel driver changes, and all the other potential points of difference, something is not working as efficiently as it used to.

Yeah, I made a decision since writing my last posts to drop the CUDA repo and reinstall everything just from the Jammy repos, just in case there was anything problematic there. There is a difference: the jammy repos have driver 525.60.11, the NVIDIA CUDA repo has 525.60.13. The former seems to play nice with my system, the latter (last time I tried it) seemed to significantly worsen the video playback issues.

(Did those 525 drivers land recently in jammy repos, BTW? I don’t remember seeing them available when I first upgraded to 22.04.)

Interesting thought. I’ll try and get machine 2 working first (just to have a working example with an Intel card), if that works then I may try to temporarily disable the NVIDIA card. Disabling the NVIDIA card via prime-select intel doesn’t make any difference to whether hardware acceleration is usable, but I don’t know if that is sufficient to avoid the hypothesized gfxinfo bailout.

The default Ubuntu Gnome 3 in both cases.

Ah, good point; I hadn’t realized that FF might be running via XWayland. I’ll give that a try too.

Thanks again for all these useful suggestions – I’ll report back when I have any new insights.

A few results from trying out different options here on System 2 (T420, intel-only graphics).

X11, snap firefox

Running from the command line, it looks like some progress with libva:

libva info: VA-API version 1.7.0
libva info: Trying to open /snap/firefox/2211/gnome-platform/usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva error: /snap/firefox/2211/gnome-platform/usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
libva info: Trying to open /snap/firefox/2211/gnome-platform/usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0

However, HARDWARE_VIDEO_DECODING still remains blocklisted by gfxInfo, and it’s clear from intel_gpu_top that the GPU is not being used for video decoding.

X11, PPA firefox

The same results, except now for a difference in VA-API version:

libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0

Note that to get this to work I had to install libavcodec-extra, otherwise I got errors like this:

WARNING: Decoder=7f04464a1100 Decode error: NS_ERROR_DOM_MEDIA_FATAL_ERR (0x806e0005) - Error no decoder found for audio/mp4a-latm: file /build/firefox-5bxMr3/firefox-108.0.1+build1/dom/media/MediaDecoderStateMachineBase.cpp:151

For some reason that didn’t happen with the snap package.

In both cases I was running with MOZ_X11_EGL=1.

Wayland (snap and PPA)

Running on Wayland WITH MOZ_ENABLE_WAYLAND=1 produces exactly the same results as described for X11.