Before any steps, let’s check if GPU acceleration is already on.
- Open about:support in Firefox.
- Navigate to Graphics section.
- Check the GPU Accelerated Windows field.
If it’s 1/1
or 1/2
or 2/2
or whatever, anyway, the first number must be greater than 0, then Firefox is already hardware accelerated. And you don’t need to take following procedures to force-enable it. Otherwise, let’s do a few modifications to force-enable the GPU acceleration in Firefox!
- Open about:config in Firefox.
- Set
webgl.force-enabled
totrue
. This will force-enable WebGL for us. - Set
layers.acceleration.force-enabled
totrue
. This will force-enable Layers Acceleration. - Set
layers.offmainthreadcomposition.enabled
totrue
. This will enable Off Main Thread Composition (OMTC), which should contributes to a faster and smoother composition.
If you want to enable more testing OMTC features, you could set layers.offmainthreadcomposition.async-animations
to true
as well. Other properties such as layers.async-video.enabled
should already be true
by default now. Therefore, you don’t need to mess with other values.
Another trivial yet important step is to set an environment variable. Before we set it for entire system, let’s check if Firefox can behave well with force-enabled GPU acceleration.
- Close all firefox processes.
- Run
export MOZ_USE_OMTC=1 && firefox
in terminal.
Now go to about:support to check if GPU acceleration is turned on. And test if Firefox still function well without glitches. In my case, the GPU Accelerated Windows field shows 1/1 OpenGL (OMTC)
.
If you’re satisfied with the result, let’s set this environment variable globally. Create a new file /etc/X11/xinit/xinitrc.d/90-x11-common.sh
(you need root privilege) and fill in this file with following lines.
#!/bin/sh #force GPU acceleration for firefox export MOZ_USE_OMTC=1
Now reboot your system, run Firefox as usual, i.e. from Application Launcher. Enjoy hardware accelerated Firefox!
P.S. I use Fedora as my Linux distribution, other distributions might have different init mechanism. In that case, you may need to put 90-x11-common.sh
file in a different location.