firefox-ios - Class Project

Stage 0:

  1. Project name:
  2. Team members:

Introduction

Firefox iOS is a browser from Mozilla for the Apple iPhone, iPad and iPod touch mobile devices. It is the first Firefox brand browser to not use the Gecko layout engine that is commonly used in Firefox for desktop and mobile devices that are not iOS based. Due to Apple’s application review policies, Firefox had to use the built-in iOS WebKit-based rendering framework instead of its own Gecko. Firefox iOS supports Firefox Sync which makes it able to sync Firefox’s browsing history, bookmarks, and recent tabs.

Architecture

General browser architecture:

Reference

Firefox’s architecture can be presented as seen in the following bottom figure, however, as mentioned before, because of Apple’s policies they had to use the built-in iOS WebKit instead of Gecko.

Reference

Resources

Firefox is an open-source browser which means that users around the world are able to help improve it. Contributers can communicate through:

They can find the list of bugs that need to be fixed at the following URL links:

Statistics

The weekly commits graph: Reference

Notice the high frequency change in the code change by observing the following graph: Reference

By looking at the following release frequency, one can understand that firefox uses the agile developing method. Also according to itbusinessedge: “Mozilla has also begun using a hybrid model that incorporates elements of both agile and waterfall approaches for its flagship Firefox Web browser. The goal is to more quickly introduce new features – aided by agile’s emphasis on iterative releases – while maintaining backward compatibility, security and overall code quality.”.

Reference

Firefox keeps its bugs/features list in their issues in github: Reference

Contributor guidelines

Using Firefox’s official site Bugzilla, developers can find a list of bugs in the firefox code. All developers must follow the following Swift style to keep the code organized: https://github.com/raywenderlich/swift-style-guide.

Adding small * Exceptions like: they use 4-space indentation instead of 2.

Further information can be found at Firefox-ios contributor guidelines

General source code structure

Firefox separates the code to packages to keep everything organised to help developers add/fix features with ease. The following figure shows the code structure, we can see that there are packages for : Account, Client, Extensions, etc… For most packages there is a corresponding package for tests: AccountTest, ClientTest, etc… . That way if firefox-developers or external-contributors make changes to the code, they wouldn’t break the browser’s functionality. General detailed code structure can be found at (note: this code structure are for windows, but its the same for all platforms in general):

Reference

Stakeholder view

are the people that provide documentation of the system for the users and administrators. Furthermore they may provide training for staff or the development team. Communicators often promote the product by sharing the product’s key features and benefits to other stakeholders.

Firefox is a global webBrowser, They have a “Mobilizers” community. Mobilizers are tech/geek enthusiasts that are committed to spreading Firefox OS and other new Mozilla mobile products. Mobilizers receive periodic missions asking them to do a simple action to teach others about the new Firefox OS. Mobilizers will also attend, assist or host events in their market about once a month Reference.

are responsible for the implementation and deployment of the systems’ specification. That is: design, code, test and accept. Their concerns lie with the platform that is being used, programming languages for writing code, tools used, dependencies needed, as well as the maintainability and flexibility of the system.

The most active and notable developers at this moment are: Stefan Arentz, Brian Nicholson, Stephan Leroux and Richard Newman. These developers create pull requests with new features or fixes (Stefan Arentz only fixes bugs). It is important to note that these are not the only developers working on the firefox project. The relevant core team can be found at Firefox-team.

are the ones that test the system to ensure that it works exactly the way it is intended to work.

Stephan Leroux and Brian Nicholson contribute the most to the tests, code tests, UI tests, etc…

Funders give money to the project to keep it alive.

One of the best money income for firefox is using the search engines such as Google. Google funds firefox by paying it to make Google search engine as the default search engine for firefox.

define the system’s functionality and use it once it has been deployed.

Users use the browser to surf the internet, they expect it to be fast, and wait for new updates for bug fixes or new features to fully enjoy surfing the internet.

Reference

## UML - Sequence diagram

The following sequence diagram shows the important part of any webBrowser’s functionality and the processes it should execute to achieve its goal. It also shows how the MVC works in firefox:

Reference

Missing important feature

According to bugzilla, Firefox is missing an important feature which is filed at https://bugzilla.mozilla.org/show_bug.cgi?id=1228089. The feature is: “Detect if the user has a URL in their clipboard when re-entering the app”, The browser currently checks if there is a copied URL only when the app opens for the first time and not when the app goes to the background which means that the user must copy the URL -> and enter the browser again.

It is recommended for the new contributors to add that feature.

