Enabling Hardware accelerated video decoding or GPU activity in electron app for Linux
Image Source: Picsum

As chrome or chromium browser does not support hardware accelerated video decoding for Linux OS. Though there is a pending PR in chromium repository to merge but google has no plan to merge it.

Due to software base approach for GPU activity , electron app performance might be affected in Linux environment. But by installing some driver for Linux and passing flag in chromium can enable hardware accelerated activity in electron app. Lets start with the steps to enable hardware acceleration in electron app for Linux OS (Mainly ubuntu):

Check weather hardware accelerated activity is supported in currently.

Open chrome developer console put the following code.

 window.location.replace("chrome://gpu");

This page should following if not supported.

Driver Installation:

PC running the electron app must have following driver install on the system. ` libva-glx2 , libva-x11-2, i965-va-driver chromium-codecs-ffmpeg-extra, libgl1-mesa-glx`

sudo apt install libva-glx2  \
libva-x11-2 i965-va-driver chromium-codecs-ffmpeg-extra libgl1-mesa-glx

Adding flags while running electron app.

In you package json, you can change start script with following:

Before:

 "start":"electron ."

To:

"start": "electron --enable-accelerated-mjpeg-decode --enable-accelerated-video --ignore-gpu-blacklist --enable-native-gpu-memory-buffers --enable-gpu-rasterization ."
The Architect

The Architect

Lead Architect at The Coders Blog. Specialist in distributed systems and software architecture, focusing on building resilient and scalable cloud-native solutions.

Understanding logo files format
Prev post

Understanding logo files format

Next post

Best way to get the current date and time in JavaScript

Best way to get the current date and time in JavaScript