8. Browser Architecture
“A modern browser is an operating system that happens to have an address bar.”
The story: the apartment building
Section titled “The story: the apartment building”Imagine a large apartment building. The building manager lives on the ground floor: holds the master keys, talks to the outside world, receives deliveries, decides who gets which flat. Each tenant lives in their own flat with a locked door. They can’t walk into each other’s flats, and they can’t touch the building’s wiring; if they want something from outside, they ask the manager. There’s a workshop in the basement with heavy machinery — only the trained technician operates it, and tenants send work orders. There’s a post room that handles all mail.
If one tenant floods their flat, the others are fine. If a tenant turns out to be a burglar, they’re stuck behind their own door.
That’s Chrome (and, with different floor plans, Firefox and Safari). The manager is the browser process. The flats are renderer processes — one per site, roughly. The workshop is the GPU process. The post room is the network service. The locked doors are the sandbox.
It wasn’t always like this. In the early 2000s, a browser was one process: one bad tab, one buggy plugin, and the whole browser crashed, taking your fifteen other tabs and your half-written email with it.
What it is: a browser is a set of cooperating processes
Section titled “What it is: a browser is a set of cooperating processes”A process is a running program with its own private memory, isolated from other processes by the operating system. A thread is a line of execution inside a process; threads in the same process share memory.
When Chrome launched in 2008, its big architectural bet was multi-process: split the browser into several processes that talk via inter-process communication (IPC). In current Chromium the main kinds are:
- Browser process — the UI (tabs, address bar), navigation decisions, permissions, file access, coordinating everything else. Privileged.
- Renderer processes — where the web page lives: HTML parsing, CSS, layout, painting, and JavaScript (V8). One per site (more below). Sandboxed: no direct access to files, network, or the screen. Everything goes through IPC to more privileged processes.
- GPU process — talks to the graphics card on behalf of all renderers and the browser UI. Isolated because GPU drivers are notoriously crashy; if it dies, Chrome restarts it and repaints.
- Network service — all HTTP, DNS, caching, cookies (in its own process on most platforms).
- Storage service, audio service, utility processes — for decoding, audio, file parsing and other risky or crashy work.
- Extension processes and plugin processes historically.
Why it exists: crashes, then security, then Spectre
Section titled “Why it exists: crashes, then security, then Spectre”Stability was the first reason. One renderer crashing (“Aw, Snap!”) takes down one tab, not the browser.
Security was the second. Browsers parse enormously complex, attacker-controlled input — HTML, CSS, JavaScript, images, fonts, video — with hundreds of thousands of lines of C++. Bugs are inevitable. The sandbox means that even if an attacker finds a bug that lets them run code inside a renderer, they’re stuck in a flat with no keys. They need a second bug, a sandbox escape, to reach your files. That’s “defence in depth.”
Spectre was the third, and it reshaped the architecture. In January 2018, researchers disclosed Spectre and Meltdown: CPU-level vulnerabilities in speculative execution, the trick modern processors use to run ahead and guess which way branches will go. Through careful timing measurements, code could infer data that it was never architecturally allowed to read — anything in the same process’s address space. Suddenly, the browser’s logical security boundaries inside a process (the same-origin policy, Chapter 13) weren’t enough. If your bank’s iframe and an attacker’s page lived in the same renderer process, JavaScript on the attacker’s page could, in principle, read your bank’s data out of memory.
The answer was Site Isolation: guarantee that pages from different sites never share a renderer process, including cross-site iframes (“out-of-process iframes”). Chrome rolled it out on desktop in 2018 (Chrome 67), later on Android for sites where you log in. Browsers also reduced timer precision and disabled SharedArrayBuffer (which can be used to build precise timers) unless a page opts into cross-origin isolation (Chapter 11).
What if it didn’t exist?
Section titled “What if it didn’t exist?”Without process isolation: one tab’s infinite loop or memory explosion freezes everything; a single exploited parsing bug owns your machine; and, post-Spectre, any page could potentially read any other page’s data that happened to share its process — your logged-in email inside an ad’s iframe’s process. The cost of isolation is real (more processes = more memory; Chrome on a low-RAM Android phone consolidates processes to cope), but the alternative is unacceptable.
Threads inside a renderer
Section titled “Threads inside a renderer”Zoom into one renderer process. Several threads matter to you:
- Main thread. Runs JavaScript, and parses HTML, and computes styles, and does layout, and records paint. Everything about the DOM happens here. There is only one. This is the single cook from the Prologue, and Chapter 10 and 11 are mostly about its schedule.
- Compositor thread. Receives the painted layers, handles scrolling and certain animations (transform, opacity), decides what’s visible, and produces frames. Crucially, it can keep working while the main thread is busy — that’s why some animations stay smooth and others stutter.
- Raster threads (a pool). Turn recorded paint operations into actual pixels, tile by tile, often by issuing GPU commands.
- Worker threads. Each Web Worker gets its own thread with its own JS environment, no DOM access, talking to the main thread by messages.
- Other helpers: the HTML preload scanner, image decoders, the V8 garbage collector’s background threads, and the streaming compilation of scripts.
The engines
Section titled “The engines”A browser’s engine is the code that parses, styles, lays out and paints web content (the rendering engine) plus the JavaScript engine. There are three that matter today:
| Engine | JS engine | Browsers |
|---|---|---|
| Blink (forked from WebKit in 2013) | V8 | Chrome, Edge, Opera, Brave, Vivaldi, Samsung Internet, and most Android WebViews |
| WebKit | JavaScriptCore | Safari on macOS and iOS — and, historically, every browser on iOS |
| Gecko | SpiderMonkey | Firefox (desktop and Android) |
That iOS row is the one that surprises people. For most of the iPhone’s history, Apple’s App Store rules required every browser on iOS to use the system’s WebKit. “Chrome on iPhone” was Chrome’s UI wrapped around Safari’s engine — same rendering bugs, same feature gaps, same performance characteristics as Safari. The EU’s Digital Markets Act forced Apple, from iOS 17.4 in 2024, to allow alternative engines for users in the EU, and other jurisdictions have pushed in a similar direction. In practice, adoption of non-WebKit engines on iOS has been slow, because shipping a full engine on iOS involves significant technical and policy hurdles, and is region-limited. As a working assumption for your users in India: if it’s on an iPhone, it’s WebKit.
Why “works in Chrome” is not testing
Section titled “Why “works in Chrome” is not testing”- Feature support differs by engine and version. A CSS feature shipped in Chrome may be a year away in Safari, or behave subtly differently.
- Performance characteristics differ. JavaScriptCore and V8 optimize differently; Safari’s compositing and memory limits differ (iOS will kill a tab that uses too much memory, with no warning to your code); Firefox’s style engine is parallel.
- Default behaviours differ: form controls, scroll behaviour, font rendering, autoplay policies, storage eviction (Chapter 12).
- Your users’ versions differ. Android WebView versions can lag; old iPhones can’t upgrade past a certain iOS version, which pins their Safari version.
The minimal serious matrix for an Indian audience: a mid-range Android phone with Chrome, an iPhone with Safari, a desktop Chrome, a desktop Firefox or Safari. Chapter 17 builds this into a test plan.
When it goes wrong
Section titled “When it goes wrong”Spectre (2018) is the canonical incident: not an outage, but a discovery that invalidated assumptions about isolation and forced every browser vendor into years of architecture work (site isolation, cross-origin isolation, timer coarsening). Lesson: logical boundaries inside one process are not security boundaries against the hardware.
The memory-killed tab. A common iOS story: a WebGL-heavy page works perfectly on desktop and on Android, but on iPhones it reloads itself mid-session (“A problem repeatedly occurred”). iOS terminates web content processes that exceed memory limits, much more aggressively than desktop. The team’s desktop-only testing never saw it. Lesson: process memory is a budget, the budget depends on the device and OS, and the browser will enforce it brutally (Chapters 17 and 20).
What you now know
Section titled “What you now know”You can describe the browser’s process model and why each process exists, explain how Spectre turned site isolation from nice-to-have into mandatory, name the threads in a renderer and what each is allowed to do, distinguish site from origin, map browsers to engines (including the iOS twist), and argue for a cross-engine test matrix.
Self-quiz
Section titled “Self-quiz”1. Why are renderers sandboxed?
They run attacker-controlled content through huge, complex code; a compromise should be contained without direct file/network/screen access.
2. What did Spectre change?
Same-process data could leak via speculative execution side channels, so different sites must be in different processes (Site Isolation).
3. Which thread computes layout?
The main thread.
4. Is app.example.com the same site as blog.example.com?
Same site (same registrable domain), different origins.
5. What engine does Chrome on an iPhone use in most of the world?
WebKit.
Exercises
Section titled “Exercises”Warm-up 1. Count processes. Open Chrome’s Task Manager with three tabs: two on the same site, one with a YouTube embed. Predict the renderer count, then check.
Solution
Typically: one renderer for the shared site (may be shared or separate depending on settings), one for the other tab, one for the cross-site YouTube iframe. Plus GPU, network, and utility processes.
Warm-up 2. Which survives? A tab’s JS enters an infinite loop. Can you still scroll the page? Switch tabs? Click a button on the page?
Solution
Switch tabs: yes (browser process). Scroll: often yes for simple scrolling handled by the compositor, unless scroll-linked JS listeners block it. Click a button: no — handlers need the main thread.
Warm-up 3. Site or origin? Classify pairs: https://a.com vs http://a.com; https://a.com vs https://www.a.com; https://a.github.io vs https://b.github.io.
Solution
Different scheme: different site and origin. a.com vs www.a.com: same site, different origin. github.io subdomains: different sites, because github.io is on the Public Suffix List.
Lab 4. Lumen’s engine matrix. Open Lumen in Chrome, Firefox and Safari (or WebKit via a test runner). List every visual or behavioural difference.
Hint
Check form controls, fonts, scrollbars, backdrop-filter, date inputs, and any recently shipped CSS.
Lab 5. Freeze the main thread. Add a button to Lumen that runs a 3-second busy loop. Click it while a CSS transform animation and a CSS left animation are running. Observe.
Expected outcome
The transform animation continues (compositor); the left animation freezes (main thread). Chapter 10 explains why in depth.
Lab 6. Watch memory per process. Open Lumen and a heavy site in Chrome’s Task Manager, add the “Memory footprint” column, and compare.
What to notice
Per-site processes carry their own baseline memory. On a 3–4 GB phone, every iframe from a different site costs real memory.
Staff 7. Iframe budget. A product team wants to embed eight third-party widgets (each a cross-site iframe) on the homepage. Explain the cost in process and memory terms and propose an alternative.
Model answer
Each cross-site iframe can mean a separate renderer process with its own V8 heap and Blink instance: memory, CPU, and contention on low-end devices. Alternatives: load on interaction (facades), lazy-load below the fold, consolidate, or use lighter integrations.
Staff 8. The iOS question. A stakeholder says “most of our iPhone users use Chrome, so we only need to test Chrome.” Write the reply.
Model answer
On iOS, Chrome renders with WebKit; behaviour and bugs match Safari. Testing desktop Chrome covers none of that. Test on a real iPhone with Safari.