a menu row can keep a lock reason the renderer no longer has: the row reads capabilities live, the fact that resends it is a 250 ms sample #3277

Closed
opened 2026-12-05 20:08:14 +00:00 by omgitsgela · 2 comments
Member

A row's caps-derived state is read from the renderer live, while the fact that decides whether to send it again is a sample up to 250 ms old. A caps state that appears and goes away inside one window is therefore displayed and never taken back.

Found while reviewing #3223, not in the game. Nothing here contradicts that change: it is about the window #3208 put around the caps read (#3208).

The two sides, on main

The row's own content asks the renderer each time it is built:

  • game/crates/api/src/services/settings_host.rs:650: let caps = link::capabilities(); in the row build
  • :878 the locked text, :847 an upscaler choice's why, :552 the slider's ceiling, :581 what is pickable, :892 a choice row's option count

The fact that re-sends watched rows is a cached sample:

  • :1357: f[Fact::CapsState as usize] = caps_hashes().1
  • :215-227: caps_hashes() keeps the renderer's answer for CAPS_EVERY_NS, :257: 250_000_000
  • game/crates/api/src/services/settings_push.rs:269: moved.contains(&Fact::CapsState) is what dirties every watched row
  • :211-219: watch remembers the row's json exactly as it was read

What that difference allows

Sample 1 takes state A. The renderer moves to B. A mod reads a row: it is built with B (live), and watch remembers B's json. The renderer returns to A. Sample 2 takes state A, so Fact::CapsState did not move, the row is not dirty, and nothing is sent: the row keeps B's lock text, or B's hint, or a ceiling from B, until some unrelated fact moves. No setting is involved, so nothing else corrects it either: a settings change marks its own row and its dependents through deps (settings_push.rs:271-273), which is why this only bites a caps state that changes without a setting change.

The sampling window itself is not wrong; it is what stopped fill_capabilities hashing every list on the main thread at every frame. The mismatch is that the row and the fact are read at different times.

What I have not established

No instance seen in the game, and I could not look for one where it is easiest: dlss_fg_most and the vendor upscalers are all off on an AMD Deck. It needs a caps state that moves without moving a setting or one of the lists (:242-250 hashes the counts and contents of sizes, monitors, gpus, langs, ids, reshade files, outputs, mics, aspects and nfc tags), and I did not find one: the case is that the code permits a read between two samples, and the review of #3223 raised it. Treat the consequence as "the code allows this", not "a player reported this".

Shape of a fix, if the shape is right

caps_hashes() keeps the snapshot along with its two hashes, and the row build reads that snapshot instead of calling link::capabilities() again: a row's state and the fact that re-sends it then come from the same renderer answer, and the window only costs staleness (a change seen up to 250 ms late), never a state no sample ever made. That also lowers the number of capabilities() calls per pass, which two existing tests already hold down ("expected <= 1 capabilities() call for 51 textWhen values", settings_host.rs:2539, and :2553), so it goes with the grain of the code rather than against it.

A game-free test that would pin it, on the fake renderer: set the caps state to B, read a watched row (it takes B), set it back to A, tick past one window, and assert the row is pushed again with A's lock text. Today the two samples are both A, moved does not contain Fact::CapsState, and nothing is sent.

Happy to write that test against main and see what it says, or to leave it to whoever owns the caps path.

