ESSAY // THE READING ROOM

Zero frames when idle

written 2026-11-02 · about 2 min read · 6 paragraphs

A WebGL portfolio page is usually a machine that never stops painting. This one has to stop, and there is a gate that proves it did.

The page runs one WebGL canvas for its whole body. Not one per section, not a stack of hero canvases: a single renderer that the scroll position steers. That choice is cheap to describe and expensive to keep, because the moment the scene is animated by a loop that runs on its own, the page becomes a machine that paints forever — including while you are reading a paragraph, including with the tab in the background, including on a laptop that has other work to do.

So the canvas has a deadline. Four seconds after the last scroll it switches its frameloop to demand mode (IDLE_MS in src/components/Three/GlobalEditorialCanvas.tsx). In demand mode nothing is painted until something invalidates the scene, and while the page is standing still nothing is supposed to.

Measuring that honestly turned out to be the harder half. The first attempt was a requestAnimationFrame loop of our own counting frames, which is a self-fulfilling instrument: the loop wakes the page every frame and destroys the very behaviour being tested. The meter that replaced it is a priority-1 subscriber inside the canvas, so React Three Fiber hands over the automatic render and the counter reads gl.info immediately after the frame it belongs to. It only exists when NODE_ENV is not production, and it writes to a window object the verifier reads.

The verifier then does something deliberately unfriendly. It scrolls to a chapter, samples that window fifteen times over 1.5 seconds to catch the busiest frame, waits 5.5 seconds so the idle deadline has passed, blanks the object to null, and waits 1.5 seconds more. If the object is still null, no frame was written after the page went quiet. That is the gate: not a lower bound on draw calls, but a proof of silence.

The cost is architectural rather than numeric. Once the loop is allowed to stop, every animation on screen has to be a function of scroll progress plus a parked state — a card that lands in its box has to park its final pose in state, because there is no live loop left to remember it. That constraint is what makes the transitions verifiable at all: a stopped page can be compared against a recorded pose.

The last recorded snapshot sits in docs/verify/anggaran.json: five draw calls at peak, 18,460 triangles, five live geometries, two textures, and zero frames while idle in every chapter. It also records the renderer as SwiftShader, which is the honest caveat — those numbers compare runs on the same machine, they are not a promise about a sixty hertz display.

WHAT THIS TEXT POINTS AT

Paths are relative to the repository root; a bare hash is a commit in its history. Every claim above can be opened and contradicted.

  • nextjs-frontend/src/components/Three/GlobalEditorialCanvas.tsx
  • nextjs-frontend/src/components/Three/stage/PengukurRender.tsx
  • docs/verify/drawcall-probe.mjs
  • docs/verify/anggaran.json