Page MenuHomeSolus

Firefox VA-API support
Closed, ResolvedPublic

Description

Hi! This is somewhere between a question and a request.

Since FF 81 it should support VA-API hardware video acceleration on both Wayland and X11:
https://bugzilla.mozilla.org/show_bug.cgi?id=1610199
https://bugzilla.mozilla.org/show_bug.cgi?id=1619523

However, i could not get it to work on Solus with all the required settings:

packages:
libva
libva-intel-driver

about:config:
media.ffmpeg.vaapi.enabled=true
media.ffvpx.enabled=false
gfx.webrender.all=true

env:
MOZ_X11_EGL=1

Apparently it only works (even on X11) if firefox has been compiled with a wayland-capable GTK+3 (+mesa). I don't know whether that is currently the case in Solus.

Thanks for any ideas or pointers :)

Event Timeline

Jacek added a subscriber: Jacek.Mar 2 2021, 2:11 AM

I don't think it has anything to do with compiling against Wayland, also you shouldn't need that env variable.
Also are you sure you are already running webrenderer and you don't also need gfx.webrender.enabled=true?

Well according to the second thread I linked the env variable and some wayland ifdefs are required. Also yes, I was on webrender according to about:support.

Btw I used intel_gpu_top from intel-gpu-tools (in addition to looking at the general CPU load) to see whether the gpu acceleration was in use.

GladOSkar updated the task description. (Show Details)Mar 2 2021, 7:27 AM

@GladOSkar Can you start Firefox from the terminal with MOZ_LOG="PlatformDecoderModule:5" firefox and see if D/PlatformDecoderModule VA-API FFmpeg is disabled by platform is in the output (which is the case on my system)?

Also, please run the following and respond back with the output:

sudo eopkg it libva-utils vdpauinfo
vainfo
vdpauinfo
sudo journalctl -b | grep -iE 'vdpau | dri driver'

@ReillyBrogan Sure:

> MOZ_LOG="PlatformDecoderModule:5" firefox | grep VA-API
[Child 41452: Main Thread]: D/PlatformDecoderModule VA-API FFmpeg is disabled by platform
[Child 41452: Main Thread]: D/PlatformDecoderModule VA-API FFmpeg is disabled by platform
[Child 41458: Main Thread]: D/PlatformDecoderModule VA-API FFmpeg is disabled by platform
[Child 41458: Main Thread]: D/PlatformDecoderModule VA-API FFmpeg is disabled by platform
> vainfo
libva info: VA-API version 1.10.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell 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
      VAProfileH264MultiviewHigh      :	VAEntrypointVLD
      VAProfileH264MultiviewHigh      :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileH264StereoHigh         :	VAEntrypointEncSlice
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileJPEGBaseline           :	VAEntrypointVLD
> vdpauinfo
display: :0   screen: 0
libva info: VA-API version 1.10.0
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0
API version: 1
Information string: OpenGL/VAAPI backend for VDPAU

Video surface:

name   width height types
-------------------------------------------
420     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
422     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
444     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
420_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
422_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
444_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 

Decoder capabilities:

