Repository navigation
iOS: the host learns the refresh rate of the screen the game's view is on - #590
Closed
oliverames wants to merge 2 commits into
Closed
oliverames wants to merge 2 commits into
oliverames wants to merge 2 commits into
Conversation
oliverames
force-pushed
the
codex/ios-rendering-scene-metrics
branch
from
October 29, 2026 18:43
0e64322 to
4f83140
Compare
oliverames
force-pushed
the
codex/ios-rendering-scene-metrics
branch
2 times, most recently
from
October 31, 2026 12:19
3bb1a4f to
21987cd
Compare
oliverames
force-pushed
the
codex/ios-rendering-scene-metrics
branch
from
November 5, 2026 14:49
21987cd to
ff9bfc3
Compare
This was referenced Nov 5, 2026
oliverames
force-pushed
the
codex/ios-rendering-scene-metrics
branch
3 times, most recently
from
November 10, 2026 03:19
ef551be to
40e91f1
Compare
… the screen the game's view is on: 120 fps can run on a 120 Hz screen there, and a TV's rate counts while the picture is on it
front_screen_max_fps had no definition on iOS, so the graphics layer's weak default answered 0 there. The host took that as a screen below 120 Hz: with DM_FPS_TARGET=120 in a game whose profile has fps_max 120, the cap stayed at 60 on a 120 Hz iPhone or iPad ("120 fps: cap 0 → 60 fps (the screen is below 120 Hz)"), and the display link never counted virtual ticks. mtl_display_hz reads UIScreen.mainScreen on iOS, but its two callers only ask whether it is 0, so it is left as it is. The pixel scale already comes from the view's own screen (a5bf542, e2fadf2); this does the same for the rate.
front_ios.m now defines front_screen_max_fps: the maximumFramesPerSecond of view.window.windowScene.screen, kept in an atomic. The game's view reads it on the main thread when it joins a window (at the start, and on its move to a TV's window and back) and when its scene's geometry changes (windowScene:didUpdateEffectiveGeometry:, which UIKit also calls when a scene moves to another screen), and logs each change.
What changes at run time, all through code that already runs on the Mac (high_cap_tick and the frame step's shown_slack in hle_nvn.c, link_range and link_sync in nvn_mtl.m):
- A 120 Hz iPhone or iPad with DM_FPS_TARGET=120 and fps_max 120: the cap is 120 and the display link runs at 120 Hz. The launcher still offers 120 on the Mac only, so this takes the switch set by hand. A 60 Hz iPhone or iPad keeps the cap of 60.
- The picture on a TV: the TV's rate counts, so with the 120 above a 60 Hz TV brings the cap back to 60, and unplugging it gives 120 again. The phone's own screen would have said 120 there, and a game that steps by its target would have run at half speed.
- A screen whose rate is not a multiple of the link's (a 144 Hz monitor on an iPad, a 50 Hz TV with the 30 Hz link): virtual ticks and shown_slack, as on the Mac.
- Every other game, at 30 or 60 on a 60 or 120 Hz screen: the same display link range as before, set once more when link_sync first sees the rate or sees it change.
- An iPhone with two screens changes rate only if UIKit reports them as two screens of different rates.
No Front-ends line: a front end that links front_ios.m gets this with it, and one with its own iOS view keeps the weak default of 0 as before.
Checked: dm/ios/tests/screen_rate_check.m, an app of the production game view and scene delegate with the host's entry points empty (tools/build_screen_rate_check.py builds it, no game files), in the iPhone 18 Pro simulator on iOS 27.3: 6 checks, 0 failed (no rate before the view is in a window, the scene's screen's rate once it is, kept while the view is off every window, read again on its return and on the geometry callback, the same on another thread); its device build compiles. The iOS compile check passes (262 files), the unsigned iOS app builds and links with synthetic modules, test_docs (6) and test_env_switches (1) pass, the Python lint ratchet has 0 new findings and clang-tidy none above the baseline. Not run: anything on a device, so no game at 120 on an iPhone or iPad, no TV or monitor on either (nor what maximumFramesPerSecond says for one, nor that the callback comes when an iPad's window goes to another screen), no iPhone with two screens, and Low Power Mode, which holds a 120 Hz iPhone's screen to 60.
oliverames
force-pushed
the
codex/ios-rendering-scene-metrics
branch
from
November 10, 2026 13:32
40e91f1 to
e65f4fd
Compare
Owner
|
Design verdict: Superseded by the landed iOS screen-rate implementation; closing. Should it exist? Yes: the host needs the actual game screen’s rate for its frame cap and timing. Main now implements that contract. c8744e4f (#2792) provides front_screen_max_fps from the game view’s window scene and updates it as the screen changes. The shared setting availability also filters the 120 Hz option. This replaces the missing weak-default contract addressed here. Closing the duplicate does not add physical ProMotion/TV/multi-screen testing beyond the existing implementation’s own validation. Review base: 82c354b0.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
On an iPhone or iPad the host doesn't know how fast the screen refreshes.
front_screen_max_fpshas no definition on iOS, so the graphics layer's weak default answers 0, and the host reads that as a screen below 120 Hz. WithDM_FPS_TARGET=120in a game whose profile hasfps_max 120, a 120 Hz iPhone logs120 fps: cap 0 → 60 fps (the screen is below 120 Hz)and stays at 60, and the display link never counts virtual ticks.This PR used to move the pixel scale to the view's own screen as well. Main has done that since a5bf542 and e2fadf2, so I've rebuilt the PR on current main as the one thing main still lacks: the rate. The
drawableSizerounding is gone too; it's in #1145.front_ios.mnow definesfront_screen_max_fpsas themaximumFramesPerSecondof the screen the game's view is on, kept in an atomic. The view reads it on the main thread when it joins a window (at the start, and on its move to a TV's window and back) and when its scene's geometry changes, which UIKit also reports when a scene moves to another screen. I leftmtl_display_hzalone: it readsUIScreen.mainScreen, but both of its callers only ask whether it's 0.What changes at run time, all through code that already runs on the Mac:
DM_FPS_TARGET=120andfps_max 120gets a cap of 120 and a 120 Hz display link. The launcher still offers 120 on the Mac only, so this takes the switch set by hand. A 60 Hz device keeps the cap of 60.shown_slack, as on the Mac.link_syncsets it once more when it first sees the rate.The reference entry is An iPhone or iPad tells the host its screen's rate.
Checked
dm/ios/tests/screen_rate_check.mis a small app of the production game view and scene delegate with the host's entry points empty, built bydm/ios/tools/build_screen_rate_check.py(no game files). In the iPhone 18 Pro simulator on iOS 27.3 it passes 6 checks, 0 failed: no rate before the view is in a window, the scene's screen's rate once it is, the rate kept while the view is off every window, read again on its return and on the geometry callback, and the same value on another thread. Its device build compiles. The iOS compile check passes (262 files, 0 failed) and the unsigned iOS app builds and links with synthetic modules.test_docs.py(6) andtest_env_switches.py(1) pass. The Python lint ratchet has 0 new findings and clang-tidy has none above the baseline.scripts/regress.py check --games: not run. The engine side is one comment; the change is in the iOS front end, which regress doesn't reach.maximumFramesPerSecondsays for one and whether the geometry callback comes when an iPad's window goes to another screen; an iPhone with two screens; Low Power Mode, which holds a 120 Hz iPhone's screen to 60.Rebuilt as one commit on main
fd8188c9on 2026-11-10 (heade65f4fdf).Front ends
Nothing to act on. A front end that links
front_ios.mgets this with it, and one with its own iOS view keeps the weak default of 0 as before.Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index). The entry is indocs/reference/frame-rate.md; the earlierrendering.mdentry is gone with the scale and rounding work.dmsh_chain.py --headerwas run anddm/gfx/nvn/dmsh_chain.his part of the change. Not applicable.