Skip to content

iPhone: hold 30 fps while the device is thermally serious (thermal cap) - #220

Closed
v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:thermal-cap
Closed

v0lumehi wants to merge 2 commits into
seedds:mainfrom
v0lumehi:thermal-cap

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

Part of #142: Breath of the Wild performance on iPhone and Mac. Start there to see how the PRs fit together and the merge order.

Based on main (9a56ecf). It doesn't depend on the other open PRs and merges cleanly onto the pipeline stack.

Replaces #212 (same branch, reopened as a new PR so the automatic review runs).

A steady 30 fps instead of dropped frames when the device is hot

When an iPhone reaches thermal state serious, iOS lowers the GPU clock to about a third. On the iPhone 17 Pro Max, the median of the frame's tiny passes goes from 6 µs to 22 µs. Breath of the Wild's vistas have about 3,000 G-buffer draws, and at that clock they take 17–26 ms of GPU time per frame. At a 60 fps target, most 300-frame windows then dropped frames, and the phone kept heating.

With this PR, the host's frame step holds 30 fps while the device is serious or critical (NSProcessInfo.thermalState ≥ 2):

  • It reads the thermal state once a second.
  • It goes back to the cap after the device has been fair or better for 30 s, so it doesn't flap at the boundary.
  • It logs both changes: thermal state 2: the frame step holds 30 fps until … and … back to the frame rate cap; the frame step's line names the reason (frame step cap 60 → 30 fps … (thermal state serious)).
  • DM_THERMAL_CAP=0 turns it off.
  • It only acts where the host runs the frame step (a game with an fps target). The Mac reports no thermal state, so nothing changes there.

A steady 30 is also the cheaper state, so the device has a chance to cool down.

Measured (iPhone 17 Pro Max, iOS 27.0.1, BotW docked)

Start What happened
Cold (thermal 0) Fair after 61 s, serious after 226 s, then the cap held 30 fps. Before serious: 13 + 5 dropped frames in two windows while the clock fell.
Warm (fair at launch) Serious after 64 s, then 30 fps.
Launched at serious 6 windows of 300 frames at 30 fps: 0 dropped, on-screen p99 33.34 ms.

Not observed yet: the way back to 60. In these runs the device didn't return to fair for 30 s.

Checked

  • Local CI-equivalent run: host tests, graphics CPU tests, every graphics test builds, dmhost for three profiles, the iOS compile check and the tool tests all pass.
  • With Breath of the Wild's profile: t_nvn (152 checks), t_fstep (51) and t_present_snap (13) pass.
  • No unit test drives the thermal state. The behaviour above comes from the device logs.
  • Docs: a reference entry in docs/reference/frame-rate.md (A thermally serious iPhone holds 30 fps), the symptom index, and the game's note.

…step holds 30 fps, and goes back to the cap after 30 s at fair or better (DM_THERMAL_CAP=0 turns it off; the Mac reports no thermal state). At serious iOS caps the GPU clock to about a third: Breath of the Wild's vistas (about 3,000 G-buffer draws) took 17-26 ms a frame and dropped frames in most 300-frame windows; a steady 30 also lets the device cool. Tests: t_nvn 152, t_fstep 51, t_present_snap 13, iOS compile check
… movie or thermal state serious; it said prerendered movie for both), and docs/reference/frame-rate.md has its entry (A thermally serious iPhone holds 30 fps), linked from Breath of the Wild's note; the symptom index is regenerated
seedds added a commit that referenced this pull request Oct 26, 2026
Hold the host frame step at 30 fps while iOS reports serious or critical
thermal pressure, and restore its configured cap after 30 calm seconds.
Keep the existing movie cap and DM_THERMAL_CAP=0 override.

Sample thermal state independently of movies and configured 30 fps targets
so heating resets recovery and cooling counts during playback. Serialize
the sample, cached cap and recovery timer across acquire/present readers.
The original PR failed five timing checks and ThreadSanitizer detected a
race through concurrent production cap getters.

Add controlled-clock production-path regressions and CI coverage, including
disabled/inactive caps and ThreadSanitizer. Record the shared mechanism
and validation limits in the frame-rate reference and BotW note.

