v1.0.12 · Release snapshot

Documentation comes from this release commit, without inheriting newer content. Commit: 35589c6fda.

TileFalling — data-driven performance flow

How the engine's game state and the falling-tile lane exchange data, and why it is cheap: JS only publishes what happened; the UI runtime reads plain numbers and derives everything else.

Sources: packages/rhythm-engine/src/driver/game-state.ts, src/components/TileFalling.tsx, src/components/tile-pool.worklet.ts, src/components/tile-note-status.ts, src/components/tile-chart-soa.ts.

1. Threads and data ownership

2. One frame on the UI runtime

3. Status ring — the only JS to UI channel per note

4. Slot lifecycle

5. Performance cost map (what is data, what is work)

StageInput dataPer-frame costAllocation
GameState write8 numbers8 storesnone (positional args)
GameState readFloat64Array[8]8 loads into reused viewnone
Status ring idlehead cell1 lock-free readnone
Status ring activenew entries onlyO(new entries)none
advanceTilespool columns, laneV, dtO(active slots)none
Cursor advanceTileChartSoA + pool.tickamortised O(1)none
bindWindowonly when cursor moved (bindDirty)O(entered tiles)none
anchorAllSlotsonly on epoch bump / parked tick moveO(slots), rarenone
wakeVisibleSlotsbodyAwake flagsO(capacity) scan, early continuenone
Sprite writesawake slots onlyO(visible)none

Data-driven rules

  • stamp says which frame wrote the block, isRunning says whether to advance: no freshness guess.
  • Tiles integrate velocity x dt and only re-anchor when epoch changes (seek, rewind, tempo jump).
  • A stalled JS thread cannot delay a tile: the pool lives on the UI runtime and never reports back.
  • Per-chart cost (buildTileChartSoA, layout) is paid once in useEffect, not per frame.

6. Metrics worth sampling

7. Cost per runtime — JS / Worklet (UI) / Worker / Native render

Qualitative budget from code reading, not measured. Fill the "measure" column from the sim (react-devtools-sim-profiling, FX frame timer) before quoting numbers.

RuntimeWorkFrequencyScales withRisk if it growsMeasure
JSjudgement + status queue + pumpper tap / per JS turntaps per secondblocks input, never delays tile motionJS frame time during dense chord charts
JSlayout + SoA buildper chartnote countstart-up hitchms in useEffect on song load
UI workletGameState write/readevery frameconstant (8 fields)negligiblenone needed
UI workletreconcileTilesevery frameactive slots, ring entriesframe over budget drops lane FPSms per frame, awake slots
UI workletbindWindow / anchorAllSlotson cursor move / epoch bumpwindow size, capacityspike on seek or tempo jumpcalls per second, spike ms
UI workletsprite systemsevery frameawake slotsdominates frame cost on dense chartssprites written per frame
Workeratlas packonce per sheetsprite countnone for gameplay if off-threadms off-thread, fallback to JS if no runtime
NativeGPU upload + drawevery framedirty slots, sprite countGPU-bound framesFX frame ms (about 3 ms in the sim)
Nativeaudio noteOnper tappolyphonylatencytap to sound latency

Where the work moved in the new logic

  • Per note, JS now only writes one status entry. Slot binding, position and fade moved to the UI runtime.
  • A stalled JS thread cannot delay a tile, because the pool is on the UI runtime and reads shared cells.
  • The only heavy off-thread job is atlas packing, and it runs once per sheet, not per frame.
  • Per-frame cost is therefore dominated by one place: the UI runtime (reconcileTiles plus sprite writes).