A row's caps-derived state is read from the renderer live, while the fact that decides whether to send it again is a sample up to 250 ms old. A caps state that appears and goes away inside one window is therefore displayed and never taken back. Found while reviewing https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3223, not in the game. Nothing here contradicts that change: it is about the window #3208 put around the caps read (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/3208). ## The two sides, on main The row's own content asks the renderer each time it is built: - `game/crates/api/src/services/settings_host.rs:650`: `let caps = link::capabilities();` in the row build - `:878` the `locked` text, `:847` an upscaler choice's why, `:552` the slider's ceiling, `:581` what is pickable, `:892` a choice row's option count The fact that re-sends watched rows is a cached sample: - `:1357`: `f[Fact::CapsState as usize] = caps_hashes().1` - `:215-227`: `caps_hashes()` keeps the renderer's answer for `CAPS_EVERY_NS`, `:257`: 250_000_000 - `game/crates/api/src/services/settings_push.rs:269`: `moved.contains(&Fact::CapsState)` is what dirties every watched row - `:211-219`: `watch` remembers the row's json exactly as it was read ## What that difference allows Sample 1 takes state A. The renderer moves to B. A mod reads a row: it is built with B (live), and `watch` remembers B's json. The renderer returns to A. Sample 2 takes state A, so `Fact::CapsState` did not move, the row is not dirty, and nothing is sent: the row keeps B's lock text, or B's hint, or a ceiling from B, until some unrelated fact moves. No setting is involved, so nothing else corrects it either: a settings change marks its own row and its dependents through `deps` (`settings_push.rs:271-273`), which is why this only bites a caps state that changes without a setting change. The sampling window itself is not wrong; it is what stopped `fill_capabilities` hashing every list on the main thread at every frame. The mismatch is that the row and the fact are read at different times. ## What I have not established No instance seen in the game, and I could not look for one where it is easiest: `dlss_fg_most` and the vendor upscalers are all off on an AMD Deck. It needs a caps state that moves without moving a setting or one of the lists (`:242-250` hashes the counts and contents of sizes, monitors, gpus, langs, ids, reshade files, outputs, mics, aspects and nfc tags), and I did not find one: the case is that the code permits a read between two samples, and the review of #3223 raised it. Treat the consequence as "the code allows this", not "a player reported this". ## Shape of a fix, if the shape is right `caps_hashes()` keeps the snapshot along with its two hashes, and the row build reads that snapshot instead of calling `link::capabilities()` again: a row's state and the fact that re-sends it then come from the same renderer answer, and the window only costs staleness (a change seen up to 250 ms late), never a state no sample ever made. That also lowers the number of `capabilities()` calls per pass, which two existing tests already hold down ("expected <= 1 capabilities() call for 51 textWhen values", `settings_host.rs:2539`, and `:2553`), so it goes with the grain of the code rather than against it. A game-free test that would pin it, on the fake renderer: set the caps state to B, read a watched row (it takes B), set it back to A, tick past one window, and assert the row is pushed again with A's lock text. Today the two samples are both A, `moved` does not contain `Fact::CapsState`, and nothing is sent. Happy to write that test against main and see what it says, or to leave it to whoever owns the caps path.
Contributor

@omgitsgela I'd like to take this one, unless you've already started on the test: say so and I'll step back.

Plan, as the issue lays it out: first a game-free test on the fake renderer (caps state B, read a watched row, back to A, tick past CAPS_EVERY_NS, expect the row pushed again with A's text), checked to fail on main. Then the fix: caps_hashes() keeps the snapshot with its two hashes, and the row build in settings_host.rs reads that snapshot instead of calling link::capabilities() again. The existing "<= 1 capabilities() call" tests stay green. Then a run in the game on an RTX 4090 (Windows): the Graphics tab's DLSS / frame generation rows still lock and unlock as the renderer changes.

@omgitsgela I'd like to take this one, unless you've already started on the test: say so and I'll step back. Plan, as the issue lays it out: first a game-free test on the fake renderer (caps state B, read a watched row, back to A, tick past `CAPS_EVERY_NS`, expect the row pushed again with A's text), checked to fail on main. Then the fix: `caps_hashes()` keeps the snapshot with its two hashes, and the row build in `settings_host.rs` reads that snapshot instead of calling `link::capabilities()` again. The existing "<= 1 capabilities() call" tests stay green. Then a run in the game on an RTX 4090 (Windows): the Graphics tab's DLSS / frame generation rows still lock and unlock as the renderer changes.
Author
Member

Go ahead, I have not started it, and nothing of mine touches this: my two changes today were #3223 and #3275, and this one only came out of the review I ran over the first of them.

