> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# TileFalling: 60 fps but not smooth (2026-11)

Symptom: the falling tiles report 60 fps yet look uneven, as if the transform reaches the sprite engine a frame late.

## Measured off-device (bun / JSC — only the _ratios_ mean anything)

| Suspect                                                                                                                                              | Result                                                                                                                                               |
| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Lane tick breathing (audio discipline, ±10 % max, τ = 100 ms), simulated with the real `tick-driver` / `gameplay-clock` functions, 800 px/s, busy JS | step vs constant speed: p95 ≤ 0.18 px, max 0.33 px at 60 Hz; rate within ±2.4 %. **Not the cause.**                                                  |
| `writeTileQuads` remap on a revision change (pool 64–256, 24–120 live)                                                                               | 2–3 µs (JSC); even at 30× (Hermes) ≈ 0.1 ms. **Not the cause.**                                                                                      |
| Pool-style per-frame rewrite (`useSpriteSystem` equivalent)                                                                                          | 1–3.7 µs _every_ frame, versus \~0.05 µs for the scroll-uniform path used today: moving to `useSpriteSystem` is a code-shape choice, not a speed-up. |

## Measured on a device (dev build, 60 Hz, two 44 s songs, 150 px/s lane)

A temporary UI-runtime probe (removed again) recorded per 2 s window, from the second after the countdown on:

| What                                          | Result                                                                                                                                                                                      |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| UI frame cadence                              | 120 frames / 2 s, longest 16.67 ms; no frame over 1.5 × the shortest                                                                                                                        |
| Tick mapper vs the TileFalling frame callback | same frame every time (0 double runs, 0 frames without a mapper), \~0.1 ms after the callback                                                                                               |
| Surface image reaching its consumer mapper    | same frame in every window (`imgLate = 0`) — the `useSurfaceMapper` ordering fix works                                                                                                      |
| Lane speed as seen per frame                  | 150 px/s, sd ≈ 1 px/s (0.6 %, \< 0.05 px per frame)                                                                                                                                         |
| `surface.render()` / whole present            | mean 0.2 ms, max 1.4 ms                                                                                                                                                                     |
| GPU: submit → `onSubmittedWorkDone`           | mean 16.5 ms, max ≈ 18 ms in every steady window. This is quantised to the next queue pump (one frame), so it only says the pass is done within a frame — never two; it is not the GPU time |

Only hitches seen: a few UI frames of 27–70 ms in the first \~5 s of a song (prewarm, countdown end, first notes), and a rare one later (33 ms, 95 ms with a 55 ms JS stall). Tile present cost never exceeded 1.4 ms, so those hitches are not the tile path.

**Conclusion:** everything up to the GPU completing the tile pass is smooth and in step with the rest of the frame. A remaining lag cannot come from the tick, the mapper order, the writer or the tile render. What is left is outside what the UI runtime can see: the Skia record → display-link present tail (the same one frame for every Skia-drawn thing), and the display.

## If it comes back

- Screen-record the device at 60 fps and diff the tile Y per frame: the only way to see what is actually presented.
- Try a release / profile build before anything else; the numbers above are a dev build.
- Xcode _Metal System Trace_ for the present tail, as in [game-mode-thermal-2026-10.md](/docs/investigations/game-mode-thermal-2026-10.md#measuring).
- The start-of-song hitches (first \~5 s) are a separate, measurable item: hitch trace (`EXPO_PUBLIC_HITCH_TRACE=1`, Lab → Hitch traces) already marks the countdown and prewarm windows around them.

## Update — tiles moved onto `useSpriteSystem` (2026-11-03)

The measurements above are for the surface + mapper design. The lane is now two sprite systems on the shared FX frame (see [piano.md](/docs/features/piano.md), _Frame order_): every awake tile is rewritten each frame, with no scroll uniform and no mapper (since 2026-11-03 evening: from its own position + velocity, not from the tick). Two things to re-measure on a device:

- **Tick freshness.** Superseded: tiles no longer place themselves from `tickSv` each frame. Each bound slot carries `headY` / `tailY` and velocity and advances by `v · dt` of the FX frame itself; the engine publishes the lane `rate` and an `epoch` (see piano.md, _Frame order_), and the tick is only used to anchor (bind, tap, epoch change) and to slide the cursor, with one frame of `rate · dt` added when the read is stale. If a lag remains, log `fresh`, `rate` and the anchor error `headY − closedForm(tick)` on a device before suspecting anything else.
- **Per-frame rewrite cost.** The off-device number above (1–3.7 µs per frame for the whole pool) predicted this to be a code-shape choice rather than a cost; confirm with a dev-build probe.

***

<small>Source: [`docs/investigations/tile-falling-lag-2026-11.md`](https://github.com/leapgame/leap-sim-piano/blob/f794b594016038c483e2d20b6af56aea0ae1b982/docs/investigations/tile-falling-lag-2026-11.md)</small>