name                        level macbs width height
----------------------------------------------------
MPEG1                          --- not supported ---
MPEG2_SIMPLE                   --- not supported ---
MPEG2_MAIN                     --- not supported ---
H264_BASELINE                  51 16384  2048  2048
H264_MAIN                      51 16384  2048  2048
H264_HIGH                      51 16384  2048  2048
VC1_SIMPLE                     --- not supported ---
VC1_MAIN                       --- not supported ---
VC1_ADVANCED                   --- not supported ---
MPEG4_PART2_SP                 --- not supported ---
MPEG4_PART2_ASP                --- not supported ---
DIVX4_QMOBILE                  --- not supported ---
DIVX4_MOBILE                   --- not supported ---
DIVX4_HOME_THEATER             --- not supported ---
DIVX4_HD_1080P                 --- not supported ---
DIVX5_QMOBILE                  --- not supported ---
DIVX5_MOBILE                   --- not supported ---
DIVX5_HOME_THEATER             --- not supported ---
DIVX5_HD_1080P                 --- not supported ---
H264_CONSTRAINED_BASELINE      51 16384  2048  2048
H264_EXTENDED                  --- not supported ---
H264_PROGRESSIVE_HIGH          --- not supported ---
H264_CONSTRAINED_HIGH          --- not supported ---
H264_HIGH_444_PREDICTIVE       --- not supported ---
VP9_PROFILE_0                  --- not supported ---
VP9_PROFILE_1                  --- not supported ---
VP9_PROFILE_2                  --- not supported ---
VP9_PROFILE_3                  --- not supported ---
HEVC_MAIN                      --- not supported ---
HEVC_MAIN_10                   --- not supported ---
HEVC_MAIN_STILL                --- not supported ---
HEVC_MAIN_12                   --- not supported ---
HEVC_MAIN_444                  --- not supported ---
HEVC_MAIN_444_10               --- not supported ---
HEVC_MAIN_444_12               --- not supported ---

Output surface:

name              width height nat types
----------------------------------------------------
B8G8R8A8         16384 16384    y  
R8G8B8A8         16384 16384    y  
R10G10B10A2      16384 16384    y  
B10G10R10A2      16384 16384    y  
A8               16384 16384    y  

Bitmap surface:

name              width height
------------------------------
B8G8R8A8         16384 16384
R8G8B8A8         16384 16384
R10G10B10A2      16384 16384
B10G10R10A2      16384 16384
A8               16384 16384

Video mixer:

feature name                    sup
------------------------------------
DEINTERLACE_TEMPORAL             -
DEINTERLACE_TEMPORAL_SPATIAL     -
INVERSE_TELECINE                 -
NOISE_REDUCTION                  -
SHARPNESS                        -
LUMA_KEY                         -
HIGH QUALITY SCALING - L1        -
HIGH QUALITY SCALING - L2        -
HIGH QUALITY SCALING - L3        -
HIGH QUALITY SCALING - L4        -
HIGH QUALITY SCALING - L5        -
HIGH QUALITY SCALING - L6        -
HIGH QUALITY SCALING - L7        -
HIGH QUALITY SCALING - L8        -
HIGH QUALITY SCALING - L9        -

parameter name                  sup      min      max
-----------------------------------------------------
VIDEO_SURFACE_WIDTH              -  
VIDEO_SURFACE_HEIGHT             -  
CHROMA_TYPE                      -  
LAYERS                           -  

attribute name                  sup      min      max
-----------------------------------------------------
BACKGROUND_COLOR                 -  
CSC_MATRIX                       -  
NOISE_REDUCTION_LEVEL            -  
SHARPNESS_LEVEL                  -  
LUMA_KEY_MIN_LUMA                -  
LUMA_KEY_MAX_LUMA                -  


corrupted size vs. prev_size in fastbins
fish: Job 1, 'vdpauinfo' terminated by signal SIGABRT (Abort)
> sudo journalctl -b | grep -iE 'vdpau | dri driver'

(nothing)

So I got this working locally with the following:

media.ffmpeg.vaapi.enabled true
media.ffvpx.enabled false
gfx.webrender.all=true
media.hardware-video-decoding.force-enabled true

I also had to change the following as it is sometime required due to a sandboxing bug with certain hardware:

media.rdd-vpx.enabled false