Validated on latest main with the BotW profile: 24 thermal checks normally
and under ThreadSanitizer, 51 frame-step checks, 154 NVN checks, the
present-snapshot suite, 21 tool/docs checks, Mac host build, and iOS compile
check (133 sources). No new device gameplay or thermal recovery run.

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Integrated on main as c4b74a6, with coauthor credit to @v0lumehi. Thanks for the thermal-cap work and device measurements.

Review confirmed two bugs, now fixed in that commit:

  • The thermal policy's mutable state was shared by acquire/present callers without synchronization. ThreadSanitizer reproduced a data race; a mutex now protects the complete sample and recovery transition.
  • Movies and configured 30 fps targets short-circuited thermal sampling. Heating during playback could preserve an old calm timer and restore 60 fps too early; cooling during playback could instead add another 30-second hold. Sampling now continues independently of those caps.

The original code failed five controlled-clock checks. The integration passes all 24 thermal checks both normally and under ThreadSanitizer, plus 51 frame-step checks, 154 NVN checks, all four present-snapshot scenarios, 21 tool/docs checks, the BotW Mac host build, and iOS compilation of 133 sources. Thermal regressions are included in CI.

No fresh iPhone gameplay or on-device recovery-to-60 test was performed; the controlled-clock tests validate the recovery policy, while the device measurements above remain the PR author's.

Closing this PR because its functionality and the review fixes are incorporated directly into main.

