fix(host): Restart now starts the game again on Windows when longshot-builder started it #2884
No reviewers
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2884
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/restart-now-through-builder"
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
On Windows, the Insert menu's Restart now (after changing a setting that needs a restart) closes the game and nothing
comes back, for any game
longshot-builder playstarted: the Launcher's Play, a desktop shortcut, a Steam tile. Aplayer reported it on nightly 951; it has been so since the hand-over arrived with #2286 (nightly 806). Linux and the
Deck are not affected.
On main: play a nightly from the Launcher on Windows, change Output resolution (or any row that needs a restart),
close the menu and choose Restart now. The window closes and the game never starts again; its log ends with
display: window closed for a restart, and no new run's log follows.Why: the game restarts itself (
host/hos_relaunch.c): a new process, the same command line, the environment it wasstarted with. But
bc_claimtakesLONGSHOT_BUILDER_CHANNELout of the environment at the start, beforehos_relaunch_keep_envkeeps it, so the copy has no channel. A game in a version folder'sbuilds/<build>/with nochannel hands over to the builder two folders up (
host/longshot_exit.h): the copy startsLongshot.exe playand exitsat once, and that builder stops at the profile the first builder still holds (
single.rs; the first is still in itsafter-game work for about 9 s). A process trace of nightly 951 started as the Launcher's window starts it: the new
game started
Longshot.exe17 ms after its own start and ended; thatLongshot.exeended 48 ms later; the firstbuilder exited 0; nothing was left running.
This PR: a Windows game the builder started (it has the builder's channel:
bc_given, new inhost/builder_channel.c) starts nothing at Restart now. It exits with 75 (HOS_RESTART_EXIT,host/hos_relaunch.h), and the builder that started it, which is waiting for it with the profile held, starts it againwith the same arguments (
build_driver::play::GAME_RESTART_STATUS), building first only when the game had also askedfor a build (
restart_to_apply). The Launcher, the profile lock and the crash watch keep the new game, as they do afterrestart_to_apply. A game no builder started (a developer's folder, a test's) and every game on Linux (execve, thesame process) restart as before. The control bridge's
relaunchtakes the same path.Read first:
relaunch()andhos_window_closed_exitinhost/hos_relaunch.c, then the loop inbuilder/crates/build-driver/src/play.rs'splay.Prior work: none found for this (open and closed pull requests and issues on Longshot and the Launcher: "restart now",
"relaunch", "hand-over"). #2741 changed the restart's standard handles and log; its launcher run was still to test.
#2807 (open) touches the same exit path for DLSS 5.
Testing
Tested: Windows 11 (26300), RTX 5080, NVIDIA 621.40.
the Launcher's (
Longshot.exe, this branch's builder, besidebuilds/default/), started as the Launcher's windowstarts it (
Longshot.exe play --profile <p> --output json), Restart now through the control bridge'srelaunch(thesame
hos_window_closed_exitas the menu's button), thenquit. The game loggedrestart: the builder that started the game starts it again (exit status 75); the same builder started the game again 20 ms after the first ended(
play_plan,game_starting,game_startedagain on its stream), the bridge answered again after 1.1 s, the newgame presented 300 frames,
quitended it and the builder exited 0. No otherLongshot.exewas started.--output user, as a desktop shortcut and a Steam tile start the builder (the Steam tile starts theLauncher with
--play, which runs it so): the same builder started the game again 26 ms after the first ended, thebridge answered again after 1.8 s, no other
Longshot.exestarted (so no "already running" box),quitended it.a test profile playing it), through the job queue, Restart now from the game's own menu (F1, Output resolution
changed, the menu closed, Restart Now at "Restart to apply Output resolution?"):
menu: restart now, to apply Output resolutionandrestart: the builder that started the game starts it again (exit status 75); the same builder (same process)under the same Launcher started a new game at once, which opened at the new Output resolution. The Launcher's
stream showed
game_starting,game_startedandgame_readyagain in the same session, and its Home page wasback on Ready to play once the game was closed.
LongshotLauncher.exe --play <version> --profile <folder>(what the Launcher's desktopshortcuts and Steam tiles run): the same, the new game at the new Output resolution (saved in the profile's
settings.ini), no otherLongshot.exeand no "already running" box; the Launcher exited 0 after the game wasclosed.
cannot make, and it played the game it had, as
play_anywaydoes. Both starts ran this branch's builder and game.)28cb22b9) as the Launcher installed it: the hand-over above, nothing came back.tests/test_restart_by_builder.py(new: the Windows restart and the window's close cut fromhost/hos_relaunch.c,compiled with stand-ins for the Win32 calls; a game the builder started starts nothing and exits with the builder's
status, any other restarts itself and exits 0, a plain close starts nothing): fails on main ("started by a builder,
Restart now started 1 program(s) and exited 0"), passes here with gcc and clang, on Windows and Linux; with the fix's
bc_given()test undone it fails again.build-driver's new unit testa_game_that_restarts_itself_through_the_builder_is_started_again_without_a_build:fails on main (
Exited(75), 1 startinstead of 5 starts, no build), passes here with the other 18play::tests. The in-game run's game and builder were built from this branch's code before its last commit, which changes only comments, docs and checks.cargo fmt --checkpasses.pre-commiton every changed file passes (tests/test_crash_record.py's 43 one-linea; bstatements, which ruff'sE702 flags in a changed file, are on lines of their own here; its syntax tree is unchanged). The new check takes the
runner's
{cc}and a compiler command with arguments (--cc "gcc -O1",CC=clang).28cb22b9too:check_guide_screenshots.py --review-sourcesasks for a review ofdevice_policy.h,vk_internal.handvk_texture.h, which main changed(#2871 records it); its other steps pass here.
test_menu_restart,test_close_waits_for_save,test_longshot_exit,test_hos_ab,test_input_moviepass on Windows;test_menu_restart,test_builder_channel,test_log_open_failure,test_restart_log,test_longshot_exit,test_close_waits_for_savepass on Linux (WSL Ubuntu 24.04).host/hos_relaunch.candhost/builder_channel.cbuilt for Windows in the pack (llvm-mingw); on Linux,test_restart_logcompiles the Linux restart cut from it andtest_builder_channelcompilesbuilder_channel.c.test_crash_recordfails on main and here at the same line (posix/display_sdl.c's thirdExitProcess(1), aninventory main has not caught up with); run with that one line lifted, its exit inventory matches this PR's
hos_relaunch.centry.test_builder_channelandtest_log_open_failurefail on Windows on main and here alike.cargo clippy -p build-driver -p longshot-builder --no-depson Windows stops at main'sfolder.rs:737(a needlessborrow in Windows-only code, untouched here); nothing in this diff. CI's clippy runs on Linux.
mise run teston Windows (12 at once): 811 passed, 57 failed here; 812 passed, 55 failed on main28cb22b9the same way. The failures match but for three here,test_quit_not_crashandtest_windows_stop(they read the window's close: updated here, both pass now on Windows and Linux) andtest_present_semaphores(passes alone: load), and one on main only,test_oot_wide_save_picture. The rest fail on main alike: stale source cuts, Windows paths and POSIX calls.Still to test:
back as from the shortcut's command above (by hand).
execve, unchanged here) (@Beanstalk Restart nowafter changing Output resolution, from the Launcher, on Linux).
Measurements
Verdict: fixed: Restart now brings the game back when the builder started it (it did not on main). No performance effect to measure.
Nothing to measure for speed: no frame, load or memory cost; the restart is a process start either way. The
evidence is the test and the run above (
HOS_RESTART_EXITis an exit status, not a switch):28cb22b9(nightly 951)f73cf723dtests/test_restart_by_builder.pyLongshot.exestarted and ended at onceRisks
does not happen: the builder in a version folder built the game beside it, and a new builder rebuilds the folder
(
another builder) before it plays.Launcher sees
game_startingandgame_startedagain, as afterrestart_to_apply.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.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 (26300), RTX 5080, NVIDIA 621.40: this branch as a pack over main 9b342b46's base, in a version folder laid out as the Launcher's (this branch's builder as Longshot.exe beside builds/default), started as the Launcher's window starts it (play --output json), at the title intro. Restart now through the control bridge's relaunch (the menu button's path): the game logged 'restart: the builder that started the game starts it again (exit status 75)', the same builder started it again 20 ms later, the bridge answered again after 1.1 s, the new game presented 300 frames, quit ended it and the builder exited 0. On nightly 951 (main
28cb22b9) the same steps left nothing running.WIP: fix(host): Restart now starts the game again on Windows when longshot-builder started itto fix(host): Restart now starts the game again on Windows when longshot-builder started it@review
Recommendation: Request changes. The reported Windows restart failure is fixed in the tested builder-driven run, but the Launcher, shortcut and Steam paths still need the runs listed by the author. (It stands on L3: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 14s.)The game asks its waiting builder to restart it on Windows, keeping the profile and builder session. This avoids the second builder colliding with the held profile; it adds an exit-status contract between the game and builder.
Blocking (2): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 14s.CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request)fails on this head and passes on the base branch: Failing after 15s.Should fix (1): not blocking, but worth doing before merging.
tests/test_restart_by_builder.py:25: The new check hard-codes gcc instead of using the compiler selected by the test runner. (more on the line) Do: Pass the runner's {cc} selection and accept its compiler command, including any arguments, in the test.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
host/hos_relaunch.c:68: The actual Windows entry points still need the integration runs listed in the PR. (more on the line) Do: Run Restart now through the Windows Launcher, a Steam tile and a desktop shortcut, and check that the game returns in the same session without an already-running message.@fixcan do L1, L3 and L4.Questions (1) (not confirmed from the code; they don't hold the recommendation)
Checks: Still running: 7 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested path: nightly 951 did not restart, while the branch restarted under the same builder, which started the new process 20 ms after the first ended. The actual Launcher, Steam and shortcut flows remain untested.
Other systems: The builder's play loop changes on both Windows and Linux. Linux's execve restart is unchanged, but an in-game Linux or Deck run remains outstanding. Crash handling sees the new exit status after the game has performed clean-close work. An older builder can still play a newer game if its attempted rebuild fails, so that compatibility case deserves attention.
Switches: None added, changed or removed.
Reviewed:
b6f4abb889against28cb22b9ed: Read the repository rules, PR template, standards, commit messages and complete diff. Read the changed host channel and relaunch code and the play loop, and traced startup, channel creation, crash handling and test runner compiler selection. Skimmed the remaining portions of the large play and test files; the review checklist file was absent. No translations, recorded runs or generated files changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project, builds or tests were run. The author reports a successful Windows in-game run and game-free checks. CI has two head-only failures already recorded by the bot and several checks still running.
Overlaps and merge order: The PR reports that open #2807 touches the same exit path; merge order was not established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as llun took it out of WIP. Nothing was run; a maintainer decides.
@ -59,1 +66,3 @@static void relaunch(void) {/* (the status the game exits with: HOS_RESTART_EXIT when its builder starts it again, else 0) */static int relaunch(void) {if (bc_given()) {L2 (should fix): The actual Windows entry points still need the integration runs listed in the PR.
When: The recorded run imitates the Launcher's command and uses the control bridge; it does not exercise the Launcher's session state or the Steam and desktop shortcut output paths after a restart.
Do: Run Restart now through the Windows Launcher, a Steam tile and a desktop shortcut, and check that the game returns in the same session without an already-running message.
@ -0,0 +22,4 @@import tempfilefrom pathlib import PathRUN_ALL_ARGS = ["--cc", "gcc"]L1 (should fix): The new check hard-codes gcc instead of using the compiler selected by the test runner.
When: On a supported Windows llvm-mingw or Linux Clang setup with CC set and no gcc on PATH, run_all skips this regression check even though a suitable compiler is available; CC is ignored when gcc is present.
Do: Pass the runner's {cc} selection and accept its compiler command, including any arguments, in the test.
Thanks for the review. Pushed
f73cf723d(the two commits rewritten, test then fix):tests/test_restart_by_builder.pynow declaresRUN_ALL_ARGS = ["--cc", "{cc}"],defaults to
$CC(else gcc), and splits the command, so--cc "gcc -O1"andCC=clangwork. Ran with gcc, clang,gcc -O1 -DX=1and throughmise run teston Windows, and withclang -O2on Linux. The test commit alone stillfails on main for the bug ("started by a builder, Restart now started 1 program(s) and exited 0").
tests/test_crash_record.py(its exit inventorychanges here) had 43 statements joined by
;(E702). They are on lines of their own now, with the syntax tree checkedunchanged;
pre-commit run --filespasses on every changed file.28cb22b9the same way.check_guide_screenshots.py --review-sourcesasks for a review ofgpu/vk/device_policy.h,vk_internal.handvk_texture.h, which recent mainchanges touched; this PR changes none of them, and the job's other steps pass here. #2871 records that review.
play --output user,in the same version-folder layout, through the job queue): the same builder started the game again 26 ms after the
first ended, the bridge answered after 1.8 s, and no second
Longshot.exestarted, so no "already running" box. TheLauncher's own Play, and a Steam tile and shortcut the Launcher made, stay in Still to test.
would be the game starting itself, which is the path that hands over and fails today, so a handshake would buy
nothing. In that case the older builder returns the game's 75 and the game doesn't come back, the same as on main.
Plus, the pairing needs a builder older than the game it plays: a version folder's builder built the game beside it,
and a newer builder rebuilds the folder ("another builder") before it plays.
b6f4abb889f73cf723d9@review
Recommendation: Request changes. The reported Windows run shows the builder restarting the game, but the actual Launcher, desktop shortcut and Steam tile entry points still need the integration runs requested in L2. (It stands on L3: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 14s.)On Windows, a builder-started game asks its existing builder to restart it, keeping the profile and Launcher session. The change adds a small restart protocol and game-free checks.
Blocking (1): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 14s.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
host/hos_relaunch.c:68: The actual Windows entry points still need integration runs. When: The reported runs start the builder in equivalent modes but do not exercise the Launcher session or its generated shortcut and Steam tile. Do: Run Restart now from Launcher Play and from a Launcher-created desktop shortcut and Steam tile; confirm the game returns in the same session without an already-running warning.@fixcan do L3.Since the last review (on
b6f4abb889)Resolved: L1 (The new check hard-codes gcc instead of using the compiler selected by the test runner.); L4 (The check
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request)fails on this he…)Still open: L2 (The actual Windows entry points still need integration runs.); L3 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…)Checks: Still running: 7 checks.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes: the reported Windows run restarted the game under the same builder 20 ms after it ended; the equivalent main build left no game running. This is not a performance change.
Other systems: Linux retains its execve restart path; a Linux or Deck game run remains unreported. Builder-started Windows games use exit status 75; games without a builder channel retain self-relaunch.
Switches: None.
Reviewed:
f73cf723d9against28cb22b9ed: Read repository rules, the PR diff and commits, the restart test and relevant host and builder code; skimmed the remaining changed tests and documentation. The large combined source output was truncated, so not every changed file was read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The author reports game-free checks and Windows in-game runs; several CI checks are still running.
Overlaps and merge order: PR #2807 touches the same exit path; its merge order is not established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
On
f73cf723d: Lint passes now; L1 and L4 are done.28cb22b9fails Third-party parts and guide screenshots the same way (check_guide_screenshots.py --review-sources:gpu/vk/device_policy.h,vk_internal.handvk_texture.hchanged since the Graphics image's review), and this PR changes none of those files. #2871 records that review; once it merges, this branch is rebased onto main and the job reruns.jsonanduser) ran in the game, as Testing says.L2: ran in the real Launcher (nightly-247-29c6603a) on Windows 11, RTX 5080, with this branch's builder and game added as a version, through the job queue. Restart now from the game's own menu (Output resolution changed, then Restart Now):
game_starting,game_startedandgame_readyagain in the same session, and Home was back on Ready to play after the game was closed.LongshotLauncher.exe --play <version> --profile <folder>, what the Launcher's desktop shortcuts and Steam tiles run): the same; no secondLongshot.exe, no "already running" box, the Launcher exited 0 at the end.Testing has the details. Left in Still to test: a tile started by Steam itself (Steam's job around the Launcher) and Linux or the Deck. L3 is still main's (#2871).
@review
Recommendation: Request changes. Restart now is shown working through the real Launcher and the shortcut command, but the Steam tile run requested in L2 remains outstanding. (It stands on L3: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 14s.)The Windows game asks its existing builder to start it again, preserving the profile lock and Launcher session. The change adds a small restart protocol between the game and builder.
Blocking (1): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 14s.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
host/hos_relaunch.c:68: The remaining Windows entry-point runs need verification. When: A Steam tile started from Steam has not been exercised, and the reported shortcut run used its command rather than a Launcher-created shortcut. Do: Run Restart now from a Launcher-created desktop shortcut and a Steam tile started by Steam; confirm the game returns and the Launcher session ends normally.@fixcan do L3.Since the last review (on
f73cf723d9)Still open: L2 (The remaining Windows entry-point runs need verification.); L3 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…)Checks: Still running: 7 checks.
Also noticed (4; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes: the reported Windows Launcher run reopened the game at the new resolution; on main, the game did not return. The same builder restarted it in the reported control-bridge run, 20 ms after exit.
Other systems: Linux retains its execve restart path; a Linux or Deck run is still listed as outstanding. Windows games started without a builder retain the existing self-relaunch path. The reported Windows runs cover Launcher Play and the shortcut command, but not a tile started by Steam itself.
Switches: None.
Reviewed:
f73cf723d9against28cb22b9ed: Read the repository rules and pull request template, the restart and builder-channel changes, the restart test, and the relevant play-loop diff and callers. Skimmed the remaining changed tests and documentation; did not read play.rs or all changed files in full. No review checklist file was found.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports game-free tests and Windows in-game runs; Steam itself and Linux or Deck remain to be tested.
Overlaps and merge order: #2807 touches the same exit path; merge order is not established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.