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

# Game Mode heat + refresh rate (2026-10)

> **Reverted 2026-10-26.** The 60 Hz iPhone lock and the update-rate cuts below (marked _Now_) looked
> choppy on real devices — smooth only in the simulator, which follows the Mac's 120 Hz display on a much
> faster GPU and never heats up. `CADisableMinimumFrameDurationOnPhone` is `true` again and every rate is
> back to its _Before_ column. Kept from this pass: the pause-panel freeze, the cadence jitter headroom,
> and the idle-allocation fixes. The Worklets 120 ↔ 60 flipping described below is back too; if it needs fixing, the next
> step was `worklets.staticFeatureFlags.IOS_DYNAMIC_FRAMERATE_ENABLED: false` in `package.json`, not a lock.
> **Tried 2026-11-03 and dropped:** it did not fix the performance problem, so the flag is not set (Worklets default).

**Symptom.** The device gets hot during long Game Mode sessions (120 Hz iPhone, 60 Hz iPad). On the Pro iPhone the
perf HUD swung between \~90 and \~120 FPS instead of holding steady.

**Status: trimmed, not yet measured on device.** Everything below comes from reading the code; the before / after
numbers in Instruments are still to be taken (see _Measuring_).

## How the frame rate is chosen

- The display link runs at the panel rate: 60 Hz on non-Pro iPhones and base / Air / mini iPads; up to 120 Hz on
  ProMotion iPhones (only with `CADisableMinimumFrameDurationOnPhone`) and on iPad Pro (always — iOS ignores the key on
  iPad). A 60 Hz panel never runs at 120. The simulator follows the Mac display.
- Reanimated 4's `useFrameCallback` runs on Worklets' `AnimationFrameQueue` display link
  (`react-native-worklets/apple/worklets/apple/AnimationFrameQueue.mm`). On ProMotion it re-picks its rate on every
  frame from the average UI-thread callback time of the last 4 frames: under 8 ms → `BEST` (60–120, prefers 120),
  under 16 ms → `STANDARD` (30–60). Busy gameplay frames sit around 8 ms, so the rate kept flipping between 120 and 60
  — the unstable 90–100 FPS, with uneven frame pacing the scrolling tiles show as micro-stutter.
- Skia (`SkiaView.mm` `requestFullFrameRate`) and Reanimated (`READisplayLink.h`) also ask for the panel maximum.

