#36 - Firefox on NVIDIA Graphics Card
Using the NVIDIA driver in Linux is quite difficult and it is not so straightforward because it varies depending on what application needs it. Mining Monero was not too difficult but the XMR miner used CUDA and that is another story.
Configuring Firefox to use NVIDIA may be overwhelming option-wise because there are so many unstable outcomes when setting these experimental or unstable options.
NVDIA-related Drivers
Below is a listing of my NVIDIA-related packages on Arch. Packages with * are probably required for this to work, other packages are currently installed but may not be strictly necessary..
nvidia
*nvidia-settings
nvidia-utils
*mesa
*mesa-demos
*opencl-nvidia
xorg-xrandr
acpi
*acpi_call
*acpid
*bbswitch
*bumblebee
*primus
primus_vk
Most packages can be easily installed from the official repos, however others may be further configured to use.
For example, bumblebee
manual (beware this is not compatible with
other methods for using NVIDIA), requires the user to be in the
blumblebee group with # gpasswd -a user
bumblebee
and enabling/starting the service #
systemctl enable bumblebeed.service
.
bbswitch
will work well with bulblebee
in switching the card ON and OFF when required, instead of leaving
it ON.
That is possible to check if the card state with some commands.
Make sure to reboot
after installing and configuring
these driver packages so far.
% nvidia-smi
[DETAILED CARD STATS] [..PAGED..]
% cat /proc/acpi/bbswitch
0000:01:00.0 ON
% watch -d -t -n1 'cat /proc/acpi/bbswitch'
0000:01:00.0 ON [..PAGED..]
# tee /proc/acpi/bbswitch <<<OFF
OFF
# tee /proc/acpi/bbswitch <<<ON
ON
Firefox Configuration
With those set, there are two important configurations to be
done in Firefox Stable's about:config
. The following was
taken from Arch Wiki's Firefox#Tweaks
and Firefox#Talk.
In about:config
, you may want to set one
configuration at a time and test:
- Enable OpenGL compositor:
layers.acceleration.force-enabled = true
* - Enable WebRender compositor:
gfx.webrender.all = true
My current Firefox can run stably and smoothly (under XFCE and
Picom) with only layers.acceleration.force-enabled
set, as force enabling the webrender makes my Firefox very buggy
and unstable..
Alternative (or additionally, you will need testing) to messing
with about:config
options, Mozilla Firefox can read
various environment variables as options.
Below these variables are presented with verbose commentary. You can find more code commentary in my shell script launcher.
#This content should be clarified
#To enable WebRender on Firefox Stable:
export MOZ_ACCELERATED=1 #same as:`layers.acceleration.force-enabled = true'
#export MOZ_WEBRENDER=1 #same as: `gfx.webrender.all = true'
#https://wiki.archlinux.org/index.php/Talk:Firefox/Tweaks
#Enable OpenGL in `pvkrun' and `primusrun'
#export LD_PRELOAD=/usr/lib/libGL.so
#export ENABLE_PRIMUS_LAYER=1
#https://github.com/felixdoerre/primus_vk
#https://bugs.archlinux.org/task/65250
#https://bbs.archlinux.org/viewtopic.php?id=252257
#`layers.offmainthreadcomposition.enabled' became on by defaults.
#https://www.reddit.com/r/firefox/comments/4j0tzz/what_happened_to/
#Do *not* set if using NVIDIA `primusrun'
export MOZ_OMTC_ENABLED=1
export MOZ_USE_OMTC=1
#https://gist.github.com/yuttie/de097d004499adb984bd
Remember to export
your environment
variables!
As I said, you may need to try various combinations of options until Firefox is running smoothly, without artifacts, visible button icons and legible menu entries..
Performance test: optirun
, primusrun
and pvkrun
That is probably a good idea to test which package will run
faster. Check performance running either glxgears
-info
, glxspheres64
or
glxspheres32
(the latter for 32 bit systems) from
package mesa-demos
.
optirun [demo]
optirun -b primus [demo]
primusrun [demo]
pvkrun [demo]
I prefer to run glxspheres64
because it prints the
frame rate and buffer size. primusrun
and
pvkrun
used to work a little better than
optirun
in the past for me, but as those are not
working now I am using optirun
..
Checking results
Current configuration can be checked at about:support
.
Follow instructions from Firefox#Tweaks
to check if options are enabled. You can also type
CTR+F
and search for `Intel' to check whether
Intel integrated graphics or `Nvidia' driver is being used
as renderer.
Alternatively, some information can be retrieved from test this website.
It is a little time consuming until you get yoru configuration working properly and maybe your system cannot support all features, but they will eventually come the official way and your driver may finally be white-listed for performance improvements by defaults.
As for now, I find it best to launch Firefox with a shell
script. My Firefox launcher in XFCE dock and keyboard shortcut
in .xbindkeysrc
also points to the script.