fix(host): a game started by longshot-builder play writes its own longshot_log.txt (LONGSHOT_OWN_LOG) #2741
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2741
Loading…
Reference in a new issue
No description provided.
Delete branch "Jiro113/Longshot:fix/launcher-game-log-file"
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
A game started by the launcher writes no
diagnostics/logs/longshot_log.txt, so the Insert menu's Bug report has nolog, the crash window names the launcher's file and players have nothing to send. Since
#2688 (nightly-854 and later)
longshot-builder play --output jsongives the game its JSON relay's pipe as stderr (from the launcher's Windows shortcut,
--output user, the launcher'stemporary file), and
host/hos_main.conly opened its own log when the game had no stderr (or Steam's Gaming-mode pipe,#1322). On main: start the game from the launcher (or
longshot-builder play --profile <p> --output jsonread by a program), and the game folder'sdiagnostics/logs/staysempty.
This PR makes the builder say so, and the game write its own log again:
longshot-builder playgives the gameLONGSHOT_OWN_LOG=1(build_driver::play::OWN_LOG_VAR) under--output json,and under
--output userasked while its own stderr is not a terminal (the launcher's shortcut):output::own_loginbuilder/crates/longshot-builder/src/output.rs. Nothing changes for a terminal,--output text,RecompLauncher or a start with no
--output.host/log_gate.hholds the one rule: no stderr, orLONGSHOT_OWN_LOG=1(never in a--prepare-shadersstep, whosepipe the builder reads), or Steam's pipe on Linux as before.
host/hos_main.creads the variable once, besidehos_relaunch_keep_envand beforelongshot_env.txt(a line there sets it with no effect).host/hos_relaunch.c: Restart now keeps the handles (Windows) or stderr (Linux) by the same rule, so the restartedgame opens its log again instead of writing into a relay nobody reads.
host/hos_crash_record.c: the log path the game opened wins over its stderr's, so the crash record names the run'slog, not
launcher-output.tmp. If the log cannot be opened, the record uses the retained stderr's path.gpu/vk/switches.defanddocs/dev/reference/switches.mdget the variable's row; a build-driver test checks that thename
playgives is the onehost/log_gate.hreads.Read first:
host/log_gate.h, the gate inhost/hos_main.c,hos_relaunch_keep_envinhost/hos_relaunch.c,output::own_logand its use inplay.rs'srun_with.The start-up screen is unchanged:
startup_progressandgame_readycome on the game's stdout(
host/launcher_startup.h), which stays the relay's (play/json_output.rs). The game's stderr lines reach the relayonly until its log opens.
Prior work: none found (
longshot_log,json_output,game_output,FILE_TYPE_UNKNOWN, "no log", "longshot_log.txtmissing"; Longshot and LongshotLauncher; Hookshot's API answered HTTP 521 on 2026-11-28).
Testing
Tested: Windows 11 (26300), RTX 4090, driver 621.24, this branch as a pack over main 22d0d2009's base (game built
from this head's code). The game started the way
play --output jsonstarts it (stdout and stderr pipes read by aprogram,
LONGSHOT_OWN_LOG=1), then Restart now through the control bridge'srelaunch, thenquit:longshot_log.txt;diagnostics/logs/longshot_log.txtwritten, the user name absent; Restart now movedit to
.1and the restarted game wrote its own; five starts kept.1to.4;--prepare-shaderswith the variable: its 616 stderr lines still reach the pipe, the log is not rotated;HOS_CRASH_TEST=start), over the pipe and over the shortcut's file: theCRASH:lines and the host backtrace are in
longshot_log.txt, the crash record nameslongshot_log.txt, nothing reachedthe pipe or the file;
diagnostics/bug-reports/running/marker namesdiagnostics/logs/longshot_log.txt;LONGSHOT_LAUNCHER_STARTUP=1too (the start-up screen's stream):startup_progressandgame_readystillreach the stdout pipe, nothing reaches the stderr pipe, and the log is written and rotates.
The variable was set by the test program in these runs, not by
longshot-builder playitself: the builder's side iscovered by
output::own_log's unit test and the name test, and by the launcher run in Still to test.Checks:
tests/test_log_open_failure.py(the relay's pipe, the shortcut's file,--prepare-shaders),tests/test_restart_log.py(Restart now under the relay, and Steam's pipe),tests/test_crash_record.py(a gamewriting its own log over a stderr file names its own log), all failing on main and passing here; the added crash-record
case for a log that cannot be opened is pending;
cargo test -p build-driver -p longshot-builder own_log;tests/run_all.py --changed origin/mainon Linux and Windows, andmise run teston Linux and Windows (no failure of its own here: see the checklist). Failures that also fail on main with the same messages, unchanged here:test_switch_table(LONGSHOT_LAUNCHER_STARTUPhas no row),test_crash_record(its source checks trip onhost/posix/display_sdl.csince #2683; the new case was run withthat check lifted and passes),
test_bug_report; on Linux (that--changedrun, in WSL outside the CI image; the CIimage's whole-suite run is in the checklist) also
test_hud_layout_row,test_guest_holes,test_pipeline_tour; on Windows alsotest_builder_channel,test_dev_ab,test_input_movie, and eight Windows pathassertions in
cargo test -p longshot-builder.Still to test:
diagnostics/logs/longshot_log.txt,the Insert menu's Bug report with that log, Restart now rotating it, and the crash window naming it (by hand, with a
launcher of this build).
(
@Beanstalk start the game through longshot-builder play --output json on Linux and check diagnostics/logs/longshot_log.txt).for the Test Farm's maintainer).
Measurements
Nothing to measure: where the log is written, once at start; no per-frame work.
Risks
play --output jsongets only the lines before the log opens; the linesare in the game's log. The launcher's own launch log (
last-launch.log) loses them the same way.LONGSHOT_OWN_LOGis read once at start, so a tool that wants the old stream can't turn it back on from
longshot_env.txt; a revert isenough.
temporary file, which no longer comes from the game after its log opens.
(#1374), instead of writing on in the run before's.
env.pushremoved) or reads the terminal on stdoutinstead of stderr: the launcher test above does.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). In the CI's own image, built locallyfrom
scripts/linux/checks.Dockerfile,run_all.py --stricton the whole suite gave 807 passed, 71 failed and10 skipped. That run had no network and no prebuilt
longshot-builder, so cargo could not fetch crates and most ofthe 71 timed out. The 71 then ran again as the CI's tests job runs them: with the network,
longshot-builderbuilt first (debug and release) and--timeout 1200. 56 passed and 15 failed here. The same 15fail on
main(22d0d2009), with the same errors:test_bug_report,test_control_picture,test_crash_record,test_framegen_hdr,test_framegen_resources,test_guest_holes,test_input_background,test_lifter(fmt --all --check),test_perf_send,test_pipeline_tour,test_present_source_crop,test_screensaver,test_switch_table(LONGSHOT_LAUNCHER_STARTUPhas no row),test_temporal_present_bandwidthand
test_xinput_thread.test_crash_recordstops at main's source check onposix/display_sdl.cbefore itreaches the case this PR adds. That case passes once that check is lifted (Testing). On Windows (llvm-mingw),
812 passed and 29 failed here, against 811 and 30 on
main, and every failure here also fails onmain. The 29are 12 of the 15 above (all but
test_guest_holes,test_input_backgroundandtest_pipeline_tour), plustest_auto_handheld,test_builder_channel,test_coverage_run,test_dev_ab,test_dev_build,test_dev_migrate,test_fsr3fi_hud_layer,test_fsr3fi_hudless_colour,test_fsr4_tune,test_game_menu_mouse_buttons,test_input_movie,test_job_queue,test_oot_menu_mouse,test_pads_after_menu,test_parity_gates,test_run_all_mingwandtest_sampler_admission. Main's extrafailure,
byte_compile_tracked, came from running it in agit archivewith no.git.main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.(
LONGSHOT_OWN_LOG, unset by default. It is no player's knob:longshot-builder playsets it for the game itstarts. Its row is in
gpu/vk/switches.defanddocs/dev/reference/switches.md; nothing to measure, asMeasurements says.)
tests/that reads changed source is updated, not weakened.the game (Testing). Linux:
scripts/check_host_compile.pyran for Linux in the CI image, with the commands of aplayer's build. Its headers came from tools.lock's
linux-x64CPM cache and FFmpeg from Ubuntu's packages: 116host units, 0 failed,
hos_main.c,hos_relaunch.candhos_crash_record.camong them. That is a syntax-onlycompile, not a link.
test_utf8_pathspasses.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 4090, driver 621.24: this branch as a pack over main 22d0d2009's base, the game started as play --output json starts it (stdout and stderr pipes read by a program, LONGSHOT_OWN_LOG=1 set by that program, not by longshot-builder play itself), title screen, Restart now through the control bridge, quit. With the variable: nothing over the pipe, diagnostics/logs/longshot_log.txt written without the user name, rotated to .1 by Restart now. Without it (main's behaviour): the log over the pipe and no file. Also seen: stderr as a file (the launcher shortcut's case) stays empty while the log is written; --prepare-shaders keeps its pipe; a crash on purpose at the start puts the CRASH: lines in longshot_log.txt and the crash record names it; the start-up screen's startup_progress and game_ready still arrive on stdout.
Possibly related, for context:
@review
Checklist: three boxes settled.
mise run testpasses. I ran the strict suite in the CI image, built locally fromscripts/linux/checks.Dockerfile, and reran its failures the way the tests job runs them. The same 15 checks fail on the branch and onmain22d0d2009, with the same errors. They are named in the box.scripts/check_host_compile.pyran for Linux in that image, with headers from tools.lock'slinux-x64CPM cache: 116 host units, 0 failed. The changed files are among them.LONGSHOT_OWN_LOG. It is unset by default, set only bylongshot-builder play, and has its row inswitches.def.The PR stays WIP: the launcher run in Still to test has not been done yet.
Description: the 29 Windows failures behind the
mise run testbox are now named. All 29 also fail onmain. Testing's Linux list is marked as the earlier--changedrun in WSL, outside the CI image.I compared the 15 failures in the CI image between the branch and
mainas whole blocks. They differ only by the two new Rust tests of this branch, which pass, and by a shifted line number intest_crash_record.py, on the same assertion. This PR's own checks pass in that image. The 10 skipped checks are Windows-only or need a Vulkan device.WIP: fix(host): a game started by longshot-builder play writes its own longshot_log.txt (LONGSHOT_OWN_LOG)to fix(host): a game started by longshot-builder play writes its own longshot_log.txt (LONGSHOT_OWN_LOG)@review
Recommendation: Request changes. The change restores a game log in the tested Windows setup, but it also removes diagnostic output that existing builder consumers receive. If opening the new log fails, the crash record can name a file the game never wrote.
The builder asks the game to write its own rotating log for JSON launches and non-terminal user-output launches. This makes bug reports more useful, but currently costs consumers their live game diagnostics and has an incorrect log destination on an open failure.
Blocking (2): must change before merging.
builder/crates/longshot-builder/src/play.rs:657: Setting this for every JSON launch removes the game's stderr diagnostics from the existing JSON event stream. (more on the line) Do: Preserve the game diagnostics in the JSON relay while also writing the rotating game log, and test both destinations.builder/crates/longshot-builder/src/output.rs:48: A non-terminal stderr does not identify the launcher's temporary file; it can be a file or pipe deliberately supplied by another caller. (more on the line) Do: Use an explicit launcher-to-builder indication for the shortcut case, or preserve the supplied stderr while writing the game log.Should fix (1): not blocking, but worth doing before merging.
host/hos_crash_record.c:807: The selected log path takes precedence even when opening that log failed and the game retained its original stderr. (more on the line) Do: Record the selected path only after redirection succeeds, or fall back to the actual stderr path when opening fails; cover this failure with a crash-record test.@fixcan do L1, L2 and L3.Questions (2) (not confirmed from the code; they don't hold the recommendation)
builder/crates/longshot-builder/src/play.rs:657: Is a game-free test of the builder's child environment required by a repository rule for this change?Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, for the tested host path: on Windows 11 with an RTX 4090, the author's simulated JSON launch wrote and rotated the log; without the variable it produced 154 KB on the pipe and no log file. The actual builder-to-launcher path and Linux remain untested.
Other systems: The JSON relay and launcher launch log lose game stderr; other JSON consumers can lose diagnostics too. Linux and Steam Gaming mode use the changed gate and restart path but have no reported game run. Shader preparation retains its pipe in the reported test. Windows restart and crash reporting were exercised in the simulated launch, but not through the launcher.
Switches: LONGSHOT_OWN_LOG is added, unset by default and set to 1 by play for JSON and explicitly requested non-terminal user output. The default leaves direct starts unchanged, but the builder's automatic setting causes the diagnostic-stream regressions noted below. The switch table and reference are updated.
Reviewed:
3478b573a5against22d0d20098: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the commit log and the change, with focused inspection of the logging gate, restart, crash-record and builder relay paths. Skimmed the changed tests and documentation; did not read every changed code file in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during review. The author reports a Windows in-game simulation and game-free checks; the actual launcher path and Linux game runs remain outstanding. CI is still running.
Overlaps and merge order: No overlapping pull request was identified in the supplied prior-work search.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -38,0 +45,4 @@pub fn own_log(asked: Option<Output>, terminal: bool) -> bool {match asked {Some(Output::Json) => true,Some(Output::User) => !terminal,L2 (blocking): A non-terminal stderr does not identify the launcher's temporary file; it can be a file or pipe deliberately supplied by another caller.
When: A user runs play --output user with stderr redirected to a file to collect game diagnostics. The builder sets LONGSHOT_OWN_LOG and the game redirects its stderr to its own log, leaving the requested file without the game's later output.
Do: Use an explicit launcher-to-builder indication for the shortcut case, or preserve the supplied stderr while writing the game log.
@ -653,1 +654,4 @@}// (the game's stderr nobody's to keep, the relay's pipe or the launcher's shortcut's file: LONGSHOT_OWN_LOG=1, and the// game writes its own longshot_log.txt, host/log_gate.h)if crate::output::own_log(asked, std::io::IsTerminal::is_terminal(&std::io::stderr())) {L1 (blocking): Setting this for every JSON launch removes the game's stderr diagnostics from the existing JSON event stream.
When: A program consuming play --output json previously received the game's stderr as source=game log events through json_output::relay. Once the game opens its file, those events stop, so a consumer monitoring a failure or preserving the launch log no longer receives the diagnostic.
Do: Preserve the game diagnostics in the JSON relay while also writing the rotating game log, and test both destinations.
@ -805,3 +805,3 @@#ifdef _WIN32HANDLE err = GetStdHandle(STD_ERROR_HANDLE); wchar_t log[PATH_CAP];if (GetFileType(err) == FILE_TYPE_DISK) {if (!log_path && GetFileType(err) == FILE_TYPE_DISK) {L3 (should fix): The selected log path takes precedence even when opening that log failed and the game retained its original stderr.
When: For a shortcut launch with a writable inherited stderr file but an unwritable game log path, hos_main prepares the selected path before fopen fails. The game continues writing to the inherited file, but the crash record names and reads the nonexistent selected log instead.
Do: Record the selected path only after redirection succeeds, or fall back to the actual stderr path when opening fails; cover this failure with a crash-record test.
@fix
3478b573a5ec40598056Recommendation: Request changes. JSON launches and explicit user-output launches with redirected stderr still lose game diagnostics from their existing streams. Both regressions need to be fixed while retaining the game’s rotating log.
What
@fixchangedI changed this pull request: the new head is
ec40598056. I rebased it ontomain(50e52e4717). I edited its description to match the change.Changed
Not done
Nothing was built or run: the checks run again on the new head.
The change gives launcher-started games their own rotating log and records the opened log path for crash reports. It also diverts diagnostics away from streams that existing callers may consume.
Blocking (2): must change before merging.
builder/crates/longshot-builder/src/play.rs:657: Setting this for every JSON launch removes the game's stderr diagnostics from the existing JSON event stream. When: A program consuming play --output json previously received the game's stderr as source=game log events through json_output::relay. Once the game opens its file, those events stop, so a consumer monitoring a failure or preserving the launch log no longer receives the diagnostic. Do: Preserve the game diagnostics in the JSON relay while also writing the rotating game log, and test both destinations. (for the author:@fixcouldn't: JSON launches still set LONGSHOT_OWN_LOG, and the host redirects stderr to the game log, removing subsequent diagnostics from the JSON relay.)builder/crates/longshot-builder/src/output.rs:48: A non-terminal stderr does not identify the launcher's temporary file; it can be a file or pipe deliberately supplied by another caller. When: A user runs play --output user with stderr redirected to a file to collect game diagnostics. The builder sets LONGSHOT_OWN_LOG and the game redirects its stderr to its own log, leaving the requested file without the game's later output. Do: Use an explicit launcher-to-builder indication for the shortcut case, or preserve the supplied stderr while writing the game log. (for the author:@fixcouldn't: Explicit user output with non-terminal stderr still sets LONGSHOT_OWN_LOG for any caller-supplied file or pipe, so the caller stops receiving game diagnostics.)Checks: they run again on this head; a failure shows on the pull request.
Also noticed (4; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested Windows game process: the reported run wrote and rotated its own log, whereas the comparison wrote 154 KB to the pipe and no log file. The builder-to-launcher path and Linux behavior remain untested in the reported runs.
Other systems: JSON relay consumers, including the launcher and potentially the Test Farm, lose game stderr after the log opens. Explicit user-output callers with a redirected file or pipe are also affected. Windows game-process behavior was exercised; Linux Desktop, Steam Gaming mode, and actual launcher starts remain to be tested.
Switches: LONGSHOT_OWN_LOG is unset by default and set by the builder for JSON and certain user-output launches. Its automatic use is not safe for callers that consume stderr; it is documented in switches.def and the switch reference.
Reviewed:
ec40598056against50e52e4717: Read the fix diff, the relevant log gate, startup and crash-record code, and the ledger-related builder changes; reviewed the supplied description and run reports. The full base-to-head diff includes other commits and was not read in full; recorded runs and tests were not executed.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The author reports a Windows game-process run; actual launcher starts, Linux Desktop and Steam Gaming mode, and the new open-failure crash-record case remain pending.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
Pushed
819145f3on top ofec405980(the head before this): the game now always writes its ownlongshot_log.txt, soLONGSHOT_OWN_LOGand the builder's side of it are gone.host/log_gate.h: the gate is "not a--prepare-shadersstep". Nothing has to pass a flag for the log to exist.hos_relaunch_keep_envbefore the log takes its place, and each log line is written to it as well (hos_log_tee_set,host/hos_thread.c), so the launcher's start-up screen andlast-launch.log, terminals and the Test Farm read what they did before. Restart now gives the new run that same stderr.play.rs/output.rschanges, theswitches.defand docs rows.test_log_open_failure.py,test_restart_log.py,test_menu_restart.py,test_crash_record.py(comments).Not verified: nothing was run. Only a Linux syntax check of
hos_thread.c,hos_relaunch.candhos_main.cpassed; the Windows side (DuplicateHandleof stderr, the handle list in the restart) is uncompiled and untested, and the updated tests have not run. The PR title and description still describeLONGSHOT_OWN_LOGand need rewriting, and the Testing section no longer applies.