Optimize: client loop, cards and telemetry
Description
Optimize in the app: a per-game way to make a game run better on the device it is played on, with every change reversible. The server decides what to try; this PR is the client side only.
What the user sees
- Cards after a session: a first card when a session ran short of what it could do, a frame-cap question, after-cards that show before and after measurements with keep, undo, keep going or stop, a done card, a "nothing yet" card, and a worse card when a change was taken off. Every card is d-pad focusable and lays out in two columns in landscape.
- First card: the title says what happened in the session (for example that frames started dropping after some minutes), a line under it gives what the player saw in the session's own numbers (the fall in frame rate, the average with its dips, or the share of stuttering frames), and one sentence names the outcome on offer: a smoother game, less heat, longer battery life, less stutter, or a steady frame rate when the session held it before it fell or the answer carries one. A session with nothing to offer leaves no card.
- Goal chooser: Balanced (always the suggested goal), Quality ("Keeps the game looking its best. Steadier, at a lower frame rate if needed."), Performance, Power and heat, Potato ("Everything to the minimum. Ugly, but it runs."), then Off. Picking a goal starts it; switching goals takes the old goal's changes off and puts the new goal's kept changes back.
- Optimize dialog under the game's settings cog: the game's name, a short status pill (Measuring, Tuning, Paused, Done, Waiting, Trial used), the plan line as a pill (games used, the monthly reset date, unlimited, or free to try with an account, as the server reports it), the goal cards, Continue when it is offered, Restore original settings with an explanation, and Close. The game options row is a plain row like its neighbours; it opens the dialog.
- Upsell: shown when signed out, or when the free or monthly games are used up; never for unlimited plans or while games are left. It names the existing plans, lists what Optimize gives in outcome words, and opens the existing See plans flow.
- Sign-in gate: actions that need an account ask for sign-in first and run once it succeeds.
- Restore: puts the game's settings back the way they were before Optimize changed anything.
What the client does
- Measures: a light per-second sampler (frame times, CPU and GPU load and clocks, the game's hot thread, temperatures and thermal status, memory pressure, DXVK pipeline cache growth read in the background) and a local session verdict that serves when the server does not answer. Nothing runs per frame or inside the game.
- Sends session data: the session's measurements and per-second records, the game's store identity and installed build, and an engine hint from the install folder for games the server does not know.
- Applies the returned change with a backup: all or nothing, with a backup of the values it replaced. Read-only files stay read-only. Before each launch, kept keys the game reset are put back; a key a newer kept change or the change on trial also writes is left to that newer change.
- Reverts on crash: a change whose session crashed or never reached gameplay comes off as soon as the game's environment is down, or at the next launch if the app died; it is reported as a crash.
- Reports the outcome: each judged change is reported with both sessions; the server's judgement replaces the local one when it gives one.
- Funnel events: cards shown and answered, changes applied and judged, sign-in prompts, sent in small batches to our own API; a few are mirrored to PostHog only when usage analytics is on.
- Plans: the account's plan, games used and reset date are read leniently from the server, falling back to the older trial fields.
- Telemetry fixes:
hot_thread_name,hot_thread_pct_p95andgame_rss_p95_mbongame_exitedkeep their old meaning; the filtered hot thread is sent ashot_thread_pick_nameandhot_thread_pick_pct_p95. Launches with no change on trial skip the container read; state is only written when it changed.
WoW64 explicit-list follow-up to utkarshdalal/GameNative#2383
utkarshdalal/GameNative#2383 sends the 32-bit CPU list to a window's process only when the list was set explicitly, and judged that against this device's default. A container made on a device with another core count looked explicit. A list shaped like the default for any core count now reads as the default. ContainerAffinityTest covers it.
Merged master
origin/master merged in (with utkarshdalal/GameNative#2383 and the GOG DLC work); no conflicts, and the CRLF Turkish strings file keeps CRLF.
Strings added
All in the default file and all 15 locales.
- Status and plan:
optimize_status_not_started,optimize_status_measuring,optimize_status_tuning_next,optimize_status_retry_next,optimize_status_trying_settings,optimize_status_trying_cores,optimize_status_trying_components,optimize_status_trying_cap,optimize_status_trying_plain(the status of a change on trial names only its kind),optimize_status_paused,optimize_status_done,optimize_status_exhausted,optimize_status_waiting,optimize_status_cap_held, pluralsoptimize_status_kept,optimize_pill_measuring,optimize_pill_tuning,optimize_pill_done,optimize_pill_waiting,optimize_pill_trial_used,optimize_plan_unlimited,optimize_plan_signed_out, pluralsoptimize_plan_monthly,optimize_plan_monthly_resets,optimize_trial_used,optimize_trial_offer,optimize_trial_progress,optimize_trial_used_short,optimize_included,optimize_see_membership. - Upsell:
optimize_upsell_title,optimize_upsell_benefit_perf,optimize_upsell_benefit_device, pluralsoptimize_upsell_plan_line,optimize_upsell_free_used,optimize_upsell_monthly_used,optimize_upsell_monthly_used_resets. Plan names reusegamenative_account_plan_basicandgamenative_account_plan_pro; See plans reusessupport_see_plans. - Goals:
optimize_profile_*andoptimize_profile_*_descriptionfor Off, Balanced, Quality, Performance, Power and heat and Potato,optimize_choose_goal,optimize_badge_suggested,optimize_badge_free_to_try,optimize_hint_heat. - Cards and results:
optimize_card_*,optimize_after_*,optimize_cap_*,optimize_evidence_*,optimize_offer_*,optimize_measured_*,optimize_metric_*(includingoptimize_metric_frame_p99,optimize_metric_ms_value, and pluralsoptimize_metric_minutes),optimize_benefit_*,optimize_keep_going,optimize_keep_tuning,optimize_happy,optimize_undo,optimize_undo_all,optimize_keep_changes,optimize_stop_here,optimize_continue. - Actions:
optimize_restore_original,optimize_restore_original_body,optimize_restored,optimize_undo_failed,optimize_game_running.
Tests
Unit tests cover the sampler buffer and verdict, apply and revert of returned changes, kept-key rechecks, crash revert, state round trips, card and offer decisions, the plan line and upsell visibility, status pills, the Potato goal's wire mapping, order and container change, the incremental cache reader, the hot thread pick, and the WoW64 default check.
The loop was also run end to end on a device (Odin 3, The Forest): first card, accept, trial sessions, after-card, Keep tuning and Restore original settings. Baseline choice, judging length, done-card tiles, the restore confirmation and the plan pill were fixed from that run and are covered by unit tests: the card's session as the first baseline and in the next-rung verdict, five-minute sessions judged, Keep tuning asking again, and the plan pill from the tier and from the older member fields.
E2E screenshot index: /tmp/odin_e2e/index.md
- f404e2baa: status and plan show as plain text lines under the title (no capsules), Suggested is a thin outlined tag, deltas are plain text; a goal switch in the dialog no longer pops the done card; Restore shows only when there is something to restore; Left returns to the last focused goal; portrait dialog uses the width with insets; Optimize sits directly above Get AI help in the game options list (2f68f9228), both with a membership marker.
- 2d6be939d: the Optimize row in the game options list is a plain row like the others (icon, title, the shared membership marker); status, plan and Continue live only in the dialog.
- dc14e6e0a: dialog d-pad: Right from any goal goes to Continue (or the first action shown), Left from an action returns to the last focused goal; focused cards get a bright border and an outer ring apart from the selection border; Restore shows only with a step on or kept and asks for confirmation first, and never pauses a goal when nothing came off; the status sentence sits under the header in both orientations and is not repeated; Suggested marks the verdict's goal whatever goal is on; a goal picked in the dialog reads Tuning on your next launch; the check sits on the title line; scroll survives rotation.
- 1a6c9186e: dialog first focus lands on the selected goal (the first goal when none is chosen) once the state has loaded, so Down moves through the goals; the status sentence under the header is dropped when it only restates the header status (Measuring, Tuning on your next launch, Paused); goal descriptions take exactly two lines so every goal card has the same height.
- cbff0a636, 04d14eafe: the first card shows what the session measured and the outcome on offer; the status of a change on trial names only its kind.
- 9dc4f2d31: no card when there is nothing to offer; the processor, memory and display sync titles describe what the player saw; new frame-cap question text; the GPU work tile is removed.
- 41fd99f2f: the Quality goal takes the place of Stability; a first card always suggests Balanced.
- 0ce81cdfd: a settings step can carry a distance for each key; the app writes the value that many levels below (or above) what the game holds now, so a step is the same size whatever settings the game starts on.
- eead63990: no first card for a session that held its frame rate without heat or stutter.
- 98543c1d2, dd2a094b5: a step counts levels from the highest one that holds the key's value and scales its distance to that level; Balanced is done when the game runs fine.
- 057df2b50, 6e2159c8a, 536e862e3: the plan line follows account and plan changes; a monthly plan with its games used reads "This month's games used"; a trial session whose frames stop until the user leaves is treated as a crash and the step comes off.
- c5b851226, e6a3239bf, 3c9df9628: Restore original settings starts the game's ladders over (crashed steps stay excluded); a card names a gain only from 5 %; signed out always shows the signed-out line.
- 4b7cff7c3, adebebccb, 6b05e5621: the session verdict needs low available memory, not only trim callbacks, for a memory diagnosis; a busy GPU limits the second even while the hot thread is busy; requests carry what the verdict was based on.
- 6aaee6cac, 70e1c532c: a kept step with nothing to see says "No change you can see yet"; a step kept without a comparison shows the kept card.
CI
- Run 43011443121 at c6b47cb1b (build and unit tests, Legacy and Modern).
- Run 42596075264 at d8a7373, via draft utkarshdalal/GameNative#2386.
- Run 42617426783 at 4110af8, via draft utkarshdalal/GameNative#2388.
- Run 42621372910 at 06ae52f72, via draft utkarshdalal/GameNative#2389.
- Run 42626252488 at 07e1f1b01, via draft utkarshdalal/GameNative#2390.
- Run 42641500233 at d4998615d (build and unit tests, Legacy and Modern): passed.
- Run 42651057062 at f922dc64e (build and unit tests, Legacy and Modern): passed.
- Run 42657673061 at f404e2baa (build and unit tests, Legacy and Modern): passed.
- Run 42660952313 at 2f68f9228 (build and unit tests, Legacy and Modern): passed.
Recording
None yet. The dialog, upsell, cards and sign-in need a device pass on a handheld in landscape with a controller.
Type of Change
- Bug fix
- Performance / stability improvement
- Compatibility improvements
- Other (requires prior approval)
Checklist
- If I have access to
#code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed. - This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
- I have attached a recording of the change.
- I have read and agree to the contribution guidelines in
CONTRIBUTING.md.
Summary by CodeRabbit
- New Features
- Added Optimize controls for selecting performance profiles, viewing game-specific recommendations, and applying or restoring settings.
- Optimization results can include measured performance indicators, and certain crashes trigger automatic rollback of changes.
- Added sign-in and membership prompts for Optimize features, plus optimization controls for supported games.
- Improvements
- Game sessions now collect more detailed performance and crash diagnostics.
- DXVK configurations can specify a compiler thread count.
- Localization
- Added translated Optimize interface text in multiple languages.