fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tab #2214
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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!2214
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/held-image-fresh-swapchain"
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
With frame generation on, on an RX 9070 XT under Windows in fullscreen, the picture freezes after Alt+Tab while the game and its sound go on, until F11. The system keeps the image it shows until another one is shown on the window. Since #1458 an image not given back in 250 ms is held, and nothing else is presented, so nothing ever lets it go. #2083's remake didn't help: the reporter's nightly-745 log shows the new swapchain's first image held again at once. This PR's first version (a fresh swapchain, the one before destroyed first) made it worse: its destroy waited 12 s for the system, and the whole game stalled until F11 (log in a comment below). Both logs also show the hold can begin as the game comes back in front.
Now, while an image is held,
present_imageasks for one more (a timeout of 0, with a fence of its own) and shows it in the held one's place if it is free within 2 ms. The system then lets the held one go, and it's shown at a later present. One that isn't free is kept and looked at again at the next present, without waiting; at most two are held. #2083's remake stays, for when no image could be shown for its wait. New log line:vk: another of the window's images shown in place of the one not given back.Read first:
other_image,fence_freeandheld_otherbesideheld_image_dropingpu/vk/vk_replay.cpp, then the hold inpresent_image_with_trial(afterimage_free).See #1482 (to close once an AMD run shows the picture coming back). See #2083, #1458, #1376.
Testing
Tested: not in the game yet. The person I work for tests this head on AMD. The first version's in-game runs (RTX 5080, Windows 11) no longer apply.
Checks (not run on this PC for this head; CI runs them):
tests/test_present_held_image.py's engine keeps the image it shows until another is shown on the window, and a remake with the swapchain before handed over takes the held image over, as the logs show. It expects a frame within 100 ms of the window being seen again with an image held, and no remake. Broken variants: no remake, and no other image shown (main's behaviour).Still to test:
Windows, AMD RX 9000 or 7000, a build of this head: by hand.
Expecting the picture moving within about a second each time, never frozen until F11. In
logs/longshot_log.txt:not given back in 250 msfollowed byanother of the window's images shown in place of the one not given back, thenthe window's image was given back: frames are shown again, and no 12 s stall (the game read no controller).Windows, NVIDIA, the same steps: by hand. Expecting no change (no image is held there).
Linux: by hand. The held path is shared; with a driver that waits in its acquire nothing is held.
Measurements
Verdict: not measured yet: the new code runs only while an image is held, which this PC (NVIDIA) never reaches.
a2dc53855ddd9b45Risks
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (Not run on this PC for this head; CI.)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
Tested in game: Windows 11 (build 26300), NVIDIA GeForce RTX 5080, NVIDIA 621.24, 1920x1080 at 360 Hz. This PR @
74dd812eas a pack over main eee3e1d5's base, through the job queue with the control bridge: the castle-gate save (Hyrule Field, child Link), frame generation Auto (AMD FSR 3.1, 3 to 4 made frames a game frame), a 1280x720 window, then full screen through the Fullscreen row (F11's path), then a window again, walking. Presents went on at each stage (425, 510, 344), none stalled, shots show the scene moving, clean close. No image is held on NVIDIA, so the new remake did not run on its own; a local-only hook calling create_swapchain_fresh every 4 s made the swapchain fresh 16 times over the same steps (4 and 5 images in turn, window and full screen, across both Fullscreen changes) with presents going on and frame interpolation at 0 late frames. The AMD Windows path itself needs the Test Farm.@Beanstalk Windows with an AMD RX 9000 or 7000 card, and one NVIDIA RTX card: set frame generation on (FSR 3.1 frame generation first, then the built-in one), full screen, in Hyrule Field. Alt+Tab to another window for about 10 seconds and back, 5 times; then play 10 minutes in full screen without Alt+Tab. Check that the picture is moving again within about a second of coming back each time (on main the picture can stay frozen until F11 while the sound goes on). Post the log lines with "not given back", "the swapchain made again" and "a fresh swapchain", and say whether the picture ever froze, and for how long.
Beanstalk test farm
Commit
5ddd9b4· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in frontto WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in front@review
Recommendation: Request changes. The fresh remake works in the model and in forced NVIDIA remakes, but it has not yet been shown to recover the reported AMD freeze. The shared recovery path and the changed swapchain image count also need testing on the affected systems. (It stands on L3: The check
Guide screenshots / Guide images and local UI source review (pull_request)fails on this head and passes on the base branch: Failing after 15s.)The change destroys and recreates a swapchain when an acquired image remains held, and attempts recovery immediately when a Windows window returns to the foreground. It may restore a frozen picture without F11, at the cost of a device-idle wait and a potentially different swapchain image count.
@fixwill do (3)gpu/vk/vk_main.cpp:1179: Restore the usual image count after recovery if the fresh count is not needed for the remainder of the session.Guide screenshots / Guide images and local UI source review (pull_request)fails on this head and passes on the base branch: Failing after 15s.CI / Website build and checks (pull_request)fails on this head and passes on the base branch: Failing after 1m17s.Before merging: testing (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_main.cpp:1234: The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. (more on the line)gpu/vk/vk_main.cpp:1179: A recovered swapchain can retain a different image count for the rest of a session; one fewer image can reduce frame-generation presentation capacity, while one more consumes VRAM. (more on the line)More: does it help, other systems, switches, what was read
Does it help: Unproven for the reported bug. The model fails on main and passes here; on Windows with an RTX 5080, 16 forced fresh remakes continued presenting, but the driver did not reproduce the held image. No AMD run has established that the picture recovers.
Other systems: The held-image remake also runs on Linux and on other GPU vendors. NVIDIA Windows was exercised with forced remakes, but Linux, Steam Deck, and AMD Windows recovery remain untested. A changed image count can also affect frame-generation presentation capacity and VRAM after recovery.
Switches: None added, changed, or removed.
Reviewed:
74dd812e97againsta2dc538590: Read the repository rules, PR template, standards, commit messages, full diff, new header and test, changed test logic, and the swapchain and presentation code surrounding the changes. Skimmed the remaining portions of the large changed source and test files; the full changed files were not all read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent. No generated files or translations changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests, or project scripts were run. The PR reports a model test and Windows NVIDIA in-game runs; its AMD and Linux runs remain outstanding.
Overlaps and merge order: None found in the supplied review context.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -1166,6 +1176,10 @@ bool create_swapchain(uint32_t width, uint32_t height) {const uint32_t slots_made = (uint32_t)present_slots_for(swapchain_framegen(), fg_sets == 2);if (caps.maxImageCount) ci.minImageCount = std::min(ci.minImageCount, caps.maxImageCount);ci.imageFormat = fmt.format;// (#1482) fresh: another image count than the one before had, so the driver cannot hand its images on (swapchain_fresh.h)L2 (minor): A recovered swapchain can retain a different image count for the rest of a session; one fewer image can reduce frame-generation presentation capacity, while one more consumes VRAM. Measure frame pacing and VRAM after recovery against main on representative Tier 1 hardware, including Linux and Steam Deck, and verify ordinary presentation and recovery there.
@ -1217,1 +1231,4 @@VkSwapchainKHR sc;// (#1482) fresh: the one before let go first, the GPU idle and it destroyed, so nothing of it is handed over; the image// it held goes with it (present_image lets its fence go at the next present)if (swapchain_fresh && dev.swapchain) {L1 (minor): The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. Run the reported Alt+Tab reproduction on AMD Windows with both frame-generation methods and verify repeated recovery and subsequent play.
WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in frontto fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in frontOn the review:
scripts/check_guide_screenshots.py --review-sourcescompares the whole tree with the recorded review hashes, not the PR's diff. On main @a2dc5385, run here, it fails with the same 10 files,gpu/vk/vk_internal.hamong them (main changed it sincesettings-graphics.pngwas reviewed). This PR changes no UI, so it doesn't update the hashes; that needs a look at the settings screen.table/menu graphics coverage mismatch at Simulated turfcomes from main's Simulated turf row (#2093, #2174). #2213 fixes it. This PR touches neither the website nor the graphics settings.fresh_image_countasks for one image more than the swapchain before had. It asks for one fewer only when that count is already the surface's most (16 on the reported RX 9070 XT; 4 to 8 asked for here), so frame generation doesn't lose a spare image in practice. The extra image costs one image of video memory (about 8 MB at 1080p) until the next ordinary remake (F11, a resize, a V-Sync or frame generation change) asks for the usual count again. Putting the usual count back right after recovery would mean a second device-idle remake just as the picture comes back: a hitch the player sees, to save 8 MB. If a maintainer prefers that, it's a small change.fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in frontto WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in frontNot fixed, and worse: back to WIP. Please don't merge.
A log from this PR's own build (
pr-2214-74dd812e) on the reporter's setup (RX 9070 XT, AMD 26.10.1, Windows 11, FSR 3.1 frame generation at 2x, fullscreen) shows:the window's image was not given back in 250 msfollowshid: game window in frontdirectly. So the new "back in front" remake never ran: it only fires for a hold that began while the window was behind.... not given back in 1 s: the swapchain made again, fresh), and letting the swapchain before go blocked for about 12 s, with the queue's lock held. The recorder was blocked on that lock for 12113.94 ms,hid: the game read no controller for 12.1 s, the game presented 16 fps over 16.8 s, and the next frame was shown 12145.5 ms after the game handed it over.display: windowedis logged beforevk: a fresh swapchain: the one before (6 images) let go first, 7 images asked for. That line is written afterretire_swapchainreturns, so the destroy finished only once the window changed.On main the picture freezes while the game and its sound go on. With this PR the whole game stops until F11. That's a regression.
What it says about the cause: the idea behind this PR, that the driver hands the held image on to a remade swapchain of the same size, is wrong, or not what matters. The system keeps the image until something new is shown on the window, or the window itself changes (F11). No swapchain remake frees it, and destroying the swapchain only waits for the system to let it go. What's left, from this evidence:
Also seen: the hold can begin as the game comes back in front. A fix has to cover that case, not only a hold that began while the window was hidden.
The rest of BeanBot's review (the image count) and the Still to test steps are on hold until there's a direction that holds up against this log.
WIP: fix(vk): the held image's remake makes the swapchain fresh, and at once when the game is back in frontto WIP: fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+TabReworked after the AMD log above: the fresh swapchain is gone (it stalled the game 12 s). Now, while an image is held, another is asked for (timeout 0, its own fence) and shown in its place if free within 2 ms, so the system lets the held one go; #2083's remake stays for when none can be shown. The test's engine now keeps the shown image until another is shown. Not run in game yet: an AMD test of this head is next (steps in Still to test). BeanBot's points on the first version (image count, fresh remake) no longer apply: there is no fresh swapchain or changed image count now.
@review
Recommendation: Request changes. The fresh-swapchain approach and its lasting image-count change are gone. The replacement recovery still needs to be demonstrated on the affected AMD Windows setup. (It stands on L3: The check
Guide screenshots / Guide images and local UI source review (pull_request)fails on this head and passes on the base branch: Failing after 15s.)While a swapchain image is held, the change tries to present another image so the held one can be released. It avoids the former fresh-swapchain approach and its reported 12-second stall, at the cost of holding up to one additional image during recovery.
@fixwill do (2)Guide screenshots / Guide images and local UI source review (pull_request)fails on this head and passes on the base branch: Failing after 15s.CI / Website build and checks (pull_request)fails on this head and passes on the base branch: Failing after 1m17s.Before merging: testing (1) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_main.cpp:1234: The model assumes that a fresh swapchain releases the stuck image, but the reported AMD driver behavior has not been tested with this change. Run the reported Alt+Tab reproduction on AMD Windows with both frame-generation methods and verify repeated recovery and subsequent play.Since the last review (on
74dd812e97)Resolved: L2 (A recovered swapchain can retain a different image count for the rest of a session; one fe…)
Still open: L1 (The model assumes that a fresh swapchain releases the stuck image, but the reported AMD dr…); L3 (The check
Guide screenshots / Guide images and local UI source review (pull_request)fai…); L4 (The checkCI / Website build and checks (pull_request)fails on this head and passes on…)Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven. The reporter reproduced the freeze on an RX 9070 XT, but this head has not been tested in the game; the test models the proposed recovery.
Other systems: The held-image path is shared across Windows and Linux and can affect other GPU drivers and presentation modes. The earlier NVIDIA run tested a different implementation; this head has no reported in-game runs.
Switches: None added, changed or removed.
Reviewed:
5ddd9b4501againsta2dc538590: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the diff, and the changed test and thread documentation. Reviewed the presentation code around the changed helpers and their callers; the rest of the large replay file was skimmed.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The reported test model covers recovery by presenting another image; the affected AMD driver and this head remain untested in game.
Overlaps and merge order: None identified.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
WIP: fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+Tabto fix(vk): another image is shown in place of one the window does not give back, so the picture no longer freezes after Alt+TabClosing as it didn't work for the user at all. Will have to continue another time.
Pull request closed