Source: Google

My summer experience with Mozilla -Servo

I was writing my first blog from last two month and waited for the right time to post. And Mozilla quantum is released last week(Nov 14, 2017) I think this is the best time to share my contribution to the servo.

Quickstart with servo intro:

Servo is a modern, high-performance browser engine designed for both application and embedded use developed by Mozilla Research. The goal is to create a new layout engine using a modern programming language (Rust), and using parallelism and code safety, to achieve greater security and performance versus contemporary browsers. Servo began in 2013 and there are so many easy tasks waiting for rust contributors. So, go pals hack on servo :) Servo developers merged part of the servo in firefox and launched Mozilla Quantum.

I chose this video among all the available latest video because everyone watched the power of servo in Firefox quantum but, only this video will show you how it all started. An Introduction to Servo

I was the part of RGSoC intern. Me and my friend Rakhi contributed together to this project. A big thanks to RGSoC community to come up with so many good projects.


Summer experience with servo

My major work was to write algorithm and test cases for parse srcset attribute in Rust.

Srcset: It defines the set of images we will allow the browser to choose between, and what size each image is. The srcset attribute specifies the URL of the image to use in different situations.

After the basic intro of srcset I started with the standard specification of parsing srcset attribute. The language used in the specification was hard at first to understand but with help of servo contributor especially my mentor Josh and coaches Rahul and Ravi, it was easy. Ask on IRC #servo channel if anyone is planning to contribute and stuck with the specification.

What Rust taught me:

Rust was new for me and I never used it before so learning and implementing rust features within summer was a little bit tough. But I learned and implemented some good features of rust. Few mentioned below:

  • match: It replaces complicated if/else or it can also be used as C switch.
  • Generic Data Type: It is more flexible, provides more functionality and removes code duplication.
  • try: try execute the closure, passing it to the parser.
  • loop { } : Rust provides a loop keyword to indicate an infinite loop. The break statement can be used to exit a loop at any time, whereas the continue statement can be used to skip the rest of the iteration and start a new one.
  • Bindings: You can bind values to names with @ .(Note: I used this a lot in my code )

Ravi taught me very good hack on git. I’ll share that on my next blog.

You always learn from the problem you faced and I am sharing the solution to all the challenges that I faced.

Rahul taught me How to read specification:
1. Read cover-to-cover, multiple times.
2. Read backwards at least once. 
3. Read by picking random sections contents and following all cross-references.
4. Define italic type word a variable.
5. Define static or enum if something is followed by “is a”.

Build and run servo: Servo is a huge project and building servo on my ubuntu take more than 2hr. I noticed that people never share their build problems and hack to solve them. So I am sharing what to do when you are building a large project on the low configurated system. 
1. Janitor: a simple web app that uses cloud9. An easy way to contribute to Firefox developer tools. Everything happens on the web and it doesn’t require any download and installation. It builds your code as fast as possible. Because it is web-based, so your code is always there for you, on any device. (I always trouble Jan if Janitor troubles me :P Thanks for being so supportive)
2. Create a separate new rust project and inside lib.rs paste all the code you wrote and run using cargo test. (Note: I did this with the help of my mentor(Josh). If you want to build this way then take someone help from servo maintainer to clone only necessary files)


My overall experience of summer with servo was great. I am happy that I contributed to the servo. The benefit of contributing to a huge project like servo, is that it pushes your limit of grasping knowledge. I’ll continue my contribution to the servo :)