Repository navigation
startup: close the rendered session from the output window - #2344
SuperCraft3M wants to merge 2 commits into
Conversation
tedin7
left a comment
There was a problem hiding this comment.
Review of head 5633a0d3f2b75f32ffcfb7a536d502d0f05fe9f5 (Linux host; no PowerShell, no Windows).
Commands executed locally (in a worktree of the PR head):
git diff --stat origin/main...HEAD -> 6 files, +84/-10
python3 tests/docs_links_check.py -> Checked 19 Markdown files and 453 links
python3 tests/bidi_controls_check.py -> no bidirectional controls
git diff --check origin/main...HEAD -> clean
python3 tests/startup_run_ps1_check.py -> "text only: not a Windows host" (0 failed)
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:
- The
-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:
- No mutation run. The launcher test needs PowerShell and the close probe needs Windows, and neither is available on this host. The claimed Win2025 results in the PR body were not re-run here.
AI-assisted; commands listed were executed locally.
R0Y00
left a comment
There was a problem hiding this comment.
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
|
APPROVED. Closes rendered session from the output window. |
5633a0d to
0465ba6
Compare
Resolved conflicts: - src/startup_stubs/d3d12_present.inl: kept main's plane-surface present_to_window and added the branch's output_closed check to its early return. - tests/startup_run_ps1_check.py: kept the branch's --managed-window expectation and main's longer debugger record; main's native-shader case also runs with -Render, so it expects --managed-window too. - tools/startup/debug_launch.py: kept main's grab_window/capture_window split and capture-thread shutdown, with the branch's "not window_close" condition on the final capture. - tools/startup/run.ps1: pass both --capture-every and --managed-window arguments.
|
I merged Conflicts and how I resolved them.
What I ran. I built the whole tree in ctest --test-dir out/build/<preset> --no-tests=error -j 1 --output-on-failure -R '^(startup_output_window_close|startup_present.*|startup_plane.*|startup_debug.*|startup_hook.*|startup_run_ps1.*|startup_run_sh.*|startup_host_cpu_debug.*|startup_window_capture.*|startup_launch.*|startup_runtime_target.*)$'
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
left a comment
There was a problem hiding this comment.
Reviewed 44f14769 (0465ba6d plus a merge of main) trial-merged over current main 7364e6a9. The merge is clean and git diff --cached --check is clean.
R0Y00's request on 5633a0d3. 0465ba6d answers all three points:
- The shared presenter no longer ends the process.
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. - The launcher owns the session's end.
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.- Tests: both close cases now have one.
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 dev and release, then ran
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -E '(_hardware$|startup_audio_)' -R '^(startup_output_window_close|startup_present.*|startup_run_ps1|startup_debug.*|startup_title_window.*|startup_overlay.*|startup_hide.*)$'
# with X2W_TEST_DEBUG_LAYER=1, one at a time
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_present.*_hardware$'- Without
_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.- Full non-hardware suite (
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 dev where needed and ran startup_output_window_close, startup_run_ps1 and startup_present_producer_warp:
| Mutant | Result |
|---|---|
| Close minimizes instead of hiding | killed (startup_output_window_close) |
| launcher ignores the close event | killed (startup_output_window_close) |
| event name not passed to the child | killed (startup_output_window_close) |
no grace wait after TerminateJobObject |
killed (no exit 0x00000000 in events.txt) |
run.ps1 never passes --managed-window |
killed (startup_run_ps1) |
present_to_window ignores output_closed |
survives |
direct Close doesn't show the title windows again (title_hider.step removed) |
survives |
| hide-title timer kept after Close | survives |
| launcher returns 0 when the child doesn't signal exit | survives |
an inherited X2W_SESSION_CLOSE_EVENT not dropped |
survives (the test drops it itself) |
Restored and rebuilt afterwards; git diff --quiet is clean.
Non-blocking.
- After Close, a direct host goes down the "not shown" path.
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. - The launcher's "process did not signal exit" path (return 2) is unpinned. It can't be reached with the current child. A note in the PR text that it's only a safeguard would be enough.
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 on 5633a0d3 still 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 fixtures and Run platform-independent Python checks on Linux pass on 44f14769.
This reply was AI-assisted.
|
I verified the earlier close handling feedback with 44f1476 integrated over main 4d7265c (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. |
|
Thanks for the close-handling rework. I reviewed head
Also worth fixing:
Environment: Linux, static review of git objects, This comment was AI-assisted. |
Change
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).