Paint Less: Culling, Adaptive Quality and Raster Tiles
A wide world holds thousands of SVG nodes and the child sees one screen of them. Day 4 makes the browser stop walking, painting and allocating for what nobody can see, without changing a single visible pixel.
The loop that ranked its own work
Days 2 and 3 fixed what the first traces pointed at. Day 4 starts a different rhythm, used for the rest of the course: a time-boxed loop where every item starts from a trace or profile of the current build at 6× CPU, is ranked by measured cost, is fixed one at a time, and is measured again before the next. Nothing is fixed because it looks slow.
Adaptive quality, level 3
Day 3's governor had two levels. Profiling a sustained low-end drag showed most per-frame invalidations came from idle objects breathing (a slow, gentle scale). Level 3 redraws idle objects, those not held, hovered, reacting, moving or talking, every fourth frame, staggered across the cast so a quarter of them update each frame. Busy objects still redraw every frame. A test proves both halves: the held object redraws at least 15 of 16 frames, an idle one at most 5.
Don't build strings for parts at rest
A CPU profile put garbage collection at 2.5 % of a low-end drag frame, mostly from transform strings rebuilt for every part of every object, every frame, including parts that had not moved. The fix compares a part's numeric inputs, rounded to the same 0.01 the writer uses, in a reused buffer, before building any string. A resting part now allocates nothing.
Scenery as images: raster tiles
A newer version of the worlds brought much richer scenery: a market world's svg held about 29 000 scenery nodes, roughly 1 500 near the view at any time, and a trace with scenery hidden cut an idle low-end frame's paint by about 75 %.
The fix turns each 1 024-unit tile of scenery into one SVG image, an <image> whose source is a blob of that tile's vectors. The browser decodes it once and draws it as a single cached image. Vector nodes stay underneath until their tile has loaded, so nothing ever appears late or blank.

Parity was checked in the browser, three worlds by three scroll positions: at most 0.003 % of pixels differed by more than 8/255, and those were door badges that pulse.
Before and after side by side
Low-end, 6× CPU, the market world, loop start vs loop end.

| low-end, same run, median of 2 | loop start | loop end |
|---|---|---|
| market idle, dropped | 98.7 % | 54.5 % |
| market drag-hold, dropped · input p95 | 82.6 % · 99 ms | 45.0 % · 71 ms |
| playground idle, dropped | 89.3 % | 24.8 % |
| playground drag-hold | 95.8 % · 119 ms | 43.3 % · 82 ms |
| playground tap-spam | 99.6 % · 178 ms | 76.2 % · 139 ms |
| mid-range market drag-slow | 28.3 % · 106 ms | 9.3 % · 71 ms |
One cell got worse in that run: low-end market tap-spam went from 48.9 % to 66.0 % dropped, while its input latency improved. Two interleaved reruns measured no difference (93/87 % vs 92/90 %), so the ledger records it as unresolved, not a win. Writing that down honestly is part of the method.
Design principles at work
- Keep the contract, change the implementation. Hosts and tests rely on each object having a laid-out root with a label and a tap pad. Culling, tiles and strides all work behind that contract, which is why none of them needed a change outside the view.
- Open/closed through levels. The governor's levels are additive policies; level 3 added a stride rule without touching levels 1 and 2.
- Measure the alternative before choosing.
visibility:hiddenvsdisplay:nonewas decided by a trace, and the rejected root-culling variant is in the ledger with the reason.
Key takeaways
visibility:hiddenstill costs paint traversal;display:noneremoves the subtree. Cull the drawing, keep the parts others depend on.- Idle animation is often the bulk of the per-frame work on slow devices: stride it, don't remove it.
- Compare numbers before allocating strings; the cheapest allocation is the one you skip.
- Turning thousands of static vectors into a few images is a large, invisible win, if you prove pixel parity.