**Decision: lock iPhone to 60 Hz app-wide.** `app.config.ts` sets `CADisableMinimumFrameDurationOnPhone: false`
(Expo's prebuild default is `true`), so iOS caps every display link at 60 on iPhone. A steady 60 has even 16.7 ms
frames, half the GPU and CPU work of 120, and gives every frame-counted mount warmup twice the wall time. Menus also
run at 60 on Pro iPhones (accepted). It takes effect after a prebuild / EAS build.

**iPad Pro stays at 120** (DEV decision). Options kept for later: a `+load` `CADisplayLink` clamp module in
`modules/` (the `sdk-crash-guards` pattern — catches Worklets, Reanimated, Skia and React Native links in one file), or
patches to the three libraries; or a Game-Mode-only cap through a native flag.

**A/B protocol.** Same song, same streak, perf HUD + Instruments → _Animation Hitches_, with the key `true` vs `false`.

## Effect update rates

Every effect runs inside ONE `useFrameCallback` (`gameplay-fx-frame.tsx`) that fires every display frame; each layer
throttles itself with `shouldRunGameplayFxUpdate(now, last, cadence)` (`gameplay-fx-update.ts`). The cadence steps are
fixed ms (60FPS 16, 40FPS 25, 30FPS 33) with `GAMEPLAY_FX_TICK_JITTER_MS` (4 ms) of headroom — a strict `>= 16` let a
jittered 15.9 ms frame skip a "60FPS" update (the stutter that once made Sparticle drop its cadence). Real rates:

| Cadence             | 60 Hz display      | 120 Hz display   |
| ------------------- | ------------------ | ---------------- |
| `frame-by-frame`    | 60/s               | 120/s            |
| `"60FPS"`           | 60/s (every frame) | 60/s (every 2nd) |
| `"40FPS"` (default) | 30/s (every 2nd)   | 40/s (every 3rd) |
| `"30FPS"`           | 30/s (every 2nd)   | 30/s (every 4th) |

**The throttle only saves CPU.** The GPU redraws the whole lane canvas on every display frame while playing, because
the tile scroll reads `tickSv`. Only the frame-rate lock lowers GPU draws during play.

### How a rate was chosen

Whether a lower rate shows is the **step per update** (speed ÷ rate): ≤ 1 pt per step is invisible, 1–3 pt is fine on
soft / blurred / low-alpha shapes, more than 3 pt on a small sharp bright shape judders against the smoothly
scrolling tiles. Fades with no motion look smooth with \~10+ steps. Two kinds stay at the display rate: anything tied to
the scroll (`tickSv`) and anything that answers a finger.

### Per loop

| Loop / effect                                            | Driver                                         | Before (60 / 120 Hz)                             | Now                                                           | Why                                                                          |
| -------------------------------------------------------- | ---------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Rhythm engine tick → `tickSv`                            | `use-rhythm-engine.ts`                         | display                                          | display                                                       | the game clock                                                               |
| Lane canvas GPU draw                                     | Skia `<Canvas>` (`GameCanvas.tsx`)             | display, also while paused                       | display while playing; **idle while the pause panel is open** | `fxFrozenSv`                                                                 |
| Tile slots (hit-line clamp, hold counter-scroll, cursor) | `TileFalling.tsx` frame cb                     | display, never stopped                           | display; **stops while paused**                               | scroll-bound                                                                 |
| Keyboard press                                           | `AtlasPianoKeyboard.tsx`                       | display while a key moves                        | **≤ 60/s** (accumulated dt, first step on the touch)          | key travel is 2 steps wide; the touch itself is shown at once; sleeps itself |
| Hold ember field (≤ 1280 quads)                          | `HoldEmberLayer.tsx`                           | display while live                               | same                                                          | positions follow `tickSv` — throttling would judder against the hold         |
| FX frame driver (clock + \~20 runners)                   | `gameplay-fx-frame.tsx`                        | display, also while paused                       | display; **returns at once while paused**                     |                                                                              |
| **Badge water crest + fill**                             | `MultiplierBadgeLayer.sim.ts` `stepBadgeWater` | 60 / 120, always from x2 (ignored its own 30FPS) | **30/s**, final fill lands exactly                            | crest \~6 pt/s → 0.2 pt/step; fill ≤ 2 pt/step on a 50 × 28 badge            |
| Badge tint cross-fade                                    | same, `stepBadgeTint`                          | 60 / 120 for 700 ms                              | **≤ 60/s**                                                    | 30 banded; 60 is band-free                                                   |
| Badge pop / fade                                         | `"30FPS"`                                      | 30                                               | 30                                                            |                                                                              |
| Background glow rise + tint                              | `GameplayGlowLayer`                            | 30 / 30–40 (`40FPS`)                             | **30/s** (`30FPS`)                                            | 2–4.5 pt steps on huge soft discs                                            |
| SmokeWave phase                                          | `SmokeWave.tsx`                                | 30 / 30–40                                       | **30/s**                                                      | soft pastel humps, 3–4.5 pt steps                                            |
| SmokeWave gate fade / tint / height                      | same                                           | 60 / 120                                         | **≤ 60/s**, end values land                                   | uniforms only                                                                |
| Tap tier bloom                                           | `TapTierGlowLayer.tsx`                         | 30 / 30–40                                       | **30/s**                                                      | 3 s soft bloom                                                               |
| StarRise orbs (68 quads)                                 | `StarRise.tsx`                                 | 60 / 60                                          | **30/s**                                                      | 5–10 pt/s → ≤ 0.7 pt/step                                                    |
| Perfect smoke puff                                       | `SmokeParticles.tsx` `60FPS`                   | 60 / 60                                          | same                                                          | \~800 pt/s — 30 would show steps                                             |
| Sparticle burst                                          | `Sparticle.tsx`                                | 60 / 120                                         | **≤ 60/s**                                                    | 207 ms burst keeps 12 samples                                                |
| Light-beam fade                                          | `LightBeam.tsx`                                | 60 / 120                                         | **≤ 60/s**                                                    | opacity only                                                                 |
| Judgement popup / centre label                           | `60FPS`                                        | 60 / 60                                          | same                                                          | main hit feedback                                                            |
| Score count-up                                           | `HeaderScoreLayer.tsx`                         | 60 / 120 for 360 ms                              | **30/s**, final value lands                                   | rolling digits can't be read faster                                          |
| Hit-line tint                                            | `useGameplayFxTierTint.ts`                     | 30 / 30–40, allocated a tuple every frame        | 30 / 40, **no idle allocation**                               |                                                                              |
| Header progress bar                                      | `GameplayHeader.tsx`                           | native style update every frame                  | **only when the 0.5 pt-snapped offset changes** (\~2–6/s)     | moves \~1–3 pt/s                                                             |
| Tick anchor sweep (JS)                                   | `tick-driver.utils.ts`                         | 50/s                                             | same                                                          | stops on pause                                                               |
| Native MIDI scheduler                                    | `MidiScheduler.swift`                          | 4 ms `.strict` timer, every screen               | same                                                          | see _Not changed_                                                            |

## Pause panel freeze

`PlayScreenBody` owns `fxFrozenSv` and flips it from `PausePanelHost`'s `onOpenChange`. It reaches the canvas as a
SharedValue prop (identity-stable — no re-record) → `GameplayAtlasSheetProvider` → `GameplayFxFrameProvider`, whose
worklet returns before advancing the clock, and `TileFalling`'s frame callback (`useGameplayFxFrozen`). Nothing writes a
SharedValue, so Skia stops redrawing. It is never set for engine auto-pause (waiting for a note) or the countdown — the
mount warmups need those frames and effects should keep moving there.

## Not changed — for DEV to decide

- **Native audio timer.** `MidiScheduler.swift` runs a 4 ms `.strict` dispatch timer (250 wake-ups/s, no coalescing)
  from engine start, and the engine is never suspended, so it runs on every screen. Options: a looser interval or
  dropping `.strict` (trade-off: scheduling accuracy), or suspending the engine outside Play.
- **iPad glow bloom overdraw.** Bloom radius is 18–27 % of lane width on every device — very large fill on iPad from x2.
  Option: a smaller radius on tablet (visual call).
- **Hold ember count.** It cannot be throttled (scroll-bound); the only lever is fewer embers per field
  (120 seeded of 160 per slot, 8 slots; the layer now has 5 slots × 244), mainly on iPad (visual call).
- **iPad Pro at 120 Hz** — see above.

## Measuring

- Xcode Instruments over a 10-minute session, before vs after: _Time Profiler_ (UI thread), _Metal System Trace_
  (GPU busy, and the x3 compile check from [streak-tier-fps-2026-10.md](/docs/investigations/streak-tier-fps-2026-10.md)), and the
  thermal state / _Energy Log_.
- Pause panel open: the UI thread should go near idle in Time Profiler.
- Pro iPhone after a rebuild: the perf HUD should hold a steady \~60.

***

<small>Source: [`docs/investigations/game-mode-thermal-2026-10.md`](https://github.com/leapgame/leap-sim-piano/blob/f794b594016038c483e2d20b6af56aea0ae1b982/docs/investigations/game-mode-thermal-2026-10.md)</small>
