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
  1. The sandbox: minimal privileges, with everything brokered over IPC.
  2. Memory: heaps, DOM, images and GPU memory, against an OS that kills processes when RAM runs out.
  3. Tab discarding: save state when the page becomes hidden.
  4. GPU access goes through the GPU process.
  5. Power: background throttling and thermal limits.
  6. 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 seewhat the machine is doingwhere it is explained
the page stutters while scrollinga long task on the main thread misses the frame budgetBrowser P5-P6, this course P3
a list of 10,000 items is slow, an array of numbers is fastpointer chasing versus sequential accessthis course P2
the app reloads after switching back from another appthe tab was discarded under memory pressurethis course P2 and P6
it gets slower the longer you use it on a phonethermal throttling, or a memory leak forcing GCthis course P6, JS P5
the first visit is slow, later ones fastTCP and TLS handshakes, slow start, cold cachesthis course P5, Browser P1
a "saved" draft vanished after a crashwritten but never made durablethis 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.