Built-in system/mods-tab faults past its 5 ms longshot/ui flush budget (modsHost.tab) #3230
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot#3230
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Longshot version
longshot pr-3223-a725d2de (source 429d93ea)(based onmain @ 3a0f7d8f7).What happened
During an in-game playtest, the built-in
system/mods-tabmod faulted twice past its 5 ms CPU budget inlongshot/ui flushwhile callingmodsHost.tab:Hardware & OS
This looks like a valid bug report. I couldn't locate the cause in the code.
The reported faults are consistent with the code: the built-in Mods tab reads
modsHost.tabduring UI work, and later UI flushes have a 5 ms callback budget. The excerpts do not establish which work caused the overrun; the API call was only part of the reported time. I could not find an exact cause or verify the PR build's changes from this checkout.For maintainers
The log shows faults in
longshot/ui flushforsystem/mods-tab; no exact code cause has been established. Related open PR #3223 discussessystem/menufaults, not this reported mods-tab call.The checkout is at the reported main-branch base,
3a0f7d8f7; the reported PR source is a separate build, so its exact code could not be verified here. Blame attributes theuseHost(host.tab)call and flush dispatch tod984fd704(#2822). Investigate the complete flush, including host-value sharing and rendering, rather than attributing the overrun solely tomodsHost.tab.Seen in the code:
host.tabusinguseHostand subscribes to host changes.Possibly related, for context:
Automated triage by BeanBot (gpt-6-luna). Nothing was run; a maintainer decides.
Second report, on a Steam Deck LCD running plain
main(nightly-1118-3a0f7d8f, source429d93ea), launcher install at 1280x800, the game at 21-24 fps, no player mods (the profile's mods folder is empty, only the built-in system mods run).Both of the menu's system mods fault here, not only the Mods tab, and either one stopping gives the player the engine's fallback page.
system/mods-tab: seven faults in the session, 5.8 to 6.9 ms of CPU each. Every one is one or two host calls (modsHost.tab1.0 to 2.3 ms), no garbage collection, no kernel time, and 4.1 to 5.6 ms of the tab's own JavaScript. Three in a minute stopped it (stopped after 3 faults in a minute, line 116819 of the run's log); it started again by itself once and stopped for good at line 116955.system/menu: three faults inlongshot/game frame listenerat 5.9 ms, 52 API calls withsettingsHost.declson top (0.8 to 2.7 ms), 4.7 to 5.6 ms of its own JavaScript, then stopped (line 17982) and started again by itself once.Repro, one action: open the Insert menu's Mods tab, open the FPS counter's page, and change its level from "FPS" to "Dev". In order, in the log: the write fires
settingsHost.changedinsystem/menu(it re-lays out every tab, 34 major page faults paging in the rows), the Mods tab takes the onlystateChangedre-read of the whole run (3.1 ms of CPU, 12.1 ms on the wall clock, 261 major page faults),the mods' scripts ran 7.3 ms of CPU together in one frame, and the counter then runs 2.1 to 2.9 ms of script CPU every frame for the rest of the session (no such warning anywhere before the change, 370 after). About 30 seconds later the Mods tab is over its 5 ms three times and stopped. The counter itself never faults.Cadence: that burst sits between the present markers at frames 389800, 389912 and 390020, so this is not one 6 ms flush at every frame. One heavy repaint overruns the 5 ms, its render is deferred (
defer(f)ingame/modapi/ui/runtime.js), and the flushes that try to finish it overrun the same 5 ms: three insideFAULT_WINDOW_NSand the mod is stopped. The paging around it is logged separately and never counted, so the overrun is real CPU work.One lead on the host side, read at
3a0f7d8f7and not measured yet:mods_tab_json()reuses itsTabMemoonly wheneffects == m.effects, and every effect entry carriesgpuMs.gpu/vk/vk_effects.cppfills that from a moving average (f.gpu_ms = ef.samples ? ef.avg_us / 1000.0 : 0.0) thatfx_poll()refreshes each frame. With any live effect (this run hasvk: sharpness: 10% on the 3D scene before the HUD, 1280x800, B10G11R11) the average moves every frame, so while the tab is shown the memo cannot hit:mods_host_steprebuilds the whole tab JSON each frame, and eachmodsHost.tab()hands the script a fresh tree whose effects differ, soshareValueshares nothing and the rows render again. Keeping the live per-effect numbers out of the memoized answer, or comparing withoutgpuMs, or reading them only while a mod's page is open, is where I would look first. The other half is the part the render slice cannot interrupt: one component's render plus the tree diff, which is over 5 ms on this hardware on its own.Related: #3223 covers the
system/menuhalf, and the 5.9 mssettingsHost.declsfaults in this log match its signature. It does not touch the Mods tab path, and since either mod stopping shows the fallback page, both halves need fixing. #3229 is the same reporter's row-disappearing bug seen on a #3223 build withsystem/menuat zero faults.Log lines quoted above are from
builds/default/diagnostics/logs/longshot_log.txtof the launcher's install; no game files are attached.Measurements from a Deck after the report above, plus one correction to my first comment.
Correction. I wrote that the menu rebuilds on every frame. It does not. With
HOS_EVENT_STATS=1, 3600 frames with the Insert menu open logged:So the menu lays out about a dozen times a minute. The problem is not the frequency, it is that one pass costs 5 to 6 ms on this CPU.
What one pass costs here (Steam Deck LCD, gameplay at 25-31 fps,
nightly-1118and a dev build of its parent3a0f7d8f): thesystem/menuframe listener runs 52 API calls (0.9-1.6 ms) and 4.1-5.6 ms of its own JavaScript, 5.1-5.9 ms of CPU per pass.system/mods-tab'slongshot/ui flushis 5.1-6.9 ms of CPU per pass, of which 4.5-5.0 ms is its own JavaScript and 1.0-2.3 ms is one or twomodsHost.tabcalls. Those numbers held across ten runs on two builds.The structural point. These are Longshot's own built-in system mods, and the budget that stops them was written for third-party code: 5 ms a callback, three faults in a minute stops the mod for the session. For a player mod that is right. For the menu it converts "slow" into "the whole Insert menu is replaced by the fallback page", which is what the screenshot at the top of this issue shows, and on Deck-class hardware one ordinary layout pass is already at the limit.
What could land first, smallest change first.
game/crates/script/src/runtime.rs'sfault()already branches onself.systemfor the log wording; the stop is a few lines below it. The 500 msOVERRUN_STOP_NSstop (runtime.rs:799-816) is a separate path and stays as the guard against a real freeze, so a built-in mod that hangs is still stopped at once. This turns a dead menu into a slow menu on hardware where it is 1 ms over, and it does not change anything for third-party mods.limits.rssays these numbers are the Mod API spec's, so a carve-out for built-ins is a spec decision, not a code one; I am putting it here because it is the only change that removes the player-visible failure today.settingsHost.decls2.1 down to 1.5-1.6 ms, pass 5.5-5.9 down to about 5.1), which is real and not enough on its own.modsHost.tabhands the script a fresh tree per read, andmods_tab_json()'s memo requires the effects list to be equal, includinggpuMs, whichvk_effects.cppfills from a live moving average. If the effects change every frame the memo cannot hit. I have not yet got the Mods tab hosted in a run to measure itsstateChangedrate, so that one stays inferred; the numbers above are measured and are enough to say that even one repaint of the tab is over budget here.Logs and the two dev runtimes are on the Deck if anyone wants them.
I am taking the remaining Deck reproduction through a fix: repeated FPS counter level changes and supported Upscaler changes must leave both system/menu and system/mods-tab running. #3223 removes one declarations invalidation but did not clear that acceptance test here. Investigating the large snapshot conversion/sharing and synchronous layout work under the normal callback budget; not changing the budget or exempting system mods. Prior work checked: #3098, #3223, #3208, #3234 and #3238; no existing PR covers both remaining fault paths.
Cause narrowed on a Steam Deck, and it is not the read. Summary from tonight's runs, so the next attempt starts in the right place.
What I tried. I split a page's build in
game/modapi/settings-host/store.tsinto three frames (declarations read, then laid out, then its rows read) so that no frame both reads a page's declarations and writes every heading's word. On the Deck, both arms of the acceptance test (Upscaler changed 18 times with the real menu keys; FPS counter's level the same) were run on a build with that change and on the base build, each arm its own run.3a0f7d8f7)system/menufaults, 2 stopsSo the split does not fix the Upscaler arm. The fault lines it produced are the useful part:
With the read in an earlier frame the API is 0.1-0.2 ms and 51
i18n.tcalls cost 0.0 ms. The remaining 5.5 ms is one page's render, all of it the menu's own JavaScript. On the base the same frame also carried the read (API 1.4-1.9 ms), which is why it looked like a read problem.Why the slice does not save it.
game/modapi/ui/runtime.jsstops a flush between components once the frame has spent 0.5 ms (overSlice,SLICE_CPU_MS), but a page is drawn depth-first inside one component's render (SettingsPage->PageRows-> itsSections andRowLines): the slice never gets a turn until the page is whole. One page of the Graphics tab is 5.5 ms of script on this CPU, so it lands past the 5 ms a callback may on its own, three of those in a minute stopsystem/menu, and the fallback page is what the player sees.What would fix it (both are menu or engine changes, not a store one):
overSlicecan cut a page's render the way it cuts between roots.I have the patch for the three-frame split (it is a small, measured improvement in the read frame, just not a fix) and the run logs if either is wanted; I did not open a pull request for it, because it does not clear the complaint it was written for.
I also withdraw the carve-out I proposed earlier (system mods kept out of the three-fault stop): it hides the fault instead of making the work fit, and the measurement above shows the work is a single page render, not an unlucky threshold.
Numbers for current
mainon a Steam Deck LCD, and which of these reports the merged #3223 actually answers.Setup: a Steam Deck LCD (SteamOS 20261023.100, kernel 7.2.7-valve2-2-neptune, RDNA3 APU), the base pack
3a0f7d8f7withtwo packs over it -
rt-curmain(main6b1694a, #3223 in) andrt-nofix(the same main with #3223's own merge diffreverse-applied). Insert menu open on the Graphics page at 1280x800 windowed in Kokiri Forest, real
menu_keypresses,the row re-found after each one, every change confirmed by
option_get, and the game's own log lines counted. Runs at$SD/longshot-dev/menu-cycle-runs/cm-*on that Deck, logcm.log.So at this
main, neither arm stopssystem/menuany more, with or without #3223. What #3223 measured wasmainat7bc53f841: there the Upscaler cycle faulted 6 times and stoppedsystem/menuin two runs out of two, the walk diedwith
row not found: Upscalerbecause the rows had gone, and the same cycle with its fix landed all 18 changes with 2and 1 faults and no stop.
mainhas moved a long way since then - #3208 took the Insert menu's logic out of therenderer and #3234 cut the work the frame's status did - and at current
mainthe menu's own listener is no longerover budget by enough to stop on its own.
What does stop, on the same Upscaler arm, is
system/mods-tab:Three of those in a minute stopped it in that run, and the same shape came back on the Frame gen. multiplier arm (6
fault lines,
modsHost.tab2.6-3.0 ms, one stop). So a player on this hardware can still get the fallback page aftercycling Graphics rows - it is the Mods tab's mod dying, not
system/menu, and the rows stay.Read on the fake game (
longshot-builder mod test game/mods/menu, current main,cpuScale 2.74), the FPS-counter paththis thread started on costs nothing now: one step of
fps_countercosts 0.856 ms of script CPU in the frame afterthe change and nothing in the frames after that, which is what flipping V-Sync costs too (0.835 ms, 0.831 ms, 0.842 ms). What is left on the menu's side is its frame listener at 5.5 ms in the same
frames as the Mods tab's read.
Claimed next: where the ~3 ms in one
modsHost.tabcall goes. Ingame/crates/api/src/services/mods_host.rsmods_tab_json, the memo is thrown away whenever any mod page's screen effects moved (effects_all), and then the wholetab is built again and copied and converted twice over (
base.clone(), thenJson::from_value). I have not measuredwhich of those three the 3 ms is yet; I will post that before proposing a change.