Mozilla has launched a new project called Electrolysis that aims to bring multiprocess browsing to Firefox. According to Mozilla, splitting up the page rendering workload into multiple processes will improve the browser's performance, security, and stability. The developers have already assembled a prototype that renders a page in a separate process from the interface shell in which it is displayed.

Mozilla has explored the possibility of adopting a multiprocessing approach for Firefox in the past, but the idea didn't gain serious traction in the Firefox developer community until it was implemented by Google and Microsoft in their respective web browsers. Google's Chrome browser uses a separate process for each page, an architectural approach that facilitates much more effective security sandboxing and prevents page-specific rendering glitches from crashing the entire browser. Chrome even includes a process manager tool that can be used to see the status and resource consumption of each page.

Adapting Firefox to make it support multiprocess browsing will not be an easy task. Many fundamental components of the browser's underlying infrastructure will have to be modified in order to accommodate the transition. This will partly involve using interprocess communication (IPC) to expose shared pieces of the browser to the individual tab processes. This is somewhat complicated, but you can get a clearer picture of how it will work by looking at some of Mozilla's design documents. A particularly illuminating example is the overview of how Firefox's image loading and caching mechanisms will be made to work with multiprocess browsing.

The browser currently has a single image loading component that is shared between tabs. To make it work for multiprocess browsing, one approach would be to simply instantiate a separate image loader in each tab process. In order to avoid redundancy, Mozilla's documentation explains, an alternate solution that might potentially be more effective would be to have a central image caching and loading service that makes image content accessible to the tab processes via IPC. It could be further optimized by using shared memory to to make the decoded image data accessible to the tabs, thus avoiding the IPC bottleneck for the heaviest aspect of the operation.

Last month, developer Chris Jones published a screencast which demonstrates a simple prototype that renders page content in a separate process outside of the main browser process. He shows that the page rendering process can be terminated independently of the browser, meaning that a page-specific crash would take down only the page and not the entire browser.

"Notice that only the 'content' disappears when the page crashes; the user interface itself keeps running as if nothing happened. This is a big step forward," he wrote in a blog entry about the demo. "With Firefox protected from buggy pages and plugins, more fun is possible. This video shows me pressing a 'Recover' button that relaunches the page that just crashed. There are many more possibilities for recovering from these errors, and I'm excited to see what our user interface folks cook up."

Jones says that his prototype represents the work that the Electrolysis developers have done to meet the requirements specified by "phase I" of Mozilla's multiprocess roadmap. To bootstrap the development of the IPC system, Mozilla is using some code from Chromium, the open source development version of Google's browser. The developers are contemplating the possibility of replacing existing Firefox components, such as the browser's network stack, with additional code from Chromium.

The experimental development work that is being done by various contributors on the Electrolysis project was recently consolidated into a single version control repository. The developers hope to have nightly builds ready for developer testing soon, but they caution that it will not yet work on Mac OS X. They are looking for volunteer Mac developers to participate in the project.

Electrolysis is going to be a truly enormous project. It's not clear yet if it will be ready in time for the next release of Firefox, which is codenamed Namaroka. The work on Electrolysis will be done parallel to Namaroka development, so it will not impede other plans to improve the browser. The early Electrolysis prototype and other parts that have been implemented so far are highly impressive. The project is off to a very promising start and has the potential to bring a lot of value to the Firefox browser and its users.

Further reading