When all this was done running Firefox with MOZ_LOG="PlatformDecoderModule:5" MOZ_X11_EGL=1 firefox 2>&1 | grep 'VA-API' showed that VA-API was correctly hardware decoding a youtube video (you'll get a very verbose log as it creates multiple log entries for every single frame decoded by VA-API).

One thing I additionally note about your setup is that your hardware does not support VP9 hardware decoding. You will need to use a Firefox extension to try to force the H264 codec for all videos that support it or force it by disabling VP9 altogether with media.webm.enabled false (warning, this will break all video sources that are VP8/VP9 only.

Interesting. I had all those settings except the rdd-vpx one. I do still get VA-API FFmpeg is disabled by platform, but it also shows VA-API FFmpeg init successful and intel_gpu_top shows some GPU usage while running H.264 Video.

I'll test around with this a bit. Thanks so far!

@GladOSkar One thing I noticed after I got it working was that I still got the VA-API FFmpeg is disabled by platform error message upon startup however I did later see output that it was being processed by VA-API. When it was not working I never saw that output.

Yes, same for me. Plus i can clearly see the video decode usage in intel_gpu_top (and lower general cpu usage). I'll consider this fixed, unless the package maintainer for firefox wishes to make this the default configuration :)

GladOSkar closed this task as Resolved.Apr 8 2021, 4:41 PM
GladOSkar claimed this task.
GladOSkar removed GladOSkar as the assignee of this task.

@GladOSkar I think this can be kept open at least for some further discussion. I think this would be a nice thing to generally support for more users.

I think the following might be useful:

  • Adding that MOZ_X11_EGL environmental variable to the Firefox .desktop file
  • Adding a section to the help center with about:config flags that have helped people get this working

I would assume that at some point all of this will become the default upstream Firefox configuration without any additional steps needed, but I'm not seeing anything in cursory searches as to the plans for that.

GladOSkar reopened this task as Open.EditedApr 8 2021, 7:03 PM

That would be great, but before EGL is activated for everyone there should probably be pretty widespread testing. Especially because i've heard it's a bit less efficient for some people, although i haven't noticed a difference.

DataDrake triaged this task as Needs More Info priority.Thu, Apr 22, 10:39 PM
DataDrake added a subscriber: DataDrake.

I'm more than a bit skeptical that EGL would be required for this.

Well i can't tell you anything else except that a) that's what the threads linked above say and b) it only works with EGL for me ¯\_(ツ)_/¯

Jacek added a comment.Fri, Apr 23, 1:19 PM

I'm more than a bit skeptical that EGL would be required for this.

Same for me, it only started working after I added env MOZ_X11_EGL=1

I get that. What I'm saying is that just because we observe the relationship "Enabling A allows B", it doesn't mean that the real reason it works isn't that "Enabling A, enables C, which allows B" where "C" is some feature that can be enabled elsewhere, without "A".

Ah i get what you're saying. That said, i found no such thing C in any of the threads i read researching this.

I did some research on this and came across the following article from someone who sounds like they are likely involved in the development effort (I glanced through the code as well and it lined up with what they said):

https://mastransky.wordpress.com/2020/09/29/firefox-81-on-fedora-with-va-api-webrtc-and-x11/

And so there the penny drops. Firefox currently requires EGL for VA-API acceleration because no one has managed to get built in for the non EGL code-path. EGL works fine for Intel and AMD where you would be using VA-API, but not on Nvidia where EGL is a broken mess and you would want VDPAU anyways. Firefox wants to enable EGL by default for Mesa drivers (e.g. AMD, Intel), but would still use the non-EGL codepath for Nvidia. This change is currently considered WIP while the EGL backend is underdevelopment.

This goes back to my original point, where EGL isn't required for VA-API because VA-API requires EGL, but because the non-EGL backend doesn't support VA-API. "Enabling A, allows B because the default C cannot allow B". But adds the complication that forcing EGL will break Nvidia.

TL;DR We can't enable EGL by default because it would break Nvidia, but AMD/Intel users can try using the new EGL backend to enable VA-API via the MOZ_X11_EGL environment variable. Firefox will make EGL default for mesalib drivers when they deem it ready.

DataDrake raised the priority of this task from Needs More Info to Normal.Fri, Apr 23, 10:17 PM
DataDrake edited projects, added Upstream Issue; removed Lacks Project.

OK, I think we can close this then. My only question was "Is there something we can do to improve the Firefox hardware acceleration story for Solus users" and the answer is "No because video hardware acceleration is a non-standardized/buggy mess".

We'll just have to wait for Firefox to try to improve this upstream.

GladOSkar closed this task as Resolved.Sat, Apr 24, 8:56 PM
GladOSkar awarded a token.