fix(menu): a settings row is built from the same sample of the renderer as the fact that sends it again (#3277) #3289
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3289
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/caps-sample-row-3277"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #3277. A settings row in the menu could keep showing a lock (or an upscaler's reason, a slider's ceiling, a choice) that the renderer no longer had.
The cause. Since #3208/#3223, two things in
game/crates/api/src/services/settings_host.rsread the renderer's capabilities at different times:lockedtext, its hint, its ceiling, which choices can be picked) asked the renderer live, each time it was built (link::capabilities());Fact::CapsState, and the declarations' generation come fromcaps_hashes(), a sample kept for 250 ms (CAPS_EVERY_NS).So a state that came and went inside one window could be read by the menu and never taken back. Sample 1 sees "free", the renderer locks a row, the menu reads it (live: locked), the lock goes, and sample 2 sees "free" again.
CapsStatenever moved, the row is not dirty, and nothing sends it again. The row keeps the lock until some unrelated fact moves.The fix. The sample now keeps the renderer's answer beside its two hashes (
caps_sample()/CapsKept), and row and declaration reads insettings_host.rsuse that answer (caps()). A row and the fact that resends it then come from the same answer: a change shows up to 250 ms late, never a state no sample saw. Device selections use the capabilities that supplied the last declared choices for that mod and row, so a changed device list does not turn a selection into a different device. Without a capabilities snapshot, only choices available without one can be selected. When a sample is available, it is reused for the window.One read stays live on purpose:
list_choice_texts, the control bridge's lists. The bridge rebuilds them when the renderer's own live generation moves (game/crates/longshot-game/src/menu.rs,caps_generation). Fed from a sample that can be behind, it would rebuild with the old list and keep it until the next change. A cold review caught this.How to see it on
main: nobody has reported it in the game, and the issue says as much. It needs a lock that comes and goes within a quarter of a second with no setting change. The new test shows it with the fake renderer.Read first:
caps_sampleandcapsinsettings_host.rs, then the testa_lock_that_comes_and_goes_between_two_samples_does_not_stay_on_a_row_read_meanwhileat the end of that file.Testing
Tested: Windows 10 22H2, RTX 4090, NVIDIA 617.42, keyboard and mouse, this PR's head
7c7bae93eon a copy of a save, Insert menu, Graphics tab, by hand. This build has no DLSS, FSR 4 or XeSS (only FSR 3.1), so the locks those give couldn't be shown here.upscalinglock).framegen_2x) only applies under DLSS Frame Generation, which this build doesn't have.Game-free, in WSL (Linux), against
mainde091ae29:settings_host.rs, run withcargo test -p api --lib a_lock_that_comes_and_goes. It drives the realsettings_host_stepandsettingsHost.rowson the fake renderer:e4bf89821withleft: "DLAA",right: ""and passes on the tested head7c7bae93e.caps()is changed back to a livelink::capabilities()read.caps_hashesnormally asks again at every call, so the window never applies. A#[cfg(test)]thread-local makes the window apply on the test's own thread, by its fake clock. It doesn't change the game's code.texts_reads_capabilities_once_across_all_valuestheFAKE_RENDERERlock, as the file's other tests that set the fake renderer already have. Run beside the new test, it saw the fake renderer change between two reads (1 suite run in 6); onmainalone it passed 8 of 8.cargo test -p api --lib: 651 passed, 1 failed, in 5 runs of 5. The failure issettings_push::tests::a_rows_dependencies_come_from_its_data, which fails onmaintoo (650 passed there); this change doesn't touch it.cargo clippy -p api --all-targets: nothing new. The warnings insettings_host.rsare older test lines.tests/run_all.py --strict: this PR 876 passed, 67 failed, 13 skipped;mainthe same 876/67/13. No file fails only here; the failures come from this machine's g++ 11 (no C++23) and lack of Vulkan. This ran at an earlier head; the current head also changessettings_host.rsandsettings/service.rs.tests/that readsettings_host.rs(test_menu_locked_button,test_menu_restart,test_menu_slider_ends,test_menu_text_field,test_microphone_test_gain): all passed at the tested head, unchanged.scripts/check_host_compile.py: 83 host units, 0 failed, on both sides.Still to test:
main(@Beanstalk)Measurements
Nothing to measure: the change makes rows read an answer the game already samples, so an available answer is reused for a quarter of a second instead of asking the renderer at each read (the existing tests count those calls).
Risks
Small. A row's renderer-derived state (lock, reason, ceiling, which choices can be picked, an Output resolution value's size) now shows up to 250 ms after the renderer changes, as the fact that resends it already did. Within that window a value the renderer has just made available can be refused, or one it has just withdrawn accepted, as the menu offered it. A revert is enough. Nothing changes in saves,
settings.tomlor the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZi9Np8FcHAzJs2LM9d
Tested in game: Windows 10 22H2, RTX 4090, NVIDIA 617.42, head
7c7bae93e, Insert menu > Graphics, by hand: Window scaling filter locks while the window is the Output resolution's size and unlocks otherwise (Fullscreen on/off); Frame generation's rows hide and show with the mode; Upscaler changes (FSR 3.1, built-in) followed by the rows. No DLSS/FSR 4/XeSS in this build, so their locks are in Still to test.Possibly related, for context:
WIP: fix(menu): a settings row is built from the same sample of the renderer as the fact that sends it again (#3277)to fix(menu): a settings row is built from the same sample of the renderer as the fact that sends it again (#3277)@review
Recommendation: Request changes. A device list can change while the menu still shows the cached list, causing a selection to save a different device from the one the player chose. The lock fix is demonstrated by the reported game-free test, but the remaining in-game DLSS check and CI are still pending.
The change builds menu rows and declarations from the same cached renderer capabilities used to decide when to refresh them. This prevents a transient lock from remaining on a row, at the cost of delaying capability changes by up to 250 ms and creating a mismatch with live device selection.
Blocking (1): must change before merging.
game/crates/api/src/services/settings_host.rs:693: The menu now displays cached device choices, but the settings codec resolves the selected index against the live device list. (more on the line) Do: Resolve a selection against the same capabilities snapshot that supplied its displayed choices, or detect a changed live list and reject or refresh the selection before saving it. Add a test that changes the device list between display and selection.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes: the reported fake-renderer test fails on the test commit against main with a lingering DLAA lock and passes at this head; it also fails when the live row read is restored. The reported Windows game run exercised other locks, but could not exercise DLSS.
Other systems: The sampled capabilities also supply output sizes, monitors, audio devices, GPUs, microphones, upscaler reasons and restart rules. The control bridge and settings codecs still read live capabilities; the latter can interpret a cached choice index as a different device. The reported Windows run covered fullscreen, frame-generation visibility and FSR 3.1; DLSS and Steam Deck or AMD runs remain outstanding.
Switches: None.
Reviewed:
7c7bae93e4againstde091ae295: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the applicable standards, the commit log and the settings_host.rs diff and surrounding implementation. Examined settings_push.rs, the control bridge, graphics declarations and settings codecs around their relevant paths. Skimmed existing tests and reported runs; did not read translations or generated files. docs/review-checklist.md and the adjacent Tooling AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during this read-only review. The author reports the new regression test passing, the same known suite failure on both branches, and a Windows in-game run; CI is still running.
Overlaps and merge order: Not checked; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -648,3 +691,3 @@) -> Vec<J> {let wanted = |key: &str, page: &str| keys.iter().any(|k| k == key) || pages.iter().any(|p| p == page);let caps = link::capabilities();let caps = caps();L1 (blocking): The menu now displays cached device choices, but the settings codec resolves the selected index against the live device list. A list change during the cache window can therefore save a different device from the one displayed.
When: For example, the cached audio output list contains devices A and B. If A disappears and the player selects the displayed A before the sample refreshes, set_service passes its index to the settings service, whose Device codec looks that index up in the live list and saves B's ID and name.
Do: Resolve a selection against the same capabilities snapshot that supplied its displayed choices, or detect a changed live list and reject or refresh the selection before saving it. Add a test that changes the device list between display and selection.
@fix
7c7bae93e440d2e466a6Recommendation: Approve. The code is ready: only testing is left. The fake-renderer test demonstrates the original stale-lock fix, and the reported Windows run exercises some affected rows. The DLSS lock and AMD or Steam Deck runs remain outstanding. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
40d2e466a6. I rebased it ontomain(8c0beeec5d). I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
Settings rows use the same sampled renderer capabilities as the fact that triggers updates, preventing a transient lock from remaining displayed. Device selections retain the capabilities used to declare their choices; the tradeoff is that renderer-derived changes can appear up to 250 ms later.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (3; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported stale-lock case: the described fake-renderer test fails on the test commit and passes on the tested head. The subsequent device-selection fix has not been run.
Other systems: The menu paths apply across Windows and Linux and renderer vendors. The reported Windows NVIDIA run covers several rows but lacks DLSS; AMD or Steam Deck coverage remains outstanding. Device selections also affect saved device IDs and names.
Switches: None.
Reviewed:
40d2e466a6against8c0beeec5d: Read the repository rules and pull request template, the fix diff, and the relevant settings host and settings service paths. The full base diff and all changed files were not read in full; recorded runs were read as reported evidence. The referenced Tooling repository was unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run code were executed. The author reports a passing stale-lock regression test and a Windows in-game run on the earlier tested head; the latest fix has not been tested.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -1696,1 +1771,3 @@} else if self.set_service(key, i64::from(v)) {} else if self.service_row(key).is_some_and(|r| {if matches!(r.native.choices_from.as_deref(), Some("audioOutputs" | "monitors" | "microphones" | "gpus")) {let sampled = self.settings_host.borrow().device_choices.get(&(cx.mod_id.clone(), key.to_owned())).cloned();L3 (should fix): Device rows reject even their built-in choices when no capabilities snapshot was available at declaration time.
When: If the renderer has not provided capabilities, the declaration still offers Default, Auto or Off, but device_choices has no entry and setting one of those values rejects with off_step.
Do: Allow built-in device choices without a capabilities snapshot, while continuing to require the displayed snapshot for choices that identify a listed device.
Tested on Windows 11 Pro (26300), RTX 5080, NVIDIA 621.47, head
40d2e466a, runtime over main8c0beeec5with DLSS, windowed 1280x720 on a 1920x1080 360 Hz display, Insert menu > Graphics (mouse, keyboard and the control bridge's option set):Seen once, not compared with main: system/menu faulted past its 5 ms frame-listener budget (5.1 ms, settingsHost.decls 3.3 ms) when Upscaler went to Game's own with DLSS FG running, during a swapchain rebuild (one 198 ms present). The menu kept working. Same family as #3230.
Also noted, likely not from this PR and not checked on main: with 8x saved, switching to DLSS FG leaves the multiplier row at 8x ("60 x 8 = 480 FPS") while DLSS FG makes up to 6x here.