Firefox Nightly 86 and VDPAU / Nvidia

Hello all,

in order to attempt a new start with this topic while also trying to avoid as much confusion as possible:

How will it be possible to get hardware accelerated video playback to work in Firefox in a system with the Nvidia 390 proprietary driver?

To be clear:

  • No Intel/Nvidia hybrid system
  • No Intel onboard solution

Configuration:

  • Graphics card:
Graphics:  Device-1: NVIDIA GF116 [GeForce GTX 550 Ti] vendor: Gigabyte driver: nvidia v: 390.141 
           alternate: nouveau,nvidia_drm bus ID: 01:00.0 chip ID: 10de:1244 
           Display: x11 server: X.Org 1.20.10 compositor: picom v: git-dac85 driver: nvidia display ID: :0.0 screens: 1 
           Screen-1: 0 s-res: 3600x1080 s-dpi: 96 s-size: 953x286mm (37.5x11.3") s-diag: 995mm (39.2") 
           Monitor-1: DVI-I-2 res: 1920x1080 hz: 60 dpi: 82 size: 598x336mm (23.5x13.2") diag: 686mm (27") 
           Monitor-2: DVI-I-3 res: 1680x1050 hz: 60 dpi: 90 size: 474x296mm (18.7x11.7") diag: 559mm (22") 
           OpenGL: renderer: GeForce GTX 550 Ti/PCIe/SSE2 v: 4.6.0 NVIDIA 390.141 direct render: Yes 
LIBVA_DRIVER_NAME=vdpau
VDPAU_DRIVER=nvidia
  • Mozilla environment:
MOZ_X11_EGL=1
MOZ_ACCELERATED=1
MOZ_WEBRENDER=1
  • Firefox installed package:
local/firefox-nightly-de 86.0a1.20201223-1
    Standalone Web Browser from Mozilla — Nightly build (de-DE)
  • Firefox about:config options:
gfx.canvas.azure.accelerated    true
gfx.canvas.azure.backends   skia
gfx.content.azure.backends  skia
gfx.webrender.all   true
gfx.webrender.enabled   true
gfx.webrender.layers-free   true
gfx.webrendest.enabled  true
gfx.webrender.blob-images true
gfx.xrender.enabled true

layers.async-pan-zoom.enabled false
layers.accelerate-all   true
layers.acceleration.force-enabled   true
layers.force-active true

webgl.force-enabled true
webgl.msaa-force    true
layers.acceleration.force-enabled true
layers.gpu-process.enabled true
layers.gpu-process.force-enabled false

media.ffmpeg.vaapi.enabled true
media.ffmpeg.dmabuf-textures.enabled true
media.ffvpx.enabled false  

If I start firefox-nightly with MOZ_LOG=PlatformDecoderModule:5, I get the following log while trying to play a video from HTML5 Video Test Page | Tek Eye :

