startup: close the rendered session from the output window #2344
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2344
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2344"
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?
@SuperCraft3M on GitHub · 2026-11-25 13:03 UTC · original
SuperCraft3M:codex/startup-output-window→main· +138 −11 · 8 files · 2 commits · openChange
Closing the output window of a rendered
run.ps1session signals its debugger. The debugger owns the Windows job, terminates the child and verifies that the process handle becomes signaled before returning. Minimize keeps the session active. In a direct shim host, Close hides the output and the host remains active.The source-built presenter exercises minimize, restore and Close in both modes. The managed probe requires a debugger return and a zero child exit. The direct probe verifies that the window is hidden and the host can continue issuing presents.
Verification
Changes at
0465ba6don18f2f85c. Release, MSVC 19.44.35230, Windows 11 build 26300.9711. Hardware used an NVIDIA RTX 4070 with driver 32.0.16.2114. The D3D12 debug layer was unavailable.4 passed, 0 failed, 0 skipped. The launcher check ran on Windows PowerShell 5.1 and PowerShell 7.
AI-assisted (Codex).
@KelboLive on GitHub · 2026-11-25 16:06 UTC · original
APPROVED. Closes rendered session from the output window.
@tedin7 on GitHub · 2026-11-25 13:05 UTC · original · reviewed
Review of head
5633a0d3f2b75f32ffcfb7a536d502d0f05fe9f5(Linux host; no PowerShell, no Windows).Commands executed locally (in a worktree of the PR head):
CI at review time: Windows and Linux jobs still pending. The PR is mergeable.
Findings: P1=0, P2=0.
Read-through:
run.ps1:-not $env:X2W_HIDE_TITLE_WINDOWtreats the string "0" as set (non-empty string is truthy), so an explicit0still opts out. The new test case with-Render -LiveConsoleandhide_env="0"covers that.--console 0matchesdebug_launch.py(opts.get("--console", "1") == "1").d3d12_present.inl:WM_CLOSEnow callsExitProcess(0)after logging. Minimize is unaffected because it goes throughWM_SYSCOMMAND. Nit: the exit skips any flush of the shader cache or logs, which the PR text already says is intended.startup_present_producer.cpp(window-close): the fixture finds the output window by class and PID, checks that the guest window is hidden, then minimize, restore andSC_CLOSE. Reaching the 5 s sleep and returning 19 means the process did not exit, so the test fails closed.startup_output_window_closeruns with the new CMake line, which linksuser32and adds thesrcinclude path.startup_run_ps1_check.py: the expectations (--console 0unless-LiveConsole, and the inherited env value) matchrun.ps1.Nits:
-Translatepath only gets the--console 0and hide default through$Render. That is correct, since-Translateneeds-Render. The test'srendering = translate or ...is a slightly looser model than the script, but it is harmless.Not done:
AI-assisted; commands listed were executed locally.
@R0Y00 on GitHub · 2026-11-25 13:16 UTC · original · requested changes
The presenter is inside the shared D3D12 shim. WM_CLOSE currently calls ExitProcess in every host that creates that window, including hosts launched without run.ps1. That also runs DLL detach after stopping the other threads, which can hang if a stopped thread holds a lock needed by detach. Keep session shutdown owned by the launcher or an explicitly enabled session owner. In other hosts, closing the presenter should leave the host alive.
Please keep the existing minimize check and add both close cases: a managed source-built child whose process handle becomes signaled and whose launcher returns, and a direct shim host that stays alive on presenter close. The window visibility and live-console change can proceed independently if you want to land that first. Microsoft ExitProcess documentation
@pigalot on GitHub · 2026-11-28 01:01 UTC · original
I merged
main38129ba3into this branch as44f14769(a merge commit on top of0465ba6d; no rebase and no force-push). It also merges cleanly with the currentmain86beae95.Conflicts and how I resolved them.
src/startup_stubs/d3d12_present.inl: I keptmain's plane-surfacepresent_to_windowand added this branch'soutput_closedcheck to its early return:if (p.failed || !queue || !steps || !count || !plane_surfaces || InterlockedCompareExchange(&output_closed, 0, 0)) return false;tests/startup_run_ps1_check.py: I kept this branch's--managed-windowexpectation andmain's longer debugger record.main's native-shader case also runs with-Render, so the condition is nowif "-Render" in switches or translate or native:.tools/startup/debug_launch.py: I keptmain'sgrab_window/capture_windowsplit and capture-thread shutdown. The final capture keeps this branch's condition,if exit_code is None and not window_close:.tools/startup/run.ps1: both argument lists are passed,@traceArgs @captureArgs @windowArgs.What I ran. I built the whole tree in
devandrelease, then ran (under the shared GPU lock,-j 1):/O2.startup_run_shreports a capability skip (77), as on every Windows host.startup_run_ps1failed on my first resolution of its check, because an assignment was mis-indented. I fixed that before committing. On44f14769it reports0 failedwith bothpowershellandpwsh.git diff --check origin/main...HEADis clean.This needs a review from someone other than me before it can be merged.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10.
This reply was AI-assisted.
@pigalot on GitHub · 2026-11-28 02:31 UTC · original · approved these changes
Reviewed
44f14769(0465ba6dplus a merge ofmain) trial-merged over currentmain7364e6a9. The merge is clean andgit diff --cached --checkis clean.R0Y00's request on
5633a0d3.0465ba6danswers all three points:WM_CLOSEcalls neitherExitProcessnorShowWindow(SW_MINIMIZE). IfX2W_SESSION_CLOSE_EVENTnames an event it can open and set, it returns, and the launcher ends the run. Otherwise it hides the output window, stops the hide-title timer, shows any hidden title windows again, and setsoutput_closedsopresent_to_windowrefuses from then on. The host keeps running.debug_launch.py --managed-window 1creates a randomLocal\X2W-session-close-<uuid>event and passes its name only to its child; an inherited value is dropped first. When the event is set, the launcher callsTerminateJobObject(job, 0), which skips the DLL detach R0Y00 pointed at. It then keeps reading debug events for up to 10 s, untilEXIT_PROCESS. It returns 2 if the process handle hasn't signalled within 2 s.run.ps1passes--managed-window 1only with-Render.-Translateand-NativeShadersboth need-Render.window-closeinstartup_present_producerminimizes, restores and closes the window, then checks the direct host survives and the managed child is ended. The existing minimize check is kept.The merge of
main(44f14769, three files):d3d12_present.inl:present_to_windowkeepsmain's plane-steps signature and adds theoutput_closedcheck. That's right.startup_run_ps1_check.py: the condition becomes"-Render" in switches or translate or native. Theor nativepart is needed: the native case passes-Render -NativeShadersinsiderun_case, not throughswitches. The tuple keepsmain's fields.debug_launch.py:mainmovedcapture_windowout of this spot. The merge keepsmain's version and adds this PR'sand not window_closeguard.What I ran. I did a full build in
devandrelease, then ran_hardware: 21 of 21 pass in each preset, includingstartup_output_window_closeandstartup_run_ps1._hardware:startup_present_producer_hardwareandstartup_present_view_hardwarepass in each preset.dev,-j 6 -E '(_hardware$|startup_audio_)'): 1977 of 1980 pass. The other three arestartup_inflate,shader_sgd5_effects_cli_checkandpixel_aot_comparisons_warp. All three timed out under load and pass when rerun alone with-j 1.Mutants. For each, I rebuilt
devwhere needed and ranstartup_output_window_close,startup_run_ps1andstartup_present_producer_warp:startup_output_window_close)startup_output_window_close)startup_output_window_close)TerminateJobObjectexit 0x00000000inevents.txt)run.ps1never passes--managed-windowstartup_run_ps1)present_to_windowignoresoutput_closedtitle_hider.stepremoved)X2W_SESSION_CLOSE_EVENTnot droppedRestored and rebuilt afterwards;
git diff --quietis clean.Non-blocking.
present_to_windowrefuses, soshown_in_windowis false. The title windows the hider hid come back, and every sixth frame doesread_back_presentedanddraw_overlayinto them. That's a reasonable way to keep a direct host visible, but no test pins it, and the docs line says only "Close hides the output". A direct-mode check that a present after Close doesn't reach the output window, and that a hidden title window is shown again, would pin the first two survivors.startup_output_window_closesetsSKIP_RETURN_CODE 77, but nothing in it returns 77. That's harmless, but it may mislead a reader.Verdict: approve on
44f14769. R0Y00's changes request on5633a0d3still stands, so this needs R0Y00's re-review before it can merge.Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware runs.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on44f14769.This reply was AI-assisted.
@R0Y00 on GitHub · 2026-11-28 02:50 UTC · original
I verified the earlier close handling feedback with
44f14769integrated over main4d7265c0(local tree b4db0b8895ee06c4109f4c2b1ecffa9af90813f5). The only conflict is in tools/startup/run.ps1. Keep #2867's scoped Continue and script:debuggerExit capture, and append @windowArgs to the debugger call inside that scope. The existing -Render guard and managed-window argument stay.Release /O2: all four checks passed with no skips. The synthetic managed presenter exits through the debugger, the direct presenter hides and keeps the host alive, and minimize/restore still works. The launcher fixture passed in Windows PowerShell 5.1 and PowerShell 7, including stderr status handling and the managed flag.
Windows 11 26200.9974, inbox WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. Please merge current main into this PR and retain both launcher behaviors. I can then recheck and update my earlier review on the published head.
@JohnConnorNPC on GitHub · 2026-11-28 08:10 UTC · original
Thanks for the close-handling rework. I reviewed head
44f14769against currentmain(1f07b2c1). The code answers R0Y00's changes request on5633a0d3(grep -c ExitProcess src/startup_stubs/d3d12_present.inl→0), but one thing still blocks the merge:mainand resolvetools/startup/run.ps1as R0Y00 asked at 02:50Z.git merge-tree --write-tree 1f07b2c1 44f14769exits 1 withCONFLICT (content): Merge conflict in tools/startup/run.ps1. Keep #2867's scoped& { $ErrorActionPreference = "Continue" ... $script:debuggerExit }block and append@windowArgsafter@captureArgsinside it. Please merge rather than rebase. On a scratch resolution done that way,startup_run_ps1_check.py(text-only on Linux),docs_links_check.pyandbidi_controls_check.pypass. R0Y00 then needs to re-review, because the changes request still stands.Also worth fixing:
prtest preset's regex matches none ofstartup_output_window_close,startup_run_ps1orstartup_present_producer_warp, andgrep -c startup_output_window_closeon the Windows job log →0. On Linux, a mutant that drops@windowArgsfromrun.ps1still passesstartup_run_ps1_check.py(0 failed (text only: not a Windows host)). That is the conflicted line, so please post Windowsstartup_run_ps1(powershell and pwsh) andstartup_output_window_closeruns on the new head.present(), isok(call(queue, 32, ...)) && finish(), which observes the queue fence and not the window. That leaves three of pigalot's surviving mutants unpinned:present_to_windowignoresoutput_closed,title_hider.stepremoved, and the hide-title timer kept. Asserting that the output window gets no new frame after Close, and that a hidden title window is shown again, would pin them.process did not signal exitpath (return 2) can't be reached with the test child, so please say in a comment or the PR text that it is only a safeguard.SKIP_RETURN_CODE 77is set, but the check never returns 77 (grep -c 77→0).--managed-windowandX2W_SESSION_CLOSE_EVENTappear in neitherdebug_launch.py's docstring nordocs/(0and0). Dropping an inheritedX2W_SESSION_CLOSE_EVENTis pinned only by the test's ownenv.pop; a case that sets a stale name before launch would pin it.Environment: Linux, static review of git objects,
git merge-tree, a scratch merge (never pushed) and the CI job logs. I did no Windows, WARP or GPU run.This comment was AI-assisted.
@JohnConnorNPC on GitHub · 2026-11-29 13:11 UTC · original
The head is still
44f14769, so my 11-28 comment stands and I haven't re-reviewed it in depth. Since thenmainhas moved further, and the conflict has grown. Againstmainc04e0dd6,git merge-tree --write-tree c04e0dd6 44f14769exits 1 in two files:tools/startup/run.ps1, two hunks. First, keepmain's$mapArgssetup (#1251) and add your$windowArgslines after it. Second, keepmain's scoped& { $ErrorActionPreference = "Continue" ... $script:debuggerExit = $LASTEXITCODE } *> "$LogDir.out"block, with--assert-sites $AssertSites @mapArgs @traceArgs @captureArgs @holdArgs(#2867, #2916 and the hook-thread hold), and append@windowArgsto it.tests/startup_run_ps1_check.py, one hunk. Keepmain'snative_default = (native or "-Render" in switches) and not translateline from #3451, and add your--managed-window 1expectation after it.expectedstill usesnative_defaulton both sides.Since #3451,
-Renderruns default to native shaders. Your--managed-window 1sits under-Rendertoo, so every default rendered launcher run gets the managed close. Please rebase (or mergemain, as R0Y00 asked). Then post Windowsstartup_run_ps1(powershell and pwsh) andstartup_output_window_closeruns on the new head, and R0Y00 can re-review.Environment: Linux only: git objects and
git merge-tree. I did no Windows run.This comment was AI-assisted.
@R0Y00 on GitHub · 2026-12-03 09:35 UTC · original
I trial-merged
44f14769over maind2e6a4edand tested the four-file conflict resolution locally. In present_to_window, keep the current failed-present diagnostic and return separately when output_closed is set. In the producer fixture, retain both main's color readback flags and the new close_test flag. In the launcher, keep mapArgs, holdArgs and the PowerShell 5.1 stderr scope, then append windowArgs to the same invocation. In the launcher fixture, keep native_default and the managed-window argument assertion.MSVC Debug on Windows build 26300, inbox WARP, debug layer enabled: ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(startup_output_window_close|startup_present_producer_warp|startup_run_ps1)$' passed 3/3 without skips. The launcher self-test exercised both powershell and pwsh.
I also exercised the inherited-event control raised on #3344. Start debug_launch.py without --managed-window, set X2W_SESSION_CLOSE_EVENT to a real initially unsignaled parent event, and let the existing producer fixture minimize, restore and close. With the merged code the child exited 0 and the event stayed unsignaled. Removing env.pop("X2W_SESSION_CLOSE_EVENT", None) made the child exit 21 and signal that event. Please include that unmanaged case when updating this original branch. #3344 carries the same implementation, so the runtime review can stay here.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.