Skip to content

Record frame times from a game's launch options, and chart them - #112

Merged
v0lumehi merged 3 commits into
LNPANDY:mainfrom
subyoung:frame-times
Oct 30, 2026
Merged

v0lumehi merged 3 commits into
LNPANDY:mainfrom
subyoung:frame-times

Conversation

@subyoung

Copy link
Copy Markdown
Contributor

What and why

The host already writes a timing row per frame when DM_NVN_TSV names a file (dm/gfx/nvn/hle_nvn.c, the rows scripts/bench.py reads), but only from the command line. A player who sees a stutter or a slow place has no way to record it from the launcher, or to show numbers in an issue such as #93.

A game's launch options now have a Frame times section, after Mods:

  • Record frame times (off by default, per game): Play passes DM_NVN_TSV with DM_NVN_TSV_CALLS=0 (timing rows only) to a new file in <library>/frame-times/<title ID>/, named by the start time.
  • The last three recordings, each summed up as bench.py counts (nearest-rank percentiles): frames, fps, median, 99 %, slowest frame, frames over 50 ms, dropped frames (@presented_ms −1), and a chart of the frame times with those over 50 ms marked. A long session is thinned for the chart to about 2,000 points, each the slowest of its stretch, so a hitch is never thinned away.
  • Refresh and Open folder, as the Mods section has.

Files: FrameTimes.swift (parsing, summary, files, the switch; no UI), FrameTimesView.swift (one recording), LaunchOptionsView.swift (the section), LauncherView.swift (Play merges the two variables into the launch environment), Localization.swift (both languages). No vendored file is touched.

Checked

  • Tests: cd frontend && swift test: 174 tests, 0 failures (2 skipped, as before); new FrameTimesTests (7): the timing rows in frame order with call-count rows and a half-written last line skipped, the summary against hand-counted values, nearest-rank percentiles, the environment, the folder and newest-first listing, off until switched on per game, both languages.
  • Visual QA: NX_LAUNCHER_CAPTURE_DIR=<dir> swift test --filter FrameTimesTests writes launch-options-frame-times.png (the section in the launch options) and launch-options-frame-times-rows.png (two recordings with their charts); checked in English.
  • Run on a Mac: Super Mario Bros. Wonder 1.2.1 (010015100B514000), built with build_ipa_from_nsp.py --platform mac-app on an Apple M2, macOS 27, opened as Play opens it with these two variables for 60 s from start: the host wrote 1,835 frames. FrameTimes.Summary of that file and bench.py's frames / pct over it agree exactly: median 14.338 ms, 95 % 21.814, 99 % 30.036, slowest 192.368, 3 dropped.
  • Not checked: an iPhone or iPad recording (the section reads any DM_NVN_TSV file, but the launcher only starts Mac games); the Chinese strings on screen.

Scope

  • No vendored file (dm/, scripts/, docs/, ref/, AGENTS.md) is edited, or it goes through a sync patcher or upstream first (pr-scope)
  • No keys, game files or data extracted from a game in the change or the attachments

@v0lumehi

Copy link
Copy Markdown
Collaborator

Thanks, the summary matching bench.py exactly is a nice check. Could you rebase onto current main? The branch is 156 commits behind and conflicts in LauncherView.swift and Localization.swift (the table gained a Swedish column in #168, so new strings need a third value).

@subyoung

Copy link
Copy Markdown
Contributor Author

Rebased onto main. The new strings have their Swedish entries, and the recording is added on top of GameStart.environment by one helper that console mode's Play calls too, so a recording is made however the game is started.

@v0lumehi

Copy link
Copy Markdown
Collaborator

@LNPANDY heads-up: this merges tomorrow (2026-10-30) after the 48 hours since it was posted, once CI is green, unless you object. It adds the recording to GameStart.environment from the outside through one helper, so it should not collide with your #220. #110 follows the same plan.

The host already writes a timing row per frame when DM_NVN_TSV names a file (the rows
scripts/bench.py reads), but only from the command line. A game's launch options now have
a Frame times section: a switch makes Play pass DM_NVN_TSV (timing rows only,
DM_NVN_TSV_CALLS=0) to a new file in <library>/frame-times/<title ID>/, and the last three
recordings are summed up as bench.py counts them (nearest-rank percentiles: median, 99 %,
slowest, frames over 50 ms, dropped frames) and charted, the hitches marked. Off by default.

Rebased onto main: the desktop Play now builds its environment with GameStart.environment, and the recording is added on top of it by one helper (FrameTimes.recordingEnvironment) that console mode's Play calls too, so a game whose recording is on is recorded however it is started. The strings have their Swedish entries (LNPANDY#168).

Checked after the rebase: swift build; swift test, 368 tests, 0 failures (FrameTimesTests gains testBothWaysOfStartingAGameRecordTheSame and checks the Swedish entries; ConsoleLiveTests unchanged).
The release build on the CI runner stopped at ConsoleControllersView.swift:133 ("the compiler is unable to type-check this expression in reasonable time"): the chip's spoken label was one + chain of optionals, String(format:) calls and ?? defaults. It is now chipLabel(_:), the same parts (name, kind, player, battery) joined by ", " with explicit types, so the text is unchanged.

Checked: swift build -c release; swift test, 436 tests, 0 failures.
@subyoung

Copy link
Copy Markdown
Contributor Author

The native macOS build failed at ConsoleControllersView.swift:133 ("unable to type-check this expression in reasonable time", twice); that line is not part of this change and builds locally, so it looks like the runner's type-checker budget. I rebased onto main and added one small commit that builds the controller chip's label in steps with explicit types (same text). swift build -c release and swift test (436 tests) pass. The run needs approving again.

@v0lumehi

Copy link
Copy Markdown
Collaborator

Thanks, @subyoung. The split chip label reads the same and is easier on the type checker, so it is fine to carry it here. I approved the new runs. The merge plan for tomorrow stands once they are green.

@v0lumehi v0lumehi added launcher The NX2Apple launcher app mac Mac enhancement New feature or request labels Oct 30, 2026
@v0lumehi

Copy link
Copy Markdown
Collaborator

Thanks @subyoung. I merged main into the branch once more, with your commits unchanged (a merge commit, no rebase). The conflicts were in the Play paths and the Swedish strings. The screen and fullscreen arguments and the return watcher from main are kept, and the frame-time recording is added on top in both the library Play and console mode. Both sets of Swedish strings are in. Build and tests pass locally.

@v0lumehi
v0lumehi merged commit 3fafa5b into LNPANDY:main Oct 30, 2026
10 checks passed
@v0lumehi v0lumehi mentioned this pull request Oct 30, 2026
3 tasks done
@v0lumehi v0lumehi mentioned this pull request Nov 19, 2026
5 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request launcher The NX2Apple launcher app mac Mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants