views:

527

answers:

5

We have been told that Google Chrome runs each tab in a separate process. Therefore a crash in one tab would not cause problems in the other tabs.

AFAIK, multi-processes are mostly used in programs without a GUI. I have never read any technique that could embed multiple GUI processes into a single one.

How does Chrome do that?

I am asking this question because I am designing CCTV software which will use video decoding SDKs from multiple camera manufactures, some of which are far from stable. So I prefer to run these SDKs in different processes, which I thought is similar to Chrome.

+18  A: 

Basically, they use another process that glues them all together into the GUI.

Google Chrome creates three different types of processes: browser, renderers, and plug-ins.

Browser: There's only one browser process, which manages the tabs, windows, and "chrome" of the browser. This process also handles all interactions with the disk, network, user input, and display, but it makes no attempt to parse or render any content from the web.

Renderers: The browser process creates many renderer processes, each responsible for rendering web pages. The renderer processes contain all the complex logic for handling HTML, JavaScript, CSS, images, and so on. Chrome achieves this using the open source WebKit rendering engine, which is also used by Apple's Safari web browser. Each renderer process is run in a sandbox, which means it has almost no direct access to the disk, network, or display. All interactions with web apps, including user input events and screen painting, must go through the browser process. This lets the browser process monitor the renderers for suspicious activity, killing them if it suspects an exploit has occurred.

Plug-ins: The browser process also creates one process for each type of plug-in that is in use, such as Flash, Quicktime, or Adobe Reader. These processes just contain the plug-ins themselves, along with some glue code to let them interact with the browser and renderers.

Source: Chromium Blog: Multi-process Architecture

Daniel Vassallo
I don't get it. It looks like these tabs belongs to the Browser process, how could these renders draw pictures and text on a tab belongs to another process?
ablmf
They don't belong to the Browser process. The Browser process simply manages them (it creates them, stops them, and monitors them). The Browser process also creates the browser GUI, but the internal logic of the tabs (the risky part that is vulnerable to crashes), is handled by the separate Renderer processes (one for each tab).
Daniel Vassallo
Great summary! One thing to add, each Chrome Extension runs in their own process. If you want to know how processes talk to each other, take a look at IPC section in the Chromium source base.
Mohamed Mansour
Hmm. Interesting. I can see how the HTML, CSS, image etc renderers might somehow serialize the drawing information over to the browser process so it can paint it in the right window. But one cannot say the same for graphics output from plug-ins. Wonder if they are simply having the plugins render to an off-screen surface and then blitting it over to the browser window - but then that seems like it'll be way too slow. And video playback wouldn't be too great as well. Maybe we'll need to look at the source!
Ranju V
+2  A: 

Download the source and see ! This would be of great benefit to you if you need a similar solution. Google Chrome is open source.

Conor
A: 

Most of the work of rendering a web page is figuring out where exactly things go (i.e. where to place each picture, what color to render each piece of text). That work is done in a separate process. Once the separate process has figured where everything goes, it passes that information on to the main Chrome process which draws all of the elements on the screen.

It isn't clear exactly how your video sdk system is setup. But you could have one process that decompresses the video and another process that renders it to the display. Most likely however, you are using opengl or DirectX. Those APIs smay impose some limitations on how you split things up among different processes.

speedplane
+6  A: 

Since this is a developer site, it is strange that no one linked to the Design Documents, in particular to the Multi-process Architecture section.

Nickolay
+1 - Good Source
Daniel Vassallo
A: 

Window objects - the small, drawable rectangular areas used to implement widgets, not what the user sees as a window - can perfectly be shared between processes, using shared memory or the X protocol. Check your toolkit's docs.

Tobu