WIP: fix(host): closing the game waits for a save it is writing #1422
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1422
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:fix/close-waits-for-save"
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?
Type: fix · Risk: low · Tested on: Linux, game-free only · Needs: any PC, closing the game while it saves, in the game
Why
nn::fs::Commitdoes nothing here, so a save goes straight into its files. Every close (the window, the control bridge's quit, the Windows stop worker) runshos_close_finishand ends the process without waiting for a file the game is writing; the log even saysstop: close work done (the game's saves are not waited for). Closing the window during a save could cut the save file short. Hookshot's issue 32 was that report.Ported from Hookshot
7d22d4fb(pixl27):git.notrexed.dev/Hookshot/Hookshot@7d22d4fb9dThe tracker was searched for "saves are not waited", "save in progress" and
hos_close_finish: no pull request or issue is this fix. The issues that match only quote the close line in their logs; #102 added the windowless stop this now waits in.How to reproduce
Seen on: Hookshot's report. Not run on Longshot.
Settings and switches: defaults.
Steps: save in the game and close the window while the save is being written.
Expected: the save is whole on the next start.
Actual: on main the process exits at once, whatever the game is writing.
What changed
host/nn_fs.ccounts the files open for writing and when one was last written (WriteFile, before and after;SetFileSize).hos_fs_wait_writeswaits, 10 ms at a time and at most 3 s, while a file is open for writing and was written in the last second, and logsstop: the game was writing a file: waited N ms for itwhen it waited.hos_close_finishcalls it first, so all three closes wait. The game's threads go on meanwhile.host/nn_fs.c,host/hos_relaunch.c(the close line now readsstop: close work done (a file the game was writing waited for, at most 3 s)).tests/test_close_waits_for_save.py(new) compiles the wait with a made-up clock and reads the four fs calls.tests/test_windows_stop.py,tests/crash_record_test.candtests/test_vcore_fs_open.pyget a stand-in for the new names;tests/windows_stop_test.cquotes the new close line.docs/development.mdnames the new line and counts the wait against an OS-ending event's four seconds.Measurements
Verdict: the game-free check fails before the fix and passes here. Nothing in the game has been measured.
Hardware: Linux, no game run.
Scene: none.
Method:
python -I -B tests/test_close_waits_for_save.pyon the test commit and on this head.How to reproduce: check out
11345ca0(the test alone, on main544229a2) and run the command; then this head.544229a2plus the test @11345ca026daec6etests/test_close_waits_for_save.pypython -I -B tests/run_all.pyon this head (Linux, 16 at once): 603 passed, 38 failed, 81 skipped (no Vulkan or SPIR-V headers here). The failures are the onesmain544229a2has on this PC, excepttests/test_perf_report.py, which failed under the full run's load and passes alone on this head and onmain.Flags and settings
None: no switch. The wait is at most 3 s, and only while the game wrote a file in the last second.
Testing
Tested: Linux, game-free. The new check, and the checks that compile
hos_close_finish,OpenFileor readnn_fs.c(test_windows_stop,test_crash_record,test_vcore_fs_open,test_fs_links,test_fs_path_utf8,test_guest_copies,test_longshot_saves,test_options_path,test_menu_restart,test_quit_not_crash,test_longshot_ctl).Not tested: the game, Windows, a host build (
a64_suyu.his not on this PC). Opened with--forcebecause Joey asked; this PC is not running the game.Must be tested:
stop: the game was writing a file: waited N ms for itwhen the close came during a write. A close with nothing being written shows no wait. Test Farm: @Beanstalk save and close the window right after, Windows and Linux, expecting the save to load next start.Risks
What could break: a close can take up to 3 s longer when a file was written in the last second. A game that keeps a file open for writing and writes it all the time would always wait the full 3 s. On a Windows logoff or shutdown the wait comes out of the four-second budget after
rx_close_asked, so a slow pipeline-cache save plus a game write could reach the deadline (exit 124), which today would also cut the write.Turning it off: none as a switch; reverting the commit restores the immediate exit.
Compatibility: nothing in saves or options.
MKWVK_API_VERSIONis unchanged.Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why. Not ticked yet: Testing's Tested is game-free only and says the game was not run, though host/ is a game file.
in Risks. Not ticked yet: Risks says a close can take up to 3 s longer, and Measurements shows no close time measured.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named). The 38 failures fail onmainhere too;test_perf_reportfailed only under load.third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.tests/that reads changed source updated in this PR, not weakened.-Wall -Wextra -Werror, and it uses only__atomicbuiltins, which both compilers have.@Beanstalk Windows and Linux, any GPU: from a new save, save in the game, then close the window right after the save starts, several runs; start again each time. Expected: the save loads on the next start, and when the close came during a write the log has
stop: the game was writing a file: waited N ms for it(at most 3000 ms). A close with nothing being written shows no wait and closes as fast as main. Not run in the game yet; Joey asked for this pull request so the farm can take that run.@TrashPanda only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.Possibly related, for context:
Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
**Not testable by hand:**line saying why and what stands in for it. Then tick it.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.