Following the Swift style which was recommended by firefox. We added the new feature, and created a pull request and attached it on their bugzilla site according to the guidelines

Metrics, Variability and Quality Measures

Firefox uses circleci for continuous integration. CircleCI’s continuous integration and delivery platform helps software teams rapidly release code with confidence by automating the build, test, and deploy process. CircleCI offers a modern software development platform that lets teams ramp quickly, scale easily, and build confidently every day. Over 100,000 companies use circleci, such as: Facebook, Kickstarter, Spotify, GoPro, etc…

CircleCI can be easily installed, runs tests and automatically have each successful build on the master be pushed to any deployment host.

For the PR we made it took CircleCI about 10 minutes to run all the tests by mainly running the following command which executes all the tests in the project:

**“set -o pipefail && xcodebuild CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= PROVISIONING_PROFILE= ONLY_ACTIVE_ARCH=NO VALID_ARCHS=”i386 x86_64” -destination ‘platform=iOS Simulator,name=iPhone 4s,OS=9.3’ -sdk iphonesimulator -project ‘Client.xcodeproj’ -scheme “FennecCI” clean build test tee $CIRCLE_ARTIFACTS/xcode_raw.log”**

It ran 263 tests in XCode with 0 failures. When the tests finished, it showed a green arrow on the PR to verify that our build passed all tests:

Codebeat gives instant feedback on the code. It is an automated code review for Swift, Ruby, Go, etc…

Codebeat gathers the results of the code analysis into a single, real-time report that gives all project stakeholders the information required to improve their code’s quality.

Firefox has a 3.02 GPA, B grade according to Codebeat codebeat badge

Codebeat report comes with a number that can range from 0 (worst) to 4 (best). Codebeat explains how it calculates the GPAs.

According to firefox-ios’s codebeat https://codebeat.co/projects/github-com-mozilla-firefox-ios , they have many problems in a class called “BrowserViewController.swift”:

And there is a code duplication in “Client/Frontend/Browser/BrowserTrayAnimators.swift:205…217” and “Client/Frontend/Browser/BrowserTrayAnimators.swift:219…231” .

Total complexity represents aggregate Assignment Branch Condition size of the entire namespace. High total complexity indicates a namespace that contains too much logic and should probably be broken down into smaller elements.

This represents the total length (code-wise) of a namespace. It is probably the most naive metric among the ones that we report on but can nevertheless provide substantial value. Ideally a single logical unit of code (class, module, etc.) should fit on one screen, without the need for scrolling. Longer namespaces are harder to navigate and understand, making your code less maintainable.

Number of functions is another high-level complexity metric. It is designed to encourage smart composition and modularity instead of refactoring code by multiplying private methods. We believe that a namespace with more than 15 (private and public) functions is a good candidate for breaking up into multiple independent modules each with its own set of data.

Number of instance variables is a metric designed to detect classes that carry too much state. Since every instance variable has an impact on the overall of status of the object the more instance variables you have the more possible states your object can have and this number grows exponentially as you keep adding instance variables.

The Following image shows the errors and how they are presented in the “BrowserViewController.swift” class:

Security

Firefox 4:

Firefox presented a Sync 1.0 functionality which creates a unique secret key that is used to encrypt and decrypt all your data. And the only way to get the data was to know that key.

Problems with Sync 1.0

If you loose your only device, you probably also lost the only copy of your secret key, and without that key, there is no way to recover your Sync data.

Firefox 29:

features a brand new Firefox Sync experience that is much easier to use while maintaining the high standard of safety, security, and openness that a user expects from Mozilla.

The security goals remain the same: there is still a strong random secret key, and Mozilla’s servers cannot decrypt your data. However, instead of using pairing, a “wrapped” version of your secret key is protected by your password and is stored alongside your Firefox Account. This means that you can recover all your data, even if you lose all your devices at the same time. Setting up a new device only requires typing your Firefox Account email and password into it.

Conclusion

Firefox is one of the many popular browsers for both iOS and any other platform. It has many challenges to overcome to make sure users use the Firefox browser and not its competitors.

They work using the agile method to make sure all bugs and small missing features are added/fixed in a short amount of time. They keep their code organised so people can contribute with ease.

Although Google has their own browser, they pay Firefox to keep Google as their default search engine.

We have sent them a PR and added a missing feature as stated above in the ”Missing important feature” section. Recently their reviewer replied and said :

“LGTM. Thanks :rawisa

Sorry it took me so long to get around to it. It got lost in my review queue.”

LGTM is short for: Looks good to me. This means that they will merge my PR soon ;)

A summary presentation can be found HERE