T-049: Phone performance of the web viewer
Problem
Evan opened alife-kz9.pages.dev on 2026-12-02. His laptop shows 60 frames per second. His phone shows 1. The page was drawing 5,000 placeholder spheres. He often looks at the project on his phone, so the phone is a real target, not an extra.
All earlier measurements came from headless Chrome on this Mac's GPU, including the "phone size" one. Nobody here has a phone to test on, so this ticket must also make it possible to measure on Evan's phone from a link.
Scope
- Find the cause. One frame per second is far worse than a slower GPU explains. Suspects: full 3x resolution (1170 by 2532 pixels), anti-aliasing, shadows, one draw call per sphere, per-entity CPU work in single-threaded wasm, sphere meshes with too many triangles, or the browser falling back to software rendering. Check what the viewer really does for each.
- A phone stand-in on this machine. Add CPU throttling to
scripts/webfps.mjs(Chrome'sEmulation.setCPUThrottlingRate) and use it with--dpr 3 --mobile, so regressions can be caught here. Say clearly how far to trust it. - Diagnostics on the page, shown with
?diag=1or by tapping the fps readout: browser, graphics backend, GPU adapter, device pixel ratio, canvas size in pixels, entity and draw counts, and how frame time splits between CPU and GPU where that can be measured. One button copies the whole report as text, so Evan can paste it to the orchestrator. - A self-running benchmark at
?bench=1: step through sphere counts, resolution scales, anti-aliasing on and off, shadows on and off, lit and unlit, a few seconds each, then show a table and a copy button. One link on Evan's phone should produce all the data. - Fix it. Likely: draw at lower resolution on high-density screens, turn off expensive features on phones, draw spheres with instancing or as camera-facing impostors, and adjust quality automatically to hold 30 frames per second.
Done when
- ☐ A written cause, with evidence, in
docs/VIEWER.md. - ☐ The throttled local stand-in shows the improvement in numbers, before and after.
- ☐ Diagnostics and benchmark are live on a preview deployment. Give the exact links.
- ☐
INBOX.mdtext for Evan in your report: which link to open and what to send back. Say plainly that only his phone can confirm the fix.
Notes
- Deploy previews only, with `wrangler pages deploy dist --project-name alife --branch
phone-perf
. Do not deploy to production and do not editscripts/deploy-web.sh`: another agent owns that file right now. The orchestrator deploys production after merging. - Whatever makes spheres cheap here should carry over to the real renderer (T-015), which must draw thousands of organisms on phones too. Write down what you learn for it.