Users running a Wayland compositor (such as Sway) may want to use a Wayland-compatible build of Firefox. This can be achieved by replacing the firefox package with firefox-wayland. It’s a switch that does improve the performance of Firefox on most systems — we’re talking ‘buttery smooth performance at up to 60 frames-per-second‘ here. KDE’s Nate Graham reports on the performance gains he got from using web render on his Wayland system, which includes better overall battery life from reduced CPU usage.
Firefox is Mozilla's web browser. It is not the same thing as Firefox OS, which was a full operating system.
Aurora is the 'unbranded' version of Mozilla's Firefox.
Installation
USE flags
USE flags forwww-client/firefoxFirefox Web Browser
clang | Use Clang compiler instead of GCC |
dbus | Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc) |
debug | Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces |
eme-free | Disable EME (DRM plugin) cabability at build time |
geckodriver | Enable WebDriver support |
gmp-autoupdate | Allow Gecko Media Plugins (binary blobs) to be automatically downloaded and kept up-to-date in user profiles |
hardened | Activate default security enhancements for toolchain (gcc, glibc, binutils) |
hwaccel | Force-enable hardware-accelerated rendering (Mozilla bug 594876) |
jack | Add support for the JACK Audio Connection Kit |
lto | Enable Link Time Optimization (LTO). Requires Gold linker when using GCC or LDD linker when using Clang |
openh264 | Use media-libs/openh264 for H.264 support instead of downloading binary blob from Mozilla at runtime |
pgo | Add support for profile-guided optimization using gcc-4.5, for faster binaries. This option will double the compile time. |
pulseaudio | Add support for PulseAudio sound server |
screencast | Enable support for remote desktop and screen cast using media-video/pipewire |
selinux | !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur |
system-av1 | Use the system-wide media-libs/dav1d and media-libs/libaom library instead of bundled. |
system-harfbuzz | Use the system-wide media-libs/harfbuzz and media-gfx/graphite2 instead of bundled. |
system-icu | Use the system-wide dev-libs/icu instead of bundled. |
system-jpeg | Use the system-wide media-libs/libjpeg-turbo instead of bundled. |
system-libevent | Use the system-wide dev-libs/libevent instead of bundled. |
system-libvpx | Use the system-wide media-libs/libvpx instead of bundled. |
system-webp | Use the system-wide media-libs/libwebp instead of bundled. |
wayland | Enable dev-libs/wayland backend |
wifi | Enable wireless network functions |
The above list of USE flag is not comprehensive. Use equery (part of app-portage/gentoolkit) for a full list:
Emerge
To compile the source version of Firefox ESR, issue:
Be aware that non-ESR versions are not getting stabilized.
Emerging the source version of Firefox can be a long process; a pre-compiled (binary) version does exist in the Gentoo repository, however users of the pre-built package should note the warning below and this message. To emerge the Firefox binary, issue:
The disadvantage of using pre-compiled www-client/firefox-bin package is that almost all of the USE flags in the list above cannot be set. Be aware that setting these flags while using this package will not alter the binary.
Configuration
Running under Wayland
Since Firefox 65, it is possible to run Firefox natively under Wayland by launching it with the GDK_BACKEND=wayland
environment variable set after having emerged Firefox with the USE flag wayland
enabled. From a terminal:
To set Firefox to always open using the Wayland backend, set the following environment variable in the user's shell. Bash is the default user shell on Gentoo systems:
~/.bash_profile
Enabling multitouch
Xinput2 scrolling
This brings touch scrolling and multitouch support for Firefox:
MOZ_USE_XINPUT2environment variable has to be set to a value of 1
in /etc/env.d/80firefox, or just before launching firefox in a shell. for example:
This also eliminates the predefined scroll step size for touchpad scrolling! All scrolling will be really smooth.
Wacom tablets/touchscreens may need extra configuration so they emit true touch events for X.
Multitouch zoom
This only works when the multitouch events reach Firefox, therefore the Xinput2
activation above has to be done first.
Description | about:config option | Value |
---|---|---|
Multitouch activation | gestures.enable_single_finger_input | False |
Zoom in | browser.gesture.pinch.in | cmd_fullZoomReduce |
Zoom out | browser.gesture.pinch.out | cmd_fullZoomEnlarge |
Middle mouse scroll (autoscroll)
Traditionally in Linux, the middle mouse button is used to paste the currently selected (highlighted) text into a text field. On Windows systems, the middle mouse button in Firefox is used for click-and-drag scrolling up and down the page. This functionality can be enabled in Firefox by opening about:config
and setting the following value[1]:
general.autoScroll = true
Middle click-and-drag scrolling should now be enabled.
Although not necessary, sometimes it is desirable to disable all other middle-click functionality within Firefox when using click-and-drap scrolling. Open about:config
and set the following values to disable middle-click functionality:
middlemouse.contentLoadURL = false
middlemouse.openNewWindow = false
middlemouse.paste = false
Threads
Firefox >= 54 has 4 threads enabled by default. Threads can be adjusted by modifying the following in the about:config
interface:
Firefox Wayland Support
Description | about:config option | Value |
---|---|---|
Increase the threads | dom.ipc.processCount | N |
Where N
is an integer number.
Audio backend
Firefox's cubeb audio library supports a number of different backends[2][3].
Description | about:config option | Value |
---|---|---|
JACK | media.cubeb.backend | jack |
Disabling percent-encoding
Firefox Wayland Environment Variable
Normally, URLs that are copied from the address bar get percent-encoded. This may cause an annoyance when certain non-Latin symbols (such as Cyrillic) get encoded, as they become unreadable to humans.
To disable percent-encoding when copying from the address bar, set the about:config
option network.standard-url.escape-utf8
to false
.
Unfortunately Firefox does not support non-Latin symbols in anchors, those remain encoded (not percent-encoded, though).
Disable enforced digital signatures verification in Firefox >=48
This concerns mandatory add-ons signature in Firefox and can lead to security issues.
Method 1
Create this file:
Then insert this:
Firefox Wayland
/usr/lib/firefox/defaults/pref/channel-prefs.js
Method 2
Method 3
This patch works for both firefox 49 and firefox 51, and seems to be robust to changes.
/etc/portage/patches/www-client/firefox/no-signature-force-check.patch
A quick and easy way to improve the performance of Firefox on Linux is to force enable WebRender.
At some point in the near future Firefox will make web render the default rendering engine for all users of the browser, on as many systems as possible. But until that happens you can force enable WebRender on Linux to get the benefits (like reduced CPU usage) right now, no waiting.
What is WebRender? I’ll let Mozilla explain:
“WebRender […] will replace Gecko’s existing compositor, interfacing with Gecko’s main-thread layout code. As WebRender is written in Rust and uses a very different design approach, we expect to get stability and performance benefits from this switch.”
To be (intentionally) reductive: the feature leverages a system’s GPU to render web content, rather than the CPU as it does at present.
It’s a switch that does improve the performance of Firefox on most systems — we’re talking ‘buttery smooth performance at up to 60 frames-per-second‘ here. KDE’s Nate Graham reports on the performance gains he got from using web render on his Wayland system, which includes better overall battery life from reduced CPU usage.
Mozilla began to enable WebRender in Firefox by default on compatible Windows systems starting September 2018. Since then the tech has slowly rolled out to more users on more systems and across more configurations, including macOS.
But WebRender is not yet default on most Linux systems, regardless of whether it is Wayland or Xorg, using closed source or open source graphics drivers, and so on.
To enable WebRender in Firefox on Linux manually:
- Open
about:config
in a new tab (and okay any warnings) - Search for
gfx.webrender.all
- Set the value to
True
to enable WebRender (orfalse
to disable it)
Your own milage will vary when using this feature. You may encounter edge cases or introduce issues after turning it on. But as it’s easy to turn off should any hiccups emerge, the probable performance benefits it offers are worth the hassle of trying it out.