[Child 17734: Main Thread]: D/PlatformDecoderModule Agnostic decoder rejects requested type
[Child 17734: Main Thread]: D/PlatformDecoderModule Sandbox RDD decoder rejects requested type
[Child 17734: MediaSupervisor #2]: D/PlatformDecoderModule Sandbox GPU decoder rejects requested type
[Child 17734: MediaSupervisor #2]: D/PlatformDecoderModule Agnostic decoder rejects requested type
[Child 17734: MediaSupervisor #2]: D/PlatformDecoderModule Sandbox RDD decoder rejects requested type
[Child 17734: MediaSupervisor #2]: D/PlatformDecoderModule Sandbox GPU decoder rejects requested type
[Child 17734: MediaSupervisor #2]: D/PlatformDecoderModule Agnostic decoder rejects requested type
[Child 17734: MediaSupervisor #2]: D/PlatformDecoderModule Sandbox RDD decoder rejects requested type
[Child 17734: MediaSupervisor #1]: D/PlatformDecoderModule Sandbox GPU decoder rejects requested type
[Child 17734: MediaSupervisor #1]: D/PlatformDecoderModule Agnostic decoder rejects requested type
[Child 17734: MediaSupervisor #1]: D/PlatformDecoderModule Sandbox RDD decoder rejects requested type
[Child 17734: MediaSupervisor #1]: D/PlatformDecoderModule Sandbox GPU decoder rejects requested type
[Child 17734: MediaPDecoder #1]: D/PlatformDecoderModule Initialising FFmpeg decoder.
[Child 17734: MediaSupervisor #1]: D/PlatformDecoderModule Agnostic decoder rejects requested type
[Child 17734: MediaSupervisor #1]: D/PlatformDecoderModule Sandbox RDD decoder rejects requested type
[Child 17734: MediaPDecoder #2]: D/PlatformDecoderModule Initialising VA-API FFmpeg decoder
[Child 17734: MediaPDecoder #1]: D/PlatformDecoderModule FFmpeg init successful.
[Child 17734: MediaPDecoder #1]: D/PlatformDecoderModule AudioTrimmer[0x7fecec16e420] ::PrepareTrimmers: sample[0,23219] no trimming information
[Child 17734: MediaPDecoder #3]: D/PlatformDecoderModule AudioTrimmer[0x7fecec16e420] ::HandleDecodedResult: sample[0,23219] (decoded[0,23219] no trimming needed

Right after that, the Firefox tab with the video in it crashes, and it asks me to file a crash report.

At a first glance, it looks like Firefox is initializing the FFmpeg VA-API decoder which apparently fails on the VDPAU configuration described above.

Remark: Hardware acceleration in chromium and mpv works without errors.

Does anybody know what is missing in order to get Firefox working?

1 Like

IIRC, NVIDIA proprietary drivers doesn’t support VAAPI

With a translation layer, they do. Just refer to Hardware video acceleration - ArchWiki .

Here’s what vainfo says when the Nvidia driver is installed together with the translation layer:

vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA-API - 0.7.4
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG4Simple            :	VAEntrypointVLD
      VAProfileMPEG4AdvancedSimple    :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD

Looks like only Mozilla does not care, apparently also because some morons spammed the bug: 1210729 - Add VDPAU or NVDEC hardware decoding support on Linux

I have the same issue.
With a Nvidia gtx1070, nvidia 460 proprietary driver, Firefox 85 stable, every time a Youtube video is hardware decoded, the tab crashes. If I disable h264ify, the video works fine, so the problem is h264 which is accelerated.

I also set these environment variables

togheter with this

but not these, since I modified the values on about:config

media.ffmpeg.vaapi.enabled is set to true
media.ffvpx.enabled is set to false

layers.acceleration.force-enabled is set to false and gfx.webrender.all is set to true
But I also tried to set both to true and than both to false…

I tried libva-vdpau-driver from the repository, the special version for chromium and the vp9 version (from AUR)
Unfortunately nothing worked.

Meanwhile, hw decoding work in chromium but only using the special version translation layer (it also works with vp9 version but not with vp9 codec, so that version is unuseful now). MPV decoding don’t work with hwdec and vo set to vaapi, it gives me this error:

    mpv: malloc.c:2394: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
Aborted (core dumped)

but it works with nvdec and vdpau…

So at the end of the day, vaapi should work in theory because it worked on chromium, using the special translation layer, but it doesn’t work in mpv and firefox, i can’t understand why

Update:
It looks like this topic has only low priority in the development at Mozilla (if anybody cares at all).

According to several recommendations from the net, I have installed firefox-nightly which even got an update yesterday.
Unfortunately, hardware accelerated video decoding still does not work in this version of firefox-nightly (87.0a1.20210127-1).
Looks like we will have to keep using chromium instead as long as we cannot afford a Radeon RX 6000 and a suitable computer around it :smile:

I wonder if it does work on Wayland…
I’m using chromium right now, but I want to ditch it in favor of Firefox, since from March they will block sync with google accounts
But the switch to Firefox is all but flawless! I’m having problems even with the font, which is bad rendered :sob:

Had the same experience here. Even after having font rendering at least acceptable on the desktop and in Chromium, fonts looked terrible in Firefox.

There is a lot of information on that topic, covering font rendering in general, but almost nothing about Firefox.

Here is what seems to have helped on my system:

  1. I installed the following font packages:
local/gnu-free-fonts 20120503-8
    A free family of scalable outline fonts
local/noto-fonts 20201226-1
    Google Noto TTF fonts
local/ttf-bitstream-vera 1.10-14
    Bitstream Vera fonts.
local/ttf-caladea 20200113-2
    A serif font family metric-compatible with Cambria font family
local/ttf-carlito 20130920-5
    Google's Carlito font
local/ttf-courier-prime 1.203-5
    Monospace Courier font alternative. It’s Courier, just better
local/ttf-croscore 20201226-1
    Chrome OS core fonts
local/ttf-dejavu 2.37+18+g9b5d1b2f-2
    Font family based on the Bitstream Vera Fonts with a wider range of
    characters
local/ttf-droid 20121017-9
    General-purpose fonts released by Google as part of Android
local/ttf-gelasio-ib 0.2-3
    Gelasio is designed to be metrics compatible with Georgia in its Regular,
    Bold, Italic and Bold Italic weights. Interpolated Medium, medium Italic,
    SemiBold and SemiBold Italic have now been added as well.
local/ttf-heuristica 1.0.2-5
    A serif latin & cyrillic font, derived from the "Adobe Utopia" font by
    Apanov
local/ttf-impallari-cantora 1.001-5 (impallari-fonts)
    Cantora ('Singer' in Spanish) is a friendly semi-formal, semi-condensed,
    semi–sans-serif font, from Pablo Impallari
local/ttf-inconsolata 1:3.000-2
    Monospace font for pretty code listings and for the terminal
local/ttf-liberation 2.1.2-1
    Font family which aims at metric compatibility with Arial, Times New Roman,
    and Courier New
local/ttf-linux-libertine 5.3.0-6
    Serif (Libertine) and Sans Serif (Biolinum) OpenType fonts with large
    Unicode coverage
local/ttf-mac-fonts 20100901.134-1
    Mac fonts including Lucida Grande, Apple Garamond and other fonts from Apple
local/ttf-merriweather 1:2.005-3
    A typeface that is pleasant to read on screens by Sorkin Type Co
local/ttf-merriweather-sans 1.008-3
    A sans-serif typeface that is pleasant to read on screens by Sorkin Type Co
local/ttf-monaco 6.1-6
    The Monaco monospaced sans-serif typeface with special characters added
local/ttf-opensans 1.101-2
    Sans-serif typeface commissioned by Google
local/ttf-oswald 4.101-3
    Sans-serif typeface from Google by Vernon Adams
local/ttf-quintessential 1.001-6
    Calligraphic typeface from Google by Brian J. Bonislawsky
local/ttf-signika 1.002-4
    Sans-serif typeface from Google by Anna Giedryś
local/ttf-symbola 13.00-8
    Font for symbol blocks of the Unicode Standard (TTF)
local/ttf-ubuntu-font-family 0.83-6
    Ubuntu font family
  1. I renamed /etc/fonts/local.conf as I wanted to have control over font configuration on other ways (see below).
  2. For each of the fonts installed, I made sure that there are no substitutions. In particular, I ensured that Arial, Times New Roman and Courier are not substituted by any other font:
fc-match "Arial"
arial.ttf: "Arial" "Standard"

fc-match "Times New Roman"
times.ttf: "Times New Roman" "Standard"

fc-match "Courier New"
cour.ttf: "Courier New" "Standard"

To achieve this, you will have to look at /etc/fonts/conf.d and see what’s there.

  1. My ~/.config/fontconfig/fonts.conf:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="font">
        <edit name="rgba" mode="assign"> <const>rgb</const></edit>
        <edit name="hinting" mode="assign"> <bool>true</bool></edit>
        <edit name="autohint" mode="assign"> <bool>false</bool></edit>
        <edit name="antialias" mode="assign"> <bool>true</bool></edit>
        <edit name="hintstyle" mode="assign"> <const>hintfull</const></edit>
        <edit name="lcdfilter" mode="assign"> <const>lcdlight</const></edit>
        <edit name="embeddedbitmap" mode="assign"><bool>false</bool></edit>
    </match>
    <!-- adjust screen resolution -->
    <match target="pattern">
        <edit name="dpi" mode="assign"><double>96</double></edit>
    </match>
    <!-- enable antialiasing for sans serif fonts -->
    <match target="font">
           <test name="family"><string>sans-serif</string></test>
           <edit mode="assign" name="antialias"><bool>true</bool></edit>
    </match>
        <!-- Web fonts. -->
    <match target="font">
        <test name="family" compare="contains"> <string>@font-face:</string></test>
        <test name="file" qual="all" compare="not_contains"> <string>/</string></test>
        <test name="fontformat" compare="eq"> <string>TrueType</string></test>
        <edit name="autohint" mode="assign"> <bool>true</bool> </edit>
        <edit name="hintstyle" mode="assign"> <const>hintmedium</const> </edit>
    </match>

</fontconfig>

Important: Firefox seems to ignore ~/.config/fontconfig/fonts.conf, according to information I found on the net. Instead, it reads ~/.fonts.conf.

So it might make sense to create a symlink like

ln -sf ~/.config/fontconfig/fonts.conf ~/.fonts.conf
  1. My ~/.Xresources:
Xft.dpi: 96
Xft.antialias: true
Xft.hinting: true
Xft.rgba: none
Xft.autohint: 0
Xft.hintstyle: hintslight
Xft.lcdfilter: lcdlegacy

Finally, I changed user settings in Firefox in Settings, Language and Appearance, Fonts and Colors according to my preferences. In particular, the minimum font size is important.

Settings in about:config:

gfx.font_rendering.cleartype_params.rendering_mode = 5
gfx.font_rendering.fontconfig.max_generic_substitutions = 127
gfx.font_rendering.graphite.enabled = true
layout.css.font-variations.enabled = false

With all these settings, I achieved an acceptable appearance of the fonts in Firefox.

Thank you very much. Based on what you said and manjaro wiki, now the font is much better!

Is there a reason behind for having completely different and confronting parameter values between your user fonts.conf and your .Xresources?

The simple reason is: Because Firefox (as well as all the other programs) work with these settings as they should. Every time I tried to synchronize these settings, I got awful font rendering (see screenshots - note the color fringe in the Firefox text portion):

With my modified settings:


.

Indeed, it looks like fonts.conf prevails over .Xresources so the settings there are apparently taken into account in few places only.
But as I agree that having contradicting settings in these two files does not make sense, I updated .Xresources to match fonts.conf:

Xft.rgba: rgb
Xft.hinting: true
Xft.autohint: false
Xft.antialias: true
Xft.hintstyle: hintfull
Xft.lcdfilter: lcdlight
Xft.embeddedbitmap: false
Xft.dpi: 96

So far, fortunately, no impact. Everything still looks like it should. Of course, I have done xrdb - merge .Xresources and even rebooted in order to make sure the settings are applied.

Update with regards to font configuration:
As we all know, there are a lot of different places where font configuration is done.

  1. The first place will be /etc/fonts with the following places:

/etc/fonts/conf.d, /etc/fonts/conf.avail and /etc/fonts/local.conf.
I have now reinstated my /etc/fonts/local.conf to read like

<?xml version="1.0"?>
  <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
      <match>
          <edit mode="prepend" name="family"><string>Noto Sans</string></edit>
      </match>
      <match target="pattern">
          <test qual="any" name="family"><string>serif</string></test>
          <edit name="family" mode="assign" binding="same"><string>Noto Serif</string></edit>
      </match>
      <match target="pattern">
          <test qual="any" name="family"><string>sans-serif</string></test>
          <edit name="family" mode="assign" binding="same"><string>Noto Sans</string></edit>
      </match>
      <match target="pattern">
          <test qual="any" name="family"><string>monospace</string></test>
          <edit name="family" mode="assign" binding="same"><string>Noto Mono</string></edit>
      </match>

    <!-- Prevent Gnome from using embedded bitmaps in fonts like Calibri -->
      <match target="font">
          <edit name="embeddedbitmap" mode="assign"><bool>false</bool></edit>
      </match>

    <!-- Reject bitmap fonts in favour of Truetype, Postscript, etc. -->
    <selectfont>
        <rejectfont>
             <pattern>
	          <patelt name="scalable"><bool>false</bool></patelt>
             </pattern>
        </rejectfont>
    </selectfont>

    <!-- Substitute truetype fonts for bitmap ones -->
    <match target="font">
        <edit name="prefer_outline"><bool>true</bool></edit>
    </match>

      <match target="font">
          <edit name="rgba" mode="assign">
	        <const>rgb</const>
          </edit>
          <edit name="hinting" mode="assign">
	        <bool>true</bool>
          </edit>
          <edit name="autohint" mode="assign">
    	        <bool>false</bool>
          </edit>
          <edit name="antialias" mode="assign">
	        <bool>true</bool>
          </edit>
          <edit name="hintstyle" mode="assign">
	        <const>hintfull</const>
          </edit>
          <edit name="lcdfilter" mode="assign">
	        <const>lcdlight</const>
          </edit>
          <edit name="embeddedbitmap" mode="assign">
    	        <bool>false</bool>
          </edit>
          <edit name="dpi" mode="assign">
    	        <double>96</double>
          </edit>
      </match>
</fontconfig>

Note the <match target="font"> section. Its contents shall be consistent with all the configuration files discussed later on, and also with the links in /etc/fonts/conf.d. At least the following links have to be set in order to match the /etc/fonts/local.conf above:

lrwxrwxrwx 1 root root  53 26. Apr 17:12 10-hinting-full.conf -> /usr/share/fontconfig/conf.avail/10-hinting-full.conf
lrwxrwxrwx 1 root root  61  1. Apr 17:43 10-scale-bitmap-fonts.conf -> /usr/share/fontconfig/conf.default/10-scale-bitmap-fonts.conf
lrwxrwxrwx 1 root root  35 26. Apr 15:39 10-sub-pixel-rgb.conf -> /usr/share/fontconfig/conf.avail/10-sub-pixel-rgb.conf
lrwxrwxrwx 1 root root  37 26. Apr 15:39 11-lcdfilter-light.conf -> /usr/share/fontconfig/conf.avail/11-lcdfilter-light.conf
lrwxrwxrwx 1 root root  40 25. Mär 2019  70-no-bitmaps.conf -> /etc/fonts/conf.avail/70-no-bitmaps.conf
  1. The next place to look at, is ~/.config/fontconfig/fonts.conf, in my case, it resembles /etc/fonts/local.conf to a large extent - note the different treatment for web fonts:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="font">
        <edit name="rgba" mode="assign"> <const>rgb</const></edit>
        <edit name="hinting" mode="assign"> <bool>true</bool></edit>
        <edit name="autohint" mode="assign"> <bool>false</bool></edit>
        <edit name="antialias" mode="assign"> <bool>true</bool></edit>
        <edit name="hintstyle" mode="assign"> <const>hintfull</const></edit>
        <edit name="lcdfilter" mode="assign"> <const>lcdlight</const></edit>
        <edit name="embeddedbitmap" mode="assign"><bool>false</bool></edit>
    </match>
    <!-- adjust screen resolution -->
    <match target="pattern">
        <edit name="dpi" mode="assign"><double>96</double></edit>
    </match>
    <!-- enable antialiasing for sans serif fonts -->
    <match target="font">
           <test name="family"><string>sans-serif</string></test>
           <edit mode="assign" name="antialias"><bool>true</bool></edit>
    </match>
        <!-- Web fonts. -->
    <match target="font">
        <test name="family" compare="contains"> <string>@font-face:</string></test>
        <test name="file" qual="all" compare="not_contains"> <string>/</string></test>
        <test name="fontformat" compare="eq"> <string>TrueType</string></test>
        <edit name="autohint" mode="assign"> <bool>true</bool> </edit>
        <edit name="hintstyle" mode="assign"> <const>hintmedium</const> </edit>
    </match>
</fontconfig>
  1. Last file to look at, is ~/.Xresources:
Xft.rgba: rgb
Xft.hinting: true
Xft.autohint: false
Xft.antialias: true
Xft.hintstyle: hintfull
Xft.lcdfilter: lcdlight
Xft.embeddedbitmap: false
Xft.dpi: 96

This enables a clear and convenient font rendering here, including otherwise problematic programs such as Firefox (see about:config recommendations earlier on).

The only program with font problems here, is chromium-dev. Starting with version 91, chromium-dev needs to be called with the --no-sandbox -test-type command line options.
Otherwise, it fails to display the font set as default (independent of which font is set) - see screenshot:

Does anybody know what is missing in order to get Firefox working?

Maybe that even with the translation layer Nvidia driver needs to also support DMA-BUF, as per Firefox#Hardware video acceleration on Arch Wiki [1]:

Nvidia’s proprietary driver does not support DMA-BUF which is necessary for this feature [6]. NVIDIA has confirmed DMA-BUF support is being worked on [7].

Also see [2].

So, it looks like your only bet @DAC324 is to use Nouveau driver. @luigir-it, on the other hand, can wait for the 470 driver to come out this summer, which would, hopefully, have DMA-BUF support implemented.

LINKS:
Since I’m considered a filthy spammer who can’t post proper links on this forum yet, you’ll have to copy-paste them manually. These are Arch Wiki paths:
[1]
/title/Firefox#Hardware_video_acceleration
[2]
/title/Talk:Firefox#Hardware_video_acceleration

Indeed, as per 1693073 - Linux, VDPAU: Firefox crashes when trying to open a H.264 video , it looks like DMA_BUF is required for Firefox under all circumstances.
Interesting question for less tech-savvy people: Why does Chromium not need this feature? But anyway, it is a development decision made by the Mozilla people that will not be changed.

The nouveau driver is reported to have other disadvantages, such as Video acceleration not fully working in programs like Chrome / Chromium, and certain media players.

So this approach looks like jumping out of the frying pan into the fire :smiley:

Of course, as soon as the 390 driver will not work anymore (which will certainly be the case with Linux kernels 6.x or 7.x) there will be no alternative to nouveau, anyway.

Finally, here are the links:
[1] Firefox - ArchWiki
[2] Talk:Firefox - ArchWiki
[6] 1669189 - Crash in [@ XDisplayString] when enabling VAAPI on proprietary Nvidia
[7] 428089 – Restarting compositing breaks existing EGLStreams