Why should one keep an eye out for Servo

Flaki
7 min readDec 1, 2014

--

(and just why are we not there yet)

For those late to the party — what is Servo?

Well, if you have never heard of Servo — Servo is a brand new open-source browser engine, built from the ground up by Mozilla and Samsung (and a host of third-party open source contributors). Browser engines are the “soul” of a browser — the “Gecko” engine in Firefox (OS), “Blink” in Chrome/Opera etc. is what makes the web tick. Servo is completely open source, highly parallelized and is written in a new programming language, called Rust.

Currently, the most comprehensive source of Servo-related information is the Servo GitHub repository, more specifically the Servo Wiki. For a quick introduction, you might want to watch the talk below by Lars Bergstrom, researcher at Mozilla Research:

Lately, leading up to the release of Firefox Developer Edition, one could have caught quite a few people wondering, whether “the new browser” would include a “new browser engine”, too. Some of these musings were just plain silliness — like the ones writing off Mozilla as a “douchebag” as now they would “have to support a new browser engine” — but some were a bit better-informed, envisioning the inclusion of Servo in the new Firefox browser. Should they knew more about Servo, these rumors wouldn’t have spread in the first place — and since information is out there in the open, I decided to do a writeup on the state of Servo.

Firefox Developer Edition had since gone live — and surprise-surprise, it didn’t include any new browser engine! Servo is currently a research project at Mozilla — and while yes, browser engines are the salt-and-pepper at Mozilla, so they definitely want to use it in production as it matures, it’s just not there yet. The above (and much more!) is discussed in the two-hour marathonic meetup session on Rust & Servo below, should this whetted your appetite to dive into Servo and browser-engine internals:

Now that we cleared all that up, let’s dive into exactly what is preventing Servo of being included in a real browser — and when can we expect that happening!

The first issue — Rust is still in its infancy

For people not familiar with Rust — it is a low-level, systems-programming language (somewhat close to the level of C/C++), that is theoretically memory safe, includes countermeasures to a host of memory-related crashes and is built from the ground-up with parallelization in mind.

I’m saying “theoretically”, because (and this is one of the reasons why Servo is still experimental), because Rust itself is pretty much in its infancy. While it is approaching version 1.0 fast, the language has not yet matured/stabilized enough to provide a reliable base for consumer-grade software (let alone a whole browser(engine)). A disclaimer at the Rust website itself suggests (half?)jokingly, that

[Rust] may do anything it likes up to and including eating your laundry.

So why use Rust at all, then? Well, first: Rust is awesome! This new programming language — besides incorporating the learnings from decades of programming language design experience — is actually shaping alongside the development of Servo, the two existing and evolving in a kind-of-symbiotic relationship. If you are coming from a well-founded systems programming background, you might be interested in this writeup by Rick Branson where he explains why he has such high hopes for the language, talking about the fores and vices of Rust compared to other similar-level languages including C, C++, Java & C#.

Next: while Servo is very promising, it is still missing a lot of key features

Due to its high level of parallelization and the code that is rewritten from scratch with years of browser engine experience to back it up, Servo is fast. It is (in its current, unrefined state) sometimes up to twice as fast as Gecko. Rendering & feature benchmarks are tricky, though — as comparing Gecko and Servo is currently a bit “apples-to-oranges”. This is due to the fact that Gecko does much more. Gecko implements the complete feature stack of a modern browser — that includes laying out tables, floats, rendering gradients etc. What Servo can’t do — will fail instantly, thus being able to lay out and render pages faster, but with features missing.
That said, there are, though, some benchmarks and web pages that already work just fine, utilizing a subset of features — and those look quite promising:

https://twitter.com/pcwalton/status/518856826918420480
Google’s fallback HTML4 homepage, rendered in a recent buid of Servo

Servo currently implements a brand-new HTML5-parser called html5ever, and does layout & rendering on a level of a late 2006–2007 web standards-compilant browser, passing the ACID2 test this spring:

https://twitter.com/halflings/status/461925921243418624

Of course, there are a lot of things missing yet, but improvements and features are pouring constantly into the engine — for example Servo is currently one of the first engines to support native rendering of vertical texts, and CSS3 Linear Gradients has just landed this month, inching closer and closer to feature-parity with the “big guns”.

Mobile is just not there (yet)

Parallelizing tasks during web page layout & rendering is gaining importance as chipsets (and graphics controllers) abandon the pursuit of ever-increasing clock speeds in favor of packing more and more cores onto the circuit board. This is especially true for handheld/mobile platforms like ARM. Unfortunately — and this is another catch — current development targets desktop, rather then mobile, resulting in a (for now) subpar ARM performance, and in Gecko on mobile/ARM currently outperforming Servo.
Regardless, on the long run, of course the goal is to have Servo bring comparable advantages to the mobile platform as the ones it brings to the desktop — in fact, an alpha release for Android is already in the pipeline, planned for early 2015!

https://twitter.com/pcwalton/status/515678867416047617
CNN in Servo http://imgur.com/6PJQAfW?tags

Another feature of Servo, is that it does a lot of things off the main thread — is the only browser currently that does Layout off the main thread — resulting in great improvements in parallelization, also off-main thread compositing which results in iframes in separate threads.
If you didn’t understand a single word of the above tech-babble, it basically means multiple cores on your device (be it processing or graphics cores) are better utilized, due to the high rate of fine-grained parallelism the whole system is built around. Also moving stuff off-main thread helps a lot with the pan/zoom/scroll experience — it results in a much smoother user experience (even when a lot of computation, DOM manipulation is happening in the background). This prevents a lot of “jank” (choppiness) of the general browser user interface.

So when will I be able use Servo then?

Servo is coming along nicely — if you want to know more about its future, I recommend you check out the Roadmap on the Servo Wiki. If you want to follow more closely, there are quite a few great fellows at Mozilla Research, working on Servo — including, but surely not limited to Patrick Walton, Matt Brubeck or Lars Bergstrom — I highly recommend following them on twitter (linked!) so you are up to date on the latest news.

Also, keep in mind, that Servo is highly modular and pluggable — so do you need a fast & nice HTML5 parser, tracking the WHATWG HTML Living Standard as close as it gets, and one that includes either Rust or C bindings? Well, you are at luck, because html5ever is there for you — you could have started using it today! This modularity and pluggability is true (and an intentional goal!) of several parts of the nascent browser engine, and are actually planned to land in Firefox, replacing some aging parts (like the current HTML tokenizer, that was actually machine-translated from Java to C++) prior to Servo being finished at all.

And well, after all — there is really no better way to follow Servo’s evolution, than working on the code itself — so if you are up to taking a dive deep into Rust-wonderland, I implore you to…

Contribute! — and make Servo happen yourself!

Helping Mozilla reach the above-mentioned goal of shipping Servo is a trivial task for anyone with a bit of programming mojo — contributions to Servo source code are on the rise — and it’s actually quite easy to contribute, so please do so, even if you haven’t seen Rust code ever in your life!
Rust is fun, you should check it out, if you haven’t yet — also, there is a whole host of marked “easy” bugs on the Servo GitHub issue tracker to get you started.
And just how “easy” are these easy bugs? So easy that they are getting fixed at a rate faster than created!

https://twitter.com/lastontheboat/status/539340916377387008

Thanks to Lars Bergstrom & Patrick Walton for their presentations & kind feedback on the article! You could follow them on Twitter (links above) to receive timely updates on Servo-progress!

--

--

Flaki

JavaScript, Hardware, Games · Skylark · Mozilla · Tessel Project