Firefox Rebirth: Rust, Servo and Project Quantum
As a champion of people powered technology, my favoured web browser has always been Mozilla Firefox. The project was started from the ashes of Netscape to break the dominance of Microsoft's Internet Explorer, and now a non-profit foundation, it works to improve technology for the people.
From a web development point of view, it was also traditionally the browser that stuck most closely to the standards set by the W3C (The not-for-profit that defines the technology specifications that browser vendors adhere to), so it worked to develop your websites to the standards and then fix issues in the other browsers after.
In this day and age, where being standards compliant browser is par for the course, for the most part browsers do render things the same. So for me it's about the principle, I want to use technology that is designed to make my life easier and more productive, not provide a window for steering me towards a certain ad network.
So now that we're over the standards issue, what is the new battle ground for browser vendors? What are Mozilla developing to lead the way in browser technology that promotes a free and open internet for all? Let's demystify the tech!
The Current State of Play
We currently have 4 major browser engines that are being actively developed:
- WebKit which powers Apple's Safari browser (Initial release as KDE, 1998)
- Blink which powers Chrome and Opera (A fork of WebKit)
- EdgeHTML which powers Microsoft Edge (Fork and partial rewrite of Trident, Internet Explorer's rendering engine, initial release Internet Explorer 4, 1997)
- Gecko which powers Firefox (Initial release as Netscape Navigator 6, 2000)
As you can see, they are all to different extents based on 20 year old technology, that's not to say that the code is poor quality or that they haven't been continuously developed over time, but the landscape is different now.
Back in the day, we were all working exclusively on desktop computers, and those PC's had a single CPU with a single core, we browsed mainly static websites, on slow connections.
Fast-forward to today and we have a plethora of different devices, architectures, multi-core CPU's, and we have added GPU's into the mix. We are also using the web browser for more demanding tasks, from dynamic apps to online gaming, and we require our browsers to be kind to our batteries on low powered devices.
And therein lies the problem, with today's browsing demands, changes in architecture, and power requirements, how do you upgrade 20 years of development to support these technological advancements?
Mozilla Firefox
Mozilla Firefox had been losing browser share since it peaked in 2010 at around 30% of the desktop market. It is currently hovering at around 12% on desktop. Mobile is a different story, where it claims less than 1% of the market.
The reason behind this is that Mozilla basically dropped the ball, from 2013 to 2015 they bet the farm on developing Firefox OS, their answer to Android for developing markets. In theory it is a good idea, develop a multi-platform operating system that is rendered using a browser where all the apps are developed using HTML, CSS, and JavaScript.
But apart from the fact that they had missed the boat on the current mobile OS market, they didn't have the budget or browser to offer anything that would be better than the competition, the browser architecture simply isn't up to the challenge.
Thankfully they have now realised this, and have refocused their efforts on their flagship product, Firefox. Because whilst they were trying to enter the mobile OS market, the other browser's in technology terms simply overtook them. They have only recently implemented sandboxed browser tabs, which the other vendors rolled out way back.
Mozilla Research
Thankfully they have a strong community of developers, and from their work, they do have a number of things up their sleeve.
Mozilla Research is a department of Mozilla Foundation that develops emerging and experimental technology, through the sponsorship of open source projects and it's own initiatives, and a number of interesting technologies see now emerging from this incubator.
Rust
Started by a Mozilla developer in 2006, and picking up sponsorship from Mozilla in 2010, Rust is designed to be a fast, concurrent, and memory safe alternative to C++.
All of the web browsers described above are written in C++, and all exhibit the same security issues, namely "buffer overflows", this is where the software allocates memory to a variable in its code, but mis-manages how the data is handled through human programming errors, enabling attackers to push more data into that variable than it has memory allocated, causing the "buffer" to overflow and write data to another part of the memory. This enables attackers to access data or parts of the program they shouldn't, which they can then build into an exploit and put on a web page to capture victim's.
The reason this can happen is because C++ is an memory unsafe language, it is the job of the developer to allocate memory, manage it and unallocated after it has been used, also for performance reasons memory is sometimes allocated in an unsafe way. Rust seeks to correct this issue by being memory safe by default, and managing the memory allocation for the developer, it's compiler is designed to catch unsafe code before the code is even compiled.
Rust is also designed to be highly concurrent, and makes it easier to split jobs up into work packages at a very finite level that can be set to work in isolation, by enabling this, all those CPU's and GPU's can be used more efficiently.
Now at version 1.2, it has come top in Stack Overflow's developer survey in the most loved programming language category for the last two years.
Mozilla Servo
Another project sponsored by Mozilla Research and Samsung, Servo is an new experimental web browser. Built in Rust, it takes advantage of those features described above to build a browser that is capable of utilising all the available resources of modern hardware, and security features that are simply not possible in the current version of Firefox due to its aging architecture.
There are many stages to rendering a web page, from parsing the HTML into a DOM tree, to applying CSS rules, working out where on the page all these items should be rendered, and drawing it to the screen. Servo uses the power of Rust to divide all these operations into little work blocks and sets them to work utilising all the available hardware, and the results are incredible:
This video from 2016 shows 499 animated objects on screen in the latest versions of all browsers to show you the performance difference, i've no doubt that Servo could produce an even higher frame rate, but it is frame limited to 60fps in this demo.
If you are interested in a more in-depth dive into the internals of Servo, I highly recommend watching this presentation from the San Francisco Bay area Rust meetup where Patrick Walton walks you through some of the ideas and methodology behind Servo and specifically the WebRender component.
Project Quantum
Moving from experimental browser to fully fledged product it's not going to be an easy journey for Mozilla, they have done some amazing work thus far. They have created a new programming language, and matured it by building a fast and secure rendering engine, now they have to get it out there.
Their plan for this is called Project Quantum, what they are doing is developing the components of Servo, and then integrating them bit by bit into Firefox, a process some have described as akin to refitting a jet engine mid flight!
The result should be that Firefox will be able to shake off the shackles of its current architecture, and overtake the other browsers in terms of performance and security, whilst keeping all the good work and tools that surround the pictures it generates in the middle of your screen.
Indeed they are already preparing to ship the first component of Servo into Firefox. Quantum CSS (a.k.a Stylo) is the part of the browser that parses and computes the style properties of each object rendered to the screen.
It is already available to test in Firefox Nightlies and Firefox Developer Edition, it must be turned on in the settings by going to about:config
and setting layout.css.servo.enabled
to true
.
If you are using the release version of Firefox, expect to see this and a whole host of other improvements including a new UI design in version 57 which will be released on 14th November 2017.
The Future
Mozilla have a lot of work to do to regain a foothold in this market and start determining the direction. Personally I think the changes they are planning set an excellent grounding for making a comeback, they will have the technology, but they are going to need people to believe in them again to restore their crown, and in the mobile market, even be relevant.
For me it is of course about the technology, but it is also very much about what they stand for, and in turbulent times, when big corporations are controlling more and more of our data, Mozilla Firefox will hopefully be there on the frontline, championing what's best for the people.
Are you a Firefox user? Or have you switched to Chrome? Tell me your experience in the comments, and if you like this article, please upvote, resteem, and follow me @hexydec.
It might be too little, too late. I can't imagine returning to Firefox now unless it was way, way better than the competition.
Hopefully it will be significantly better than the competition and it needs to be, but it's the principle of the thing, you shouldn't have to give up your browsing habits to have a good browsing experience.
57 is the first release with this new tech in it, expect more technology to be ported from Servo, and for the current tech to be refined further in future releases.
I love Firefox, I have been using it for more than a decade and haven't left, sure it has had its ups and downs but for the most part it has been a solid user experience.
I use the privacy badger and HTTPS everywhere extensions from EFF for some extra piece of mind and ublock origin to block annoying ads and known malware.
Are you insane?
FF went to shit, I had to downgrade to 55
55 is the current release, 56 is still in beta and 57 is currently only available in nightlies, and will contain bugs, if you aren't prepared for that then I suggest you stay on the release track.
You can never solve a problem on the level on which it was created.
- Albert Einstein