VAAPI / HW-acceleration not working Snap-packaged Firefox

Bug #1947115 reported by Troels Petersen
44
This bug affects 8 people
Affects Status Importance Assigned to Milestone
firefox (Ubuntu)
Fix Released
High
Olivier Tilloy

Bug Description

I just installed Ubuntu 21.10, which packages Firefox in snap in contrary to the old .deb package way.

Now neither of my laptops (with snap packaged firefox and Ubuntu 21.10) can play videos hardware accelerated using VAAPI anymore. This means my laptops get hotter and use battery faster. It was working perfectly in Ubuntu 21.04.
I can see that the about:config has stayed untouched since the upgrade, so I have my doubts that this is related to an updated about:config.

vainfo shows full support (nothing appears broken) and I am also able to play videos in VLC using hardware acceleration, VAAPI.

The reason why I can see it is not using VAAPI is intel_gpu_top. In previous versions of Ubuntu with Firefox, I could monitor the video decoder when watching videos in Firefox. Before the upgrade it was always utilized. Now it only shows that the GPU is being used, so the video decoder is not in use.

I can't see any switch in the Application/Firefox menu regarding allowing access to video decoding hardware, so I am wondering if it simply cannot access that part of the GPU inside a snap environment?

Tags: snap
Revision history for this message
Sebastien Bacher (seb128) wrote (last edit ):

Thank you for your bug report. Which desktop environment and session do you use? it sounds like it could be the same issue than https://bugzilla.mozilla.org/show_bug.cgi?id=1732580 which has a fix recently landing upstream and should make it to beta next

Changed in firefox (Ubuntu):
importance: Undecided → High
Olivier Tilloy (osomon)
Changed in firefox (Ubuntu):
assignee: nobody → Olivier Tilloy (osomon)
status: New → Confirmed
Revision history for this message
Olivier Tilloy (osomon) wrote :

I can confirm that this doesn't work out of the box.

When running the firefox snap with MOZ_LOG="PlatformDecoderModule:5", I can see that libva tries to load drivers from $SNAP/gnome-platform/usr/lib/x86_64-linux-gnu/dri/, where it can't find any such driver. This is bug #1947180, for which I've proposed a fix in snapcraft.

Once that is fixed, the next step is to ship said VA-API drivers, either in the firefox snap itself, or in the platform snap (gnome-3-38-2004).

Revision history for this message
Olivier Tilloy (osomon) wrote :

https://gitlab.gnome.org/Community/Ubuntu/gnome-sdk/-/merge_requests/31 adds the VA-API drivers to the gnome platform snap (gnome-3-38-2004).

Changed in firefox (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I guess we can soon close bug 1424201?

Revision history for this message
Troels Petersen (thesleort) wrote :

I am using Wayland and the variable MOZ_ENABLE_WAYLAND=1 (I read somewhere recently that this should be default now, but I still have it set.)
I am using the Ubuntu variant of gnome shipped with Ubuntu 21.10. The default one with Ubuntu.

Revision history for this message
Vincent Chernin (vchernin) wrote :

Well I would say https://bugs.launchpad.net/bugs/1424201 isn’t properly solved until VAAPI is on by default for browsers on Ubuntu. Neither Firefox or Chromium do so yet. There’s a few bugs on the browser side that need the be solved, as mentioned in the Arch Wiki. https://wiki.archlinux.org/title/Firefox#Hardware_video_acceleration https://wiki.archlinux.org/title/Chromium#Hardware_video_acceleration.

Revision history for this message
Olivier Tilloy (osomon) wrote :

gnome-3-38-2004 version 0+git.cd626d1 (revision 87 for amd64) is now in the stable channel, so the VA-API drivers are exposed for the firefox snap and other consumer snaps.

Changed in firefox (Ubuntu):
status: In Progress → Fix Released
tags: added: snap
Revision history for this message
Troels Petersen (thesleort) wrote :

Thank you all for working and fixing this issue! It also works here.

Revision history for this message
Troels Petersen (thesleort) wrote :

It does not work again on Ubuntu 22.04 LTS with i965. I am not sure whether i965_drv_video.so is packaged with the snap or not.

If I do:
```
troels@troels-ThinkPad-X230-Tablet:~$ LIBVA_DRIVER_NAME=i965 vainfo
libva info: VA-API version 1.14.0
libva info: User environment variable requested driver 'i965'
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) Ivybridge Mobile - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple : VAEntrypointVLD
      VAProfileMPEG2Simple : VAEntrypointEncSlice
      VAProfileMPEG2Main : VAEntrypointVLD
      VAProfileMPEG2Main : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main : VAEntrypointVLD
      VAProfileH264Main : VAEntrypointEncSlice
      VAProfileH264High : VAEntrypointVLD
      VAProfileH264High : VAEntrypointEncSlice
      VAProfileH264StereoHigh : VAEntrypointVLD
      VAProfileVC1Simple : VAEntrypointVLD
      VAProfileVC1Main : VAEntrypointVLD
      VAProfileVC1Advanced : VAEntrypointVLD
      VAProfileNone : VAEntrypointVideoProc
      VAProfileJPEGBaseline : VAEntrypointVLD
```
However, if it force the iHD driver:

```
troels@troels-ThinkPad-X230-Tablet:~$ LIBVA_DRIVER_NAME=iHD vainfo
libva info: VA-API version 1.14.0
libva info: User environment variable requested driver 'iHD'
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
vaInitialize failed with error code 1 (operation failed),exit
```

So my computer does not work with the iHD driver, that I think the snap comes packaged with. Maybe I by mistake in Ubuntu 21.10 was using the normal packaged version of Firefox, which enabled me to use the i965 VA driver.

Revision history for this message
Olivier Tilloy (osomon) wrote :

The gnome platform snap, which the firefox snap relies on for libva drivers, comes with both drivers (i965 and iHD):

    $ ls -1 /snap/gnome-3-38-2004/current/usr/lib/x86_64-linux-gnu/dri/ | grep _drv_video.so
    i965_drv_video.so
    iHD_drv_video.so
    nouveau_drv_video.so
    r600_drv_video.so
    radeonsi_drv_video.so

Can you share the output of:

    MOZ_LOG="PlatformDecoderModule:5" snap run firefox

Revision history for this message
Troels Petersen (thesleort) wrote :

On my other laptop which uses the iHD driver, it is also not working

troels@spectre:~$ vainfo
libva info: VA-API version 1.14.0
libva info: User environment variable requested driver 'iHD'
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
      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
      VAProfileHEVCMain : VAEntrypointVLD
      VAProfileHEVCMain : VAEntrypointEncSlice
      VAProfileHEVCMain : VAEntrypointFEI

On both computers, intel_gpu_top shows that the "video" engine is not being used at all. In Ubuntu 21.10, they were perfectly capable of using the hardware decoder with firefox.

Revision history for this message
Troels Petersen (thesleort) wrote :

Pardon me, I didn't see your comment.

I attached the output when viewing a video on Youtube

Revision history for this message
Troels Petersen (thesleort) wrote :

Is it because the snap package uses XWayland?

I just checked about:support and it reports the window protocol as XWayland.

Me personally, I have only had success using VAAPI HW-acceleration when using Wayland with export MOZ_ENABLE_WAYLAND=1 and then using Wayland as the windowing system in Ubuntu

Revision history for this message
Olivier Tilloy (osomon) wrote :

No, this is in fact an upstream regression (https://bugzilla.mozilla.org/show_bug.cgi?id=1751363).

Can you try running the firefox snap with MOZ_DISABLE_RDD_SANDBOX=1 and report whether this works around the problem for you?

Revision history for this message
Troels Petersen (thesleort) wrote :

It does not work. I tried
$ MOZ_DISABLE_RDD_SANDBOX=1 firefox

and it still does not work. Then I remembered, that I already added this in my /etc/profile a while ago, when it stopped working on an at that timer new version of firefox.

This is the bottom of my /etc/profile :

export LIBVA_DRIVER_NAME=i965
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
export MOZ_ENABLE_WAYLAND=1
export MOZ_DISABLE_RDD_SANDBOX=1

Revision history for this message
Nikos Epwnymo (iceman358) wrote :

Hey there,
I am facing the same issue.

However, for me if I use MOZ_DISABLE_RDD_SANDBOX=1 firefox, it works as expected.

Is there a way to use it while not disabling the sandbox?

Revision history for this message
Troels Petersen (thesleort) wrote :

Ahh yeah, I just noticed that VAAPI works again now with Firefox 101.0-2 and Firefox 102.0b2-1

Revision history for this message
I.Scott (tractor556) wrote :

I have ubuntu 22.10 beta installed, Firefox Snap 105.0.3, intel GPU with iHD driver. Hardware decoding via VAAPI only works if I use "MOZ_DISABLE_RDD_SANDBOX=1 firefox"

Revision history for this message
I.Scott (tractor556) wrote :

Hardware Acceleration now seems to be working following the latest update to Firefox Snap v106.0.1 on Ubuntu 22.10 without the need to disable the sandbox

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.