Things that may save you a search, all verified on main at 688d47e:

  • The live reads are spread wider than the lock text. Row build: settings_host.rs:650 (let caps = link::capabilities();); then :878 the locked text, :847 an upscaler choice's why, :552 top_in for the ceiling, :581 not_pickable, :892 the option count. And elsewhere in the same file :385 list_choices, :936, :1057, :1470 each ask again. So a snapshot threaded through one pass has more than one caller to catch.
  • The two capabilities() count tests you want to stay green are :2539 (51 textWhen values, <= 1 call) and :2553 (4 choicesFrom values, <= 1 call), so the code already leans your way.
  • The sampled side: caps_hashes() :215-227 with KEPT: Mutex<(i64, u64, i64)> (the stamp, the lists hash, the state hash), CAPS_EVERY_NS :257, used at :1357, where Fact::CapsState is set, and consumed at settings_push.rs:269, where it dirties every watched row; watch at :211-219 is what remembers the json to compare against. Holding the snapshot means the KEPT tuple grows by a LsCapabilities, which is the part I would have wanted a maintainer's eye on: it is a C-shaped struct (game/crates/host-sys/src/settings_link.rs:130-175), fixed-size arrays, so it should be cheap to keep, but I have not tried it.
  • One thing worth deciding early: the fake renderer path. caps_hashes() re-asks every call when host_sys::FAKE, and the tests set caps fields per test (renderer_reasons.rs:84, settings_host.rs:2211), so a cache that also feeds the row build could make existing tests see a stale snapshot. That is probably where a first attempt fails, and it is a good place to design rather than debug.
  • Hardware: a Steam Deck cannot show any of it (no NVIDIA runtime, every vendor upscaler off), so your RTX 4090 run is the useful one. If it helps, the row I would watch is Graphics, frame_generation / frame_generation_by and the multiplier, since that is where dlss_fg_most and the lock both move; and I can run a pinned test request of yours on a Deck LCD afterwards if a no-change-from-main check is worth having.

Shout if you want the Deck side of anything, and it is yours otherwise.

Go ahead, I have not started it, and nothing of mine touches this: my two changes today were #3223 and #3275, and this one only came out of the review I ran over the first of them. Things that may save you a search, all verified on main at `688d47e`: - The live reads are spread wider than the lock text. Row build: `settings_host.rs:650` (`let caps = link::capabilities();`); then `:878` the `locked` text, `:847` an upscaler choice's why, `:552` `top_in` for the ceiling, `:581` `not_pickable`, `:892` the option count. And elsewhere in the same file `:385` `list_choices`, `:936`, `:1057`, `:1470` each ask again. So a snapshot threaded through one pass has more than one caller to catch. - The two `capabilities()` count tests you want to stay green are `:2539` (51 `textWhen` values, <= 1 call) and `:2553` (4 `choicesFrom` values, <= 1 call), so the code already leans your way. - The sampled side: `caps_hashes()` `:215-227` with `KEPT: Mutex<(i64, u64, i64)>` (the stamp, the lists hash, the state hash), `CAPS_EVERY_NS` `:257`, used at `:1357`, where `Fact::CapsState` is set, and consumed at `settings_push.rs:269`, where it dirties every watched row; `watch` at `:211-219` is what remembers the json to compare against. Holding the snapshot means the `KEPT` tuple grows by a `LsCapabilities`, which is the part I would have wanted a maintainer's eye on: it is a C-shaped struct (`game/crates/host-sys/src/settings_link.rs:130-175`), fixed-size arrays, so it should be cheap to keep, but I have not tried it. - One thing worth deciding early: the fake renderer path. `caps_hashes()` re-asks every call when `host_sys::FAKE`, and the tests set caps fields per test (`renderer_reasons.rs:84`, `settings_host.rs:2211`), so a cache that also feeds the row build could make existing tests see a stale snapshot. That is probably where a first attempt fails, and it is a good place to design rather than debug. - Hardware: a Steam Deck cannot show any of it (no NVIDIA runtime, every vendor upscaler off), so your RTX 4090 run is the useful one. If it helps, the row I would watch is Graphics, `frame_generation` / `frame_generation_by` and the multiplier, since that is where `dlss_fg_most` and the lock both move; and I can run a pinned test request of yours on a Deck LCD afterwards if a no-change-from-main check is worth having. Shout if you want the Deck side of anything, and it is yours otherwise.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot#3277
No description provided.