@seedds seedds closed this Oct 26, 2026
@v0lumehi
v0lumehi deleted the thermal-cap branch October 26, 2026 09:29
Xipzer pushed a commit to Xipzer/nxnative that referenced this pull request Oct 28, 2026
The thermal cap (seedds#220) holds the frame step at 30 fps while iOS reports a serious
or critical thermal state, and DM_THERMAL_CAP=0 turned it off only from an env
file. It is a trade a player should be able to make: with a phone cooler, or for
a player who would rather have an uneven 45 to 55 than an even 30, it costs more
than it saves.

"Halve when hot" in Performance, on by default, so nothing changes for anyone
who does not touch it. Shown only for a game with a frame step, as Hold frames
when late is.

The note says what the thermal state does not catch. On an iPhone 17 Pro Max,
Breath of the Wild 1.9.0 dropped a third of its frames for ten minutes with the
state reading nominal throughout, and one scene's GPU time went from 8.40 ms to
21.83 ms while it still read nominal: iOS lowers the clock well before it calls
the device hot. The same phone, charged over USB while large apps were installed
onto it, started a game already at serious and was held at 30 from the first
frame, which is the case the setting is for.
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
Hold the host frame step at 30 fps while iOS reports serious or critical
thermal pressure, and restore its configured cap after 30 calm seconds.
Keep the existing movie cap and DM_THERMAL_CAP=0 override.

Sample thermal state independently of movies and configured 30 fps targets
so heating resets recovery and cooling counts during playback. Serialize
the sample, cached cap and recovery timer across acquire/present readers.
The original PR failed five timing checks and ThreadSanitizer detected a
race through concurrent production cap getters.

Add controlled-clock production-path regressions and CI coverage, including
disabled/inactive caps and ThreadSanitizer. Record the shared mechanism
and validation limits in the frame-rate reference and BotW note.

Validated on latest main with the BotW profile: 24 thermal checks normally
and under ThreadSanitizer, 51 frame-step checks, 154 NVN checks, the
present-snapshot suite, 21 tool/docs checks, Mac host build, and iOS compile
check (133 sources). No new device gameplay or thermal recovery run.

Co-authored-by: v0lumehi <[email protected]>
Xipzer added a commit to Xipzer/nxnative that referenced this pull request Nov 13, 2026
Game carries eleven unrelated rows: how fast the game runs, how large it
renders, which console mode it reports, how the finished frame is scaled,
fitted and shaped, which language it speaks, how the Mac window opens, and a
frame-rate read-out. The only thing they have in common is that none of them
belonged in Controls or Performance.

Picture takes the rows that are about the finished frame rather than about
the game: Render scale, Upscaling, Game's upscaler, Picture and Picture
shape. Game keeps Frame rate, Dynamic resolution, Console mode, Game language
and the Mac's Display mode. The frame-rate counter moves to Performance next
to the Performance HUD, since both are read-outs rather than settings. The
iOS in-game menu follows the sections, so the counter comes after the
controls there.

The split matters more as the section grows. With the anisotropic and
trilinear filtering of seedds#335 and the upscaling detail and sharpening of seedds#345,
Game would hold fifteen rows, nine of which are about how the picture looks.

The heading order on screen is the order of SECTIONS, and rows keep their
table order inside a section, so settings.tsv still decides the layout on its
own.

In docs/settings.md the Picture section takes the anchor #picture, and the
Picture setting inside it becomes #picture-1.

The thermal cap (seedds#220) holds the frame step at 30 fps while iOS reports a
serious or critical thermal state, and DM_THERMAL_CAP=0 turned it off only
from an env file. It is a trade a player should be able to make: with a phone
cooler, or for a player who would rather have an uneven 45 to 55 than an even
30, it costs more than it saves.

"Halve when hot" in Performance, on by default, so nothing changes for anyone
who does not touch it. Shown only for a game with a frame step, as Hold
frames when late is.

The note says what the thermal state does not catch. On an iPhone 17 Pro Max,
Breath of the Wild 1.9.0 dropped a third of its frames for ten minutes with
the state reading nominal throughout, and one scene's GPU time went from
8.40 ms to 21.83 ms while it still read nominal: iOS lowers the clock well
before it calls the device hot. The same phone, charged over USB while large
apps were installed onto it, started a game already at serious and was held
at 30 from the first frame, which is the case the setting is for.

The tests follow: Render scale is a basic row under Picture, and in the Mac
window's list for Breath of the Wild every Game row is basic, so its Advanced
settings start at Picture.
ltrdpper pushed a commit to ltrdpper/BananaNative that referenced this pull request Nov 14, 2026
Xipzer added a commit to Xipzer/nxnative that referenced this pull request Nov 18, 2026
Game carries eleven unrelated rows: how fast the game runs, how large it
renders, which console mode it reports, how the finished frame is scaled,
fitted and shaped, which language it speaks, how the Mac window opens, and a
frame-rate read-out. The only thing they have in common is that none of them
belonged in Controls or Performance.

Picture takes the rows that are about the finished frame rather than about
the game: Render scale, Upscaling, Game's upscaler, Picture and Picture
shape. Game keeps Frame rate, Dynamic resolution, Console mode, Game language
and the Mac's Display mode. The frame-rate counter moves to Performance next
to the Performance HUD, since both are read-outs rather than settings. The
iOS in-game menu follows the sections, so the counter comes after the
controls there.

The split matters more as the section grows. With the anisotropic and
trilinear filtering of seedds#335 and the upscaling detail and sharpening of seedds#345,
Game would hold fifteen rows, nine of which are about how the picture looks.

The heading order on screen is the order of SECTIONS, and rows keep their
table order inside a section, so settings.tsv still decides the layout on its
own.

In docs/settings.md the Picture section takes the anchor #picture, and the
Picture setting inside it becomes #picture-1.

The thermal cap (seedds#220) holds the frame step at 30 fps while iOS reports a
serious or critical thermal state, and DM_THERMAL_CAP=0 turned it off only
from an env file. It is a trade a player should be able to make: with a phone
cooler, or for a player who would rather have an uneven 45 to 55 than an even
30, it costs more than it saves.

"Halve when hot" in Performance, on by default, so nothing changes for anyone
who does not touch it. Shown only for a game with a frame step, as Hold
frames when late is.

The note says what the thermal state does not catch. On an iPhone 17 Pro Max,
Breath of the Wild 1.9.0 dropped a third of its frames for ten minutes with
the state reading nominal throughout, and one scene's GPU time went from
8.40 ms to 21.83 ms while it still read nominal: iOS lowers the clock well
before it calls the device hot. The same phone, charged over USB while large
apps were installed onto it, started a game already at serious and was held
at 30 from the first frame, which is the case the setting is for.

The tests follow: Render scale is a basic row under Picture, and in the Mac
window's list for Breath of the Wild every Game row is basic, so its Advanced
settings start at Picture.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants