There’s no optimizations applied by Raspbian to Firefox. And there’s lots of sticking points using Firefox on the RPI4. For example, using Firefox to surf the web interferes with video playback. Watching a video on VLC is disrupted by scrolling a web page in Firefox. Raspberry Pi 4: Chronicling the Desktop Experience – Firefox Revisited – Week 26 April 22, 2020 Luke Baker Blog, Desktop This is a weekly blog about the Raspberry Pi 4 (“RPI4”), the latest product in the popular Raspberry Pi range of computers.
Back to RPi Guides.
Adding The Mozilla IceWeasel web browser to a Raspberry Pi
The Mozilla Firefox web browser is popular on many computer operating systems. On Debian systems (including Debian and Raspbian on the Raspberry Pi), the implementation of Firefox is rebranded as 'Iceweasel'. More details are available on the Wikipedia page.
The Midori browser does not support many html features, including HTML5, and has stability issues with many web pages. Iceweasel gives you all the features and security updates that are available with Firefox, and adds stability to your browsing experience.
This guide shows you how to install the Mozilla Iceweasel browser on your Raspberry Pi for recent Raspbian or Debian operating systems.
- A booted Raspberry Pi with keyboard, mouse, monitor
- A network connection (Ethernet or WiFi).
- Authorization to use root privileges.
Login to the computer, activate a terminal window by either double click on either of the 'LXTerminal' or 'Root Terminal' icons or menu 'Accessories -> LXTerminal' or 'Accessories -> Root Terminal'. Type the following commands in the terminal:
Answer with a positive response if asked about authorization. With both the 'upgrade' and 'install' steps, answer 'Y' when asked about disk space.
After this sequence, the IceWeasel browser should be installed on your computer. It can be activated from the system menu 'Internet -> Iceweasel'.
This browser should look familiar to you if you are a Firefox user on other systems. All dialogs and features are similar or the same as with Firefox. Many plugins will work on both Iceweasel and Firefox.
Updated: June 27, 2020
Let's fix another problem. This is a big one, and technically speaking, the most important one. Because if you intend to use Raspberry Pi 4 as a desktop system, like I do, then hardware acceleration is a critical component of the overall experience. What this translates to, in layman's terms: smooth video playback with low system resource utilization and less heating.
By default, even the earlier Pi models could play 1080p movies without a problem. This means you ought to get solid results here, too. However, the default configuration is not (currently) optimized for a desktop experience, and we will need to make a few manual changes. Let me show you what you need to do on the system level first - and then how to allow Firefox, Chromium and VLC to use hardware acceleration. After me.
Update system & install libraries
The first, basic step is to update the system:
sudo apt-get update
sudo apt-get dist-upgrade
Then, you need to install a few wee libraries:
sudo apt-get install libgles2-mesa libgles2-mesa-dev xorg-dev
Configuration file tweaks
We talked about this in my guide on how to fix the screen resolution in MATE, where you end up having either black bars top and bottom, or a black border around your desktop, and a weird resolution like 1824x984 instead of full HD 1920x1080. I will briefly repeat some of the stuff, for clarity.
There are two ways you can do this:
- Using the guided tool called raspi-config. However, it may not be present in MATE or work correctly.
- Manually change the boot configuration file that is used to setup the system.
I would recommend you go for the manual change, because it also allows you to better understand what you're doing. The boot configuration is stored in the following locations:
- 32-bit Raspberry Pis (up to Model 3) under /boot/config.txt.
- 64-bit Raspberry Pi (Model 4) under /boot/firmware/usercfg.txt.
On Raspberry Pi, /boot/firmware/config.txt also exists, but this file tells you not to write changes to it directly, and to use usercfg.txt. At the bottom of the config.txt file, there's an include statement, which will pull all your manual overrides from the usercfg.txt file. So this is where we want to make the change.
Open the file in a text editor as root or sudo:
sudo nano /boot/firmware/usercfg.txt
Then add the following lines in there:
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
gpu_mem=128
hdmi_enable_4kp60=1
What we're doing here, we're enabling the 3D video driver (so-called Fake KMS), and we set the memory to 128 MB - please note that Pi 4 does GPU memory management differently from previous models, and since there is a discrete processor for graphics, you don't need as much as you would use on earlier hardware.
Now, there are two other drivers you can try, provided you don't get the hardware acceleration working as you like. So instead of dtoverlay=vc4-fkms-v3d, you can use:
dtoverlay=vc4-kms-v3d
Firefox Raspberry Pi Zero
Or this one:
dtoverlay=vc4-kms-v3d-pi4
You can also change the memory allocation for the GPU, but this is not a trivial topic. So we won't go into that at this point. Just be aware that you have some flexibility in how much memory you want to allocate. The amount of RAM your Pi has will also play a role in getting the number right. 128 MB ought to be fine.
Memory splitting and CMA allocation
One more trick you can do is memory splitting. Basically, you can tell how much memory is allocated to the GPU and how much goes to the CPU. Normally, the memory is allocated dynamically, but you can do your own split. What it actually means is that once this value is crossed (in MB), the GPU will either request more memory from the CPU, or relinquish some back - this can lead to potential performance bottlenecks during intense operations, hence the split allows you to pre-optimize for characteristic use cases. You can see this configuration if you run the raspi-config tool, for instance. It allows you to specify how much memory will be given to the CPU (ARM), and how much to the GPU (VideoCore).
The actual setting is then (either kms or fkms) something like:
dtoverlay=vc4-kms-v3d, cma-128
dtoverlay=vc4-fkms-v3d, cma-128
Reboot & check
Once your Pi boots again, you can check that 3D drivers are loaded and working:
cat /proc/device-tree/soc/firmwarekms@7e600000/status
cat /proc/device-tree/v3dbus/v3d@7ec04000/status
If these two commands return okay, you have hardware acceleration on. If the result is disabled, try with a different dtoverlay option, reboot, and check again. Please be aware that you may not be able to turn the hardware acceleration on for some reason - kernel version, missing graphics stack utilities, etc. If that happens, just wait until the next system update.
Enable hardware acceleration in Firefox
Having your system with hardware acceleration is not enough. You also need to tell individual programs to use it. For whatever reason, neither Firefox nor Chromium have the right flags set by default. In Firefox, you can check the status with about:support. Go to Graphics and check the line that reads Compositing. If the value is Basic, you do not have hardware acceleration enabled.
To override, go to about:config, and search for the following key:
layers.acceleration.force-enabled
And toggle it to true. Restart Firefox. Open the about:support page. The Compositing field should have the value OpenGL. Now you can watch videos as intended.
Enable hardware acceleration in Chromium
Firefox Raspberry Pi Netflix
Similarly, if you choose to use Chromium, it will initially report no HW acceleration under chrome://gpu. We can change that through chrome://flags. What you want is Override software rendering list, and change the setting to Enabled.
Please note that some options will still read Disabled or Software only. This is because some of these are hardware-dependent (if you have say Windows and Nvidia graphics, do the same check, for fun), and some of these depend on OpenGL 3.0. To the best of my knowledge, Raspberry Pi only supports OpenGL 2.1.
Chrome On Raspberry Pi 3
Enable hardware acceleration in VLC
This is the simplest of the three. Tools > Preferences. Click on Video. Under Video Settings > Output, select OpenGL video output. Please note that if you're trying this on a random distribution of choice, or if VLC has not been compiled with OpenGL, this won't work, regardless of what your platform supports.
Testing & results
And now, you need to actually fire up some nice video content and see what gives.
Conclusion
I believe that over time, these issues will disappear, and you won't be needing this guide. Well, I hope so. Looking at Ubuntu MATE - but also Raspberry Pi OS, the defaults are not designed with too much focus for desktop use just yet. That's understandable, but for anyone who does seek to use the Pi as an ordinary mouse and keyboard system, this means a lot of extra work.
Hopefully, this tutorial has all the pieces you need to have an enjoyable multimedia experience. In the next article in this series, we will discuss, you guessed it, audio, a second and just as critical component. That would be all for now, stay tuned.
Firefox For Raspberry Pi 4
Cheers.