firefox enable proper video hardware acceleration

Symptoms:

Video playback via browser like firefox is laggy/choppy with cpu spiking. Especially when playing HD video’s.

My hardware has no issues playing the same HD video’s using smplayer when opening the url, so it is really a browser issue (which seems to play video’s using CPU instead of GPU).

This is not a new issue, I had this for several opensuse/firefox versions so I’m really hoping someone can help me out to fix it.

I already set these settings in about:config:


layers.acceleration.force-enabled true
media.hardware-video-decoding.force-enabled true

and below is some info about my gpu


inxi -SGxxz
System:    Kernel: 5.3.18-lp152.33-default x86_64 bits: 64 compiler: gcc v: 7.5.0 Desktop: KDE Plasma 5.18.5 tk: Qt 5.12.7 
           wm: kwin_x11 dm: SDDM Distro: openSUSE Leap 15.2 
Graphics:  Device-1: NVIDIA GK107 [GeForce GT 640] vendor: Micro-Star MSI driver: nvidia v: 450.57 bus ID: 01:00.0 
           chip ID: 10de:0fc1 
           Display: x11 server: X.Org 1.20.3 compositor: kwin_x11 driver: nvidia resolution: 1680x1050~60Hz s-dpi: 75 
           OpenGL: renderer: GeForce GT 640/PCIe/SSE2 v: 4.6.0 NVIDIA 450.57 direct render: Yes 

You’re right, it’s a browser issue. No one running Linux on Xorg has hardware video acceleration. Yet.

Read this: https://www.phoronix.com/scan.php?page=news_item&px=Firefox-80-VA-API-X11

Yes, but, you haven’t enabled “gfx.webrender.all” …

Aha so there is hope :slightly_smiling_face:

Or not:

“With the Firefox 80 release, everything should be set assuming you have a hardware + driver setup for the Video Acceleration API.”

Is there a way to find out if hardware and driver will support this?

Support: Platform/GFX/WebRender Where - MozillaWiki

Must add that even if we get hw video decoding on X11, having it support NVIDIA is yet another thing.
If decoding on CPU is a problem, an alternative is downloading the video and playing on VLC. Of course that wouldn’t work for video chats.

Aha so there is hope

Or not:

“With the Firefox 80 release, everything should be set assuming you have a hardware + driver setup for the Video Acceleration API.”

Is there a way to find out if hardware and driver will support this?

Not sure. The linked work item from the article mentions a few implementation alternatives, but I’m really lost about which path they’re taking. NVIDIA doesn’t support VAAPI, but VDPAU instead, for instance. People complain about NVIDIA being closed-source. IMO the real issue is implementation

Check out the Graphics section on about:support (firefox)

I’m using FF Webrender from ~ April 2019.
Check another stuff: omt, offmainthread, tiling, skia, GPU_PROCESS, …

With NVIDIA GK107 chip you have h.264 acceleration, but not h.265 or VP9.
But you may get some help from CUDA…

Supported hardware and drivers


Nvidia proprietary driver for Nvidia graphics cards on Linux
libva-vdpau-driver for cards supported by VDPAU

WebRender is about offloading painting and compositing to the GPU. This may relieve some burden off the CPU, but its the decoding that would be more expensive and browsers still don’t have that on Linux. Well, there are unofficial patches for chromium in the AUR, someone could port them to openSUSE, it doesn’t seem a lot of work.

It’s possible, but it looks like the translation layer is unmaintained.

You’re right, it’s a browser issue. No one running Linux on Xorg has hardware video acceleration. Yet.

What I still do not understand:

  1. How is it possible that applications like smplayer seem to resolve this issue, being able to use hardware acceleration just fine. But browsers aren’t (not just firefox, but also chromium and chrome). Can’t they implement video playback the same way smplayer does it? If smplayer can access the graphics card, why would firefox not be able to?
  2. I have a feeling that this issue was very low prio in linux world, since it has been around for more then 5 years now (at least) and it is still not resolved. Yet isn’t video playback through browser a major feature nowadays on a desktop (netflix, youtube, etc)? Shouldn’t this be top prio? :-d From a non linux browser like chrome this could be expected, but from firefox/chromium I would have expected a solution already.

Chrome runs mostly on Linux (Android).

IMHO developers doesn’t need this feature.
And Linux share is too small to invest in this feature.