Enable hardware graphics acceleration in Chromium web-browser running on Ubuntu MATE 21.10 on RPi 4

I'm trying to use my existing Raspberry Pi 4 with 4 Gb of RAM as media player for various video content - local and from online web services.

Modern Ubuntu MATE 21.10 ships Chromium as Snap, so traditional methods does not work for it. As first step one should remove Snap version of Chromium by sudo snap remove chromium.

Possible workaround is to install Chromium using the same deb-package as RaspberryPi OS provides.

It is done by using commands below:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E
sudo apt-add-repository "deb http://archive.raspberrypi.org/debian/ bullseye main"

cat <<EOF | sudo tee /etc/apt/preferences.d/pin-chromium
Package: *
Pin: release o=Raspberry Pi Foundation
Pin-Priority: -1

Package: chromium*
Pin: release o=Raspberry Pi Foundation
Pin-Priority: 1000

sudo apt-get update
sudo apt-get install chromium-browser

Then launch Chromium to configure it as usual - enable the following options on chrome://flags:

  • Override software rendering list aka #ignore-gpu-blocklist;
  • GPU rasterization aka #enable-gpu-rasterization;
  • Zero-copy rasterizer aka #enable-zero-copy;
  • Enables Display Compositor to use a new gpu thread. aka #enable-drdc;
  • Out-of-process 2D canvas rasterization. aka #canvas-oop-rasterization.

Relaunch it using chromium-browser --enable-features=VaapiVideoDecoder, visit chrome://gpu to ensure that you have all (excluding Vulkan) options enabled:

Graphics Feature Status

  • Canvas: Hardware accelerated
  • Canvas out-of-process rasterization: Enabled
  • Compositing: Hardware accelerated
  • Multiple Raster Threads: Enabled
  • Out-of-process Rasterization: Hardware accelerated
  • OpenGL: Enabled
  • Rasterization: Hardware accelerated on all pages
  • Skia Renderer: Enabled
  • Video Decode: Hardware accelerated
  • Vulkan: Disabled
  • WebGL: Hardware accelerated
  • WebGL2: Hardware accelerated

To make --enable-features=VaapiVideoDecoder flag permanent one should edit the relevant config-file programmatically as shown below:

echo 'CHROMIUM_FLAGS="${CHROMIUM_FLAGS} --enable-features=VaapiVideoDecoder"' | sudo tee /etc/chromium.d/92-vaapi-hardware-decoding

As the result all web-players will play 1080p without lags and tearing.

1 Like

The naming for the Chromium flags is a bit misleading, since the Pi has no VAAPI support.

My experience, after trying this on a 21.10 UM install, was that video on the site I used for testing (Crunchyroll) still took about 90-95% of the CPU, but unlike the pure software decode also crashed in less than 2 minutes. That sort of crash is consistent with the behavior of Chromium when using 32-bit Raspbian several months ago, but whether that's Chromium at fault or the HW decoder isn't something I've cared about enough to look into (since I have no interest in using Chrome other than FOR streaming video, so the constant crashing makes it useless to me).

CPU load isn't necessarily a meaningful metric, since the Pi can clock from 900 to 1800 MHz, and 90% load at 900MHz will obviously run FAR cooler than 90% load at 1800MHz with the CPU doing all the work. But since it crashes so much, I can't get it to run for long enough to see whether it gets to the same titanium-burning levels of heat that it does when watching non-crashing videos via FF and the SW decoder. :slight_smile:

I'll probably try it out on YouTube at some point (with h264-ify), but a browser that constantly crashes doesn't really appeal much to me, and even if it does work there I don't watch enough YT these days for it to be worth keeping around anyway for me personally.

Glad there's something that appears to be progress on this front for you though. Maybe in another 3 years the Pi stack will reach the point of actually being able to play accelerated h265 via a standard method rather than only though a massively hacked-up custom version of VLC that's so broken it's unusable even though the acceleration works spectacularly well. :frowning: (< 10% CPU for 1080p h265).