Part 6 · 1 chapters · ~12 min
A Browser Tab on Top of All of It
The renderer as the OS sees it: a sandboxed process brokering everything over IPC, a memory budget against a low-memory killer, tab discarding and the page lifecycle, GPU access through the GPU process, background throttling and thermal limits, and one tap traced through every layer.
12
What the OS gives a renderer process
a sandboxed process with a budget
- The sandbox: minimal privileges, with everything brokered over IPC.
- Memory: heaps, DOM, images and GPU memory, against an OS that kills processes when RAM runs out.
- Tab discarding: save state when the page becomes hidden.
- GPU access goes through the GPU process.
- Power: background throttling and thermal limits.
- The whole stack: a tap crosses every layer of the machine.
code
// survive discarding: persist what the user would hate to lose, at the last reliable moment
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
sessionStorage.setItem('transfer-draft', JSON.stringify(draft)); // small, synchronous, enough
navigator.sendBeacon('/rum', JSON.stringify(pendingMetrics)); // the Disciplines course part 5
}
});
// on load: was this tab discarded and restored?
if ((document as any).wasDiscarded) restoreDraft(JSON.parse(sessionStorage.getItem('transfer-draft') ?? 'null'));| what users see | what the machine is doing | where it is explained |
|---|---|---|
| the page stutters while scrolling | a long task on the main thread misses the frame budget | Browser P5-P6, this course P3 |
| a list of 10,000 items is slow, an array of numbers is fast | pointer chasing versus sequential access | this course P2 |
| the app reloads after switching back from another app | the tab was discarded under memory pressure | this course P2 and P6 |
| it gets slower the longer you use it on a phone | thermal throttling, or a memory leak forcing GC | this course P6, JS P5 |
| the first visit is slow, later ones fast | TCP and TLS handshakes, slow start, cold caches | this course P5, Browser P1 |
| a "saved" draft vanished after a crash | written but never made durable | this course P4 |
A BROWSER TAB ON TOP OF IT ALL
one renderer process as the OS sees it: a sandbox, a memory budget, a GPU client, a power consumer, and a candidate for being frozen or killed
swipe the figure sideways, or tap expand for full screen
1/6
the sandbox
The sandbox: the renderer process is created with almost no privileges: no direct file system access, no raw network sockets, restricted system calls (seccomp-bpf on Linux and Android, the Seatbelt sandbox on macOS). Everything goes through the browser process over IPC. A compromised renderer is stuck in a box.