Skip to content

Pipelines: a pass over the screen holds frames for its 10 s once in all, not every frame (map freeze, #3059) - #3788

Open
Lyrnc wants to merge 1 commit into
trustno1-coder:mainfrom
Lyrnc:fix/map-freeze
Open

Lyrnc wants to merge 1 commit into
trustno1-coder:mainfrom
Lyrnc:fix/map-freeze

Conversation

@Lyrnc

@Lyrnc Lyrnc commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Opening the in-game map freezes the game, with no crash (#3059 on v2026.11.29.03: RTX 5070 Ti + 9850X3D; "same" from a 5090 + 14900KF and from a third user). The logs are attachments and were not read. #3467 (zinixyt, RTX 3060, 32 GB, Series S, main 41adb55) measured the same screen in its text: "the map ran at about 10 seconds a frame", 42 quiet windows of over 5 s in 11 minutes, the six biggest 9.2 to 9.8 s. The line right after each window was:

INFO victory_gpu::pipeline::make: a pass over the screen was waited for (VICTORY_SCREEN_WAIT_MS=0: dropped pa[sses])

and the card was idle behind the CPU. #2822 (RTX 4090, 64 GB) lists "map stalls" with system commit exhaustion and memory-guard deferrals, gone with a larger page file.

Root cause

Read from the code and #3467's log line (#3059's logs were not read, so this is the likely cause, not a measured one). What the map does differently: it draws passes over the screen (full-screen graphics passes, Pending::screen) that the world has not drawn, so their pipelines are not made yet, and it draws them every frame while it is open.

crates/victory-gpu/src/pipeline/make.rs:

  • ready → wait(p, frame): a draw whose pipeline is not made waits for it. A pass over the screen gets screen_budget() (VICTORY_SCREEN_WAIT_MS, 10 s) per frame, others 500 ms per frame (wait_budget).
  • Nothing limits how many frames a pass waits its 10 s. One whose pipeline does not come within 10 s holds the next frame for 10 s again, and the next, for as long as it is not made. The code's own measurement (doc of screen_wait_once): "every screen wait that reached the 10 s budget ended without the pipeline (55 waits, 550 s) and 34 of the 43 waits after such a one ran out again". The only way out, VICTORY_SCREEN_WAIT_ONCE=1 (Pipelines: VICTORY_SCREEN_WAIT_ONCE=1 stops waiting for a pass over the screen whose wait ran out, until it is made (off by default) #1743), is off by default.
  • Why the pipeline may not come in 10 s, any of: the compile memory gate holds the worker (compilemem::begin: a pipeline worker waits up to 10 s to be let start, then the compile is put off), the memory guard puts it off (Pending::defer, retried 1 s later and put off again while commit stays low), or a long driver compile or a long queue.
  • The wait loop also does not end when the build it waits for is put off. make_with notifies DONE after defer(), the waiter wakes, sees made unset, and waits out the rest of its 10 s for a pipeline nothing will make during its pause.

So on the map every frame can take the screen's whole 10 s, which the player sees as a freeze. The title's 30 s watchdog does not end it (each frame is under 30 s, and it is told to quit).

Fix

wait (now wait_within(p, frame, screen_budget, draw_budget) so tests can pass small budgets):

  • A pass over the screen is waited for up to the screen's budget in all, over every frame that draws it, not in every frame. Pending::screen_waited_us counts what draws waited for it as a pass over the screen. A wait gets at most what is left of that allowance. Once it is used up and the pipeline is still not made, the pass waits as other draws do, within the frame's shared 500 ms, until it is made. Its first 10 s are unchanged, so a loading screen or a pass the title draws once still gets them. A line says when a pass has used its allowance (formats, shaders).
  • The wait ends when its build is put off (p.retry_waits() in the loop condition).
  • VICTORY_SCREEN_WAIT_EVERY_FRAME=1 gives back the old wait (the whole budget every frame). VICTORY_SCREEN_WAIT_ONCE=1 still drops such a pass at once.

With this, a map pass not made in time costs at most 10 s of waiting in all, then frames of 500 ms at most until it is made, instead of 10 s each.

Verification

Windows 11 26200, rustc 1.98.1 (the pinned toolchain), Ryzen 7 9800X3D. On 700a84f:

  • cargo check -j 6 --locked -p victory-gpu --all-targets: passes (victory-gpu's existing warnings only).
  • cargo test -j 6 --locked -p victory-gpu --lib pipeline::make::tests::: 32 passed, 0 failed. The two new ones:
    • a_pass_over_the_screen_holds_frames_for_its_budget_once_in_all: a pass over the screen that is never made, with budgets of 300 ms (screen) and 20 ms (others) in place of 10 s and 500 ms. The first frame waits at least 290 ms. The next four frames each return in under 150 ms (they wait as other draws do).
    • a_wait_ends_when_its_build_is_put_off: a screen draw waits with a 5 s budget on another thread. 50 ms later the build is put off for memory through make_with (the gate's own refuse_compile). The waiter returns in under 2 s, the pipeline is not recorded as refused, and only the time actually waited is charged to the pass.
    • The existing a_pipeline_whose_compile_was_put_off_for_memory_is_made_later and the other wait tests pass unchanged.
  • cargo clippy -j 6 --locked -p victory-gpu --all-targets: finishes with warnings only. None is on a line this adds (checked against git diff -U0 41adb551 700a84fd). The one in make.rs is main's (pop never used, l.1367).

NOT tested

Diagnostic to pin it (needs Selim's OK to read the attached play log of #3059, and of #3467 if zinixyt agrees):

  1. grep "a pass over the screen was waited for": for each line, ms, made, formats, shaders. The same shaders again and again with made=false is the case this fixes. A new shaders each time with made=true is the slow-compile case (Stop long freezes on pipeline compiles #2580).
  2. grep "memory guard: a compile is put off\|host pipeline not made: the PC is short of memory\|compile memory:" around those times: put-offs point at Stop waiting for deferred pipeline compiles #2188 / Memory guard: no black screen at 0.2 fps on 32 GB PCs (one compile at a time under the commit floor, refused pipelines made again, no 10 s screen waits) #3474 (and Memory guard: a pipeline put off again and again is made on a lower commit floor #2886), and a larger page file as the workaround (v2026.11.29.01 – System commit exhaustion, pipeline OOM errors, map stalls and runtime crashes mitigated by increasing pagefile #2822).
  3. In game (later, on our 5080, once runs are allowed): load a save on main, open the map, wait 60 s, then the same with this branch. Record the frame times from the log and the lines above. The same with VICTORY_COMMIT_FLOOR_MB=60000 to force the memory guard to put compiles off (it refuses every compile while free commit is under 60 GB), which reproduces the put-off case on any PC.

Exact repro steps for the reporters: start the game, load into the world, open the pause menu and the map, wait 60 s. Before: frames of 9 to 10 s (the title bar's fps goes to 0.1), the log line above every 10 s. After: at most one 10 s frame for each map pass, then the map moves again, possibly with a part of it missing until its pipeline is made, and a line "a pass over the screen waited for its whole budget in all".

Overlap

gh pr list --state open --search for "screen wait", "pass over the screen", "SCREEN_WAIT", "screen passes", "held frame" (2026-11-30). git merge-tree of this branch with each PR head: all four below merge cleanly with main alone, and each conflicts with this branch in make.rs's wait:

AI use

Claude Code (Claude Opus 5.5) read the issues' text (no attachments) and the pipeline code, wrote the change and its tests, ran the checks listed above, and wrote this note. Nothing was run in game.

🤖 Generated with Claude Code

…ll, not every frame

A draw of a pass over the screen whose pipeline is not made waits up to
VICTORY_SCREEN_WAIT_MS (10 s) for it, in every frame, for as long as it
is not made. A screen the title draws every frame (the pause menu's map)
whose pipeline did not come within 10 s (the compile memory gate holding
the worker, the memory guard putting the build off, a long compile or
queue) held every frame for the 10 s again: about 10 s a frame on the map,
seen as a freeze (trustno1-coder#3059; trustno1-coder#3467 measured it on main 41adb55, each 9 to
10 s gap followed by "a pass over the screen was waited for").

Now each pass has the screen's budget once in all (screen_waited_us);
after that it waits as other draws do, within the frame's shared 500 ms,
until it is made. Its first 10 s are as before. The wait also ends when
the memory guard puts its build off (nothing makes it during the pause);
it waited out the rest of its budget before.
VICTORY_SCREEN_WAIT_EVERY_FRAME=1: the whole budget every frame, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tyr0nsur

Copy link
Copy Markdown

I found a race in the per-pass allowance on 700a84f. wait_within reads screen_waited_us before taking the frame-budget mutex, and charges the pass after waiting. Two concurrent draws of the same pending pass can each book the last 100 ms, even with VICTORY_PIPELINE_WAIT_SHARED=1, when the shared frame budget has room for both.

The regression test starts with 400 ms charged against 500 ms, then holds the first caller at DONE after it books time. On this PR's head the second caller also enters the wait. With the follow-up, it returns immediately and the pass is charged exactly 500 ms total. The patch books per-pass time under the existing frame-budget lock and releases any unused reservation when the wait ends, including on memory deferral.

Cherry-pickable commit 1d2f2cc. All 33 pipeline::make::tests passed on Windows with 1 and 4 test threads (SCREEN_WAIT_EVERY_FRAME=0, SCREEN_WAIT_ONCE=0, PIPELINE_WAIT_SHARED=1, all with the VICTORY_ prefix). cargo xtask policy --staged passed. This exercises the wait loop in unit tests. Game impact remains unmeasured. Codex implemented and tested the change, with Claude Code assisting in the review of adjacent deferral behavior.

@dyshay

dyshay commented Nov 30, 2026

Copy link
Copy Markdown

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched code pass. A run on an RTX 4090 is queued. Frame times will follow here.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

The same repeated screen wait appears during launch and world entry on v2026.11.29.05.

Reporter and adapter Screen waits with made=false Most frequent shader-set repeats
#3940, RTX 5070 Ti 58 29 each for two sets
#3953, RTX 5080 110 29 each for two sets
#3956, RTX 3060 19 19 for one set

The recorded wait durations were 10,000 ms in 186 of the events and 9,998 ms in one. Every waited-on shader set in those logs matches an earlier E_OUTOFMEMORY refusal key in its own run. The diagnostic groups pipeline variants by shader hashes. The repeated-wait fix lets later frames advance while the pipeline is missing. The underlying driver refusals remain a separate issue.

I cherry-picked 700a84f then @tyr0nsur's 1d2f2cc onto release main 41adb551. Both applied cleanly. A native Windows test called the actual wait path for one pending screen pass on three successive frames, scaling the screen/draw budgets to 300/20 ms.

Build and setting Measured wall time per frame, ms
Release main, default policy 304, 310, 310
Release main, VICTORY_SCREEN_WAIT_ONCE=1 304, 0, 0
#3788, default policy 307, 31, 30
#3788, VICTORY_SCREEN_WAIT_EVERY_FRAME=1 303, 311, 309
#3788 + review commit, default policy 309, 30, 31

The reviewer's unchanged concurrent-booking test failed on 700a84f with "two waits booked the same remaining time". It passed with 1d2f2cc, including the assertion that 400 ms already charged plus the single 100 ms grant totals exactly 500 ms. The pipeline unit suite passed 30/30 on main, 32/32 on the PR, and 33/33 with the review commit with both one and four test threads. The review commit also checks release of the unused reservation on memory deferral.

Please include 1d2f2cc with its original Git author when updating this PR. The current Windows CI run stops at the existing victory-loader::unwind_copy unused-function lint before reaching the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants