Firefox 81 on Fedora with VA-API, WebRTC and X11

Mozilla Firefox continues to implement more and more HW acceleration features on Linux and Fedora comes with extra integration patches to enable it.

Firefox 78 introduced VA-API video decoding on Wayland. Firefox 81 (a latest stable release) comes with VA-API for WebRTC streams decoding and enables VA-API on X11 for supported platforms.

Let’s start with X11. Firefox implements VA-API on top of DMABuf where particular video frames are exported by vaExportSurfaceHandle from libva and imported by EGL_EXT_image_dma_buf_import extension to OpenGL/EGL. That’s the default OpenGL sequence on Wayland where the VA-API was implemented first.

There are two options how to bring VA-API on X11 – vaPutSurface/GLX or vaExportSurfaceHandle/EGL. GLX is the default Firefox OpenGL backend on X11, it’s well supported on all devices including NVIDIA proprietary drivers and it’s generally well tested. On the contrary Firefox does not implement native X11 pixmap textures in any HW accelerated backend, shm based textures are used everywhere. There was an attempt to implement VA-API/vaPutSurface with Basic compositor but it was rejected.

VaExportSurfaceHandle/EGL is the second option for X11. EGL is well supported on Intel/AMD drivers but almost completely missing on NVIDIA, both proprietary and free ones (a partial solution may be GLX/EGL wrapper by Adam Jackson). But with EGL we can recycle most of the work done for Wayland and use the same code path which led to final EGL/X11 implementation by Robert Mader.

The EGL backend is not used by default yet, we’re working to enable it for Mesa drivers. Until that happens you need to run Firefox with set MOZ_X11_EGL env variable to switch from GLX to EGL, so run Firefox as:

MOZ_X11_EGL=1 firefox

As a consequence the dmabuf/vaapi preferences has been changed. Enable VA-API decoding by media.ffmpeg.vaapi.enabled set to true at about:config. That’s a single option for both Wayland and X11 backends as well as for WebRTC decoding (see bellow). Also make sure WebRender (Firefox HW accelerated backend) is enabled.

Users of Mozilla stock builds or other distros than Fedora need also set media.ffvpx.enabled to false until VA-API decoding is implemented in in-tree ffvpx library.

And now the WebRTC VA-API decoding. I tested the implementation on BlueJeans video conferencing system as it’s used by Red Hat internally. BlueJeans uses VP8 video streams and Intel HW decoder produces YV12 video frames which have to be handled by DMABuf surfaces. And we also want to route WebRTC video through external decoder by default [1][2].

If you use Fedora Firefox builds you are settled here, the patches [1][2] are included in the builds.

Users of other distros or Mozilla Firefox stock builds must set media.ffmpeg.low-latency.enabled and media.navigator.mediadatadecoder_vpx_enabled to true at about:config.

12 thoughts on “Firefox 81 on Fedora with VA-API, WebRTC and X11

  1. Werbender was not mentioned in the post, is it still a prerequisite for vaapi? I thought webrender still needed work before it was enabled by default on Linux.

    Like

    1. Please open about:config, set gfx.webrender.all to true and restart Firefox to force-enable WebRender. (Internally it means layers.acceleration.force-enabled + gfx.webrender.enabled.) Your graphics card must support OpenGL 3.1, most ones do. Open about:support, “Compositing” should be “WebRender”.

      Like

  2. Hi Martin,

    I wanted to ask, is there a way for fedora to have ffmpeg/libva/vaapi enabled by default in the future? Currently one needs to find the correct packages from rpmfusion for this vaapi development in firefox, or any application, to be useful. Is there a way that fedora could ship with free codecs for vp8, vp9 and av1 and leave h264/avc on rpmfusion for users that need it?

    Even if this can’t be done, this firefox work is amazing for linux! It’s been a huge person gripe of mine for a while when installing distros on friend’s low-powered laptops. Thank you and everyone who helped firefox vaapi get this far!

    Like

      1. There are two variants of the Intel VAAPI driver. Only the one who includes support for oldest Intel devices is non-free. Couldn’t Fedora ship the free one like Ubuntu and Debian?

        https://github.com/intel/media-driver
        * Full Feature Build is default driver build, which supports all feature by hardware accelerator and close source shaders(media kernel binaries). Ubuntu [intel-media-va-driver-non-free package is generated from this build type.
        = https://packages.debian.org/testing/intel-media-va-driver-non-free

        * Free Kernel Build, enables fully open source shaders(media kernels) and hardware features but the features would be limited. Ubuntu intel-media-va-driver package is generated from this build type.
        = https://packages.debian.org/testing/intel-media-va-driver

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create your website at WordPress.com
Get started
%d bloggers like this: