
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.
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.
LikeLike
Yes, WebRender needs to be enabled.
LikeLike
I’ll update the post, Thanks for the feedback!
LikeLike
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”.
LikeLiked by 1 person
Getting closer and closer to enabling everything by default and out of the box – awesome!
LikeLike
Any plan to add it as a Nightly Experiments in the future?
LikeLike
I didn’t know about it, sounds good!
LikeLike
It’s pretty new but really useful since the user doesn’t have to activate each pref separately. I think you can open a bug in Product: Firefox / Component: Preferences with a patch similar to https://bugzilla.mozilla.org/show_bug.cgi?id=1652134
LikeLike
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!
LikeLike
Yes, VA-API patches are going to be added to Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=1660336) so VP8/9 and eventually AV1 will work out of the box for radeon free drivers for instance. I’m afraid Intel drivers are non-free and they won’t be installed by default.
LikeLike
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
LikeLiked by 1 person
That’s a good idea. It will make sense when https://bugzilla.mozilla.org/show_bug.cgi?id=1660336 lands so Fedora my not need any extra packages and the va-api decode path for vp8/9 can be installed by default.
LikeLiked by 1 person
Hello,
When running Firefox on my Manjaro Xfce with ‘MOZ_X11_EGL=1 firefox’ I have all those errors:
”
MOZ_X11_EGL=1 firefox at 02:29:26
Can’t find symbol ‘eglGetNativeClientBufferANDROID’.
Can’t find symbol ‘eglQuerySurfacePointerANGLE’.
Can’t find symbol ‘eglCreateStreamKHR’.
Can’t find symbol ‘eglDestroyStreamKHR’.
Can’t find symbol ‘eglQueryStreamKHR’.
Can’t find symbol ‘eglStreamConsumerGLTextureExternalKHR’.
Can’t find symbol ‘eglStreamConsumerAcquireKHR’.
Can’t find symbol ‘eglStreamConsumerReleaseKHR’.
Can’t find symbol ‘eglStreamConsumerGLTextureExternalAttribsNV’.
Can’t find symbol ‘eglCreateStreamProducerD3DTextureANGLE’.
Can’t find symbol ‘eglStreamPostD3DTextureANGLE’.
Can’t find symbol ‘eglGetNativeClientBufferANDROID’.
Can’t find symbol ‘eglQuerySurfacePointerANGLE’.
Can’t find symbol ‘eglCreateStreamKHR’.
Can’t find symbol ‘eglDestroyStreamKHR’.
Can’t find symbol ‘eglQueryStreamKHR’.
Can’t find symbol ‘eglStreamConsumerGLTextureExternalKHR’.
Can’t find symbol ‘eglStreamConsumerAcquireKHR’.
Can’t find symbol ‘eglStreamConsumerReleaseKHR’.
Can’t find symbol ‘eglStreamConsumerGLTextureExternalAttribsNV’.
Can’t find symbol ‘eglCreateStreamProducerD3DTextureANGLE’.
Can’t find symbol ‘eglStreamPostD3DTextureANGLE’.
”
Should I care about them?
LikeLiked by 1 person
It should not affect you.
LikeLiked by 1 person
I believe webrtc vaapi decoding was meant to be working by default (when vaapi in firefox was otherwise working):
One needed config option was set to true as shown here: https://bugzilla.mozilla.org/show_bug.cgi?id=1665329
However this above change was later reverted thereby disabling webrtc vaapi decoding by default.
https://bugzilla.mozilla.org/show_bug.cgi?id=1680313
LikeLike
Can VA-API acceleration for X11 be built without Wayland headers or libs ?
I can see there are a lot of sources which have ifdefs’ for MOZ_WAYLAND_… guarding ffmpeg vaapi code.
LikeLike
Yes, it can be built without Wayland but it will need some work to create a new define (for instance MOZ_DMABUF) and move dmabuf headers there. Why do you need it anyway? Is there any system where Wayland isn’t available but vaapi is supported?
LikeLike