Skip to content

startup: output-window close review follow-up - #3342

Open
romn4rch wants to merge 4 commits into
R0Y00:mainfrom
romn4rch:copilot/pr-2344-review-a2cb59d5
Open

romn4rch wants to merge 4 commits into
R0Y00:mainfrom
romn4rch:copilot/pr-2344-review-a2cb59d5

Conversation

@romn4rch

Copy link
Copy Markdown
Contributor

Replacement submission for #2344. This branch contains the existing output-window close work plus the verified review follow-up commit. The original PR remains open because its author-owned branch was not writable from this account; these PRs overlap in scope, so please keep only one submission and close/mark the other as superseded when choosing.

Validation: startup_present_producer built successfully, and startup_output_window_close, startup_present_producer_warp, and startup_run_ps1 passed (3/3).

SuperCraft3M and others added 4 commits November 25, 2026 22:30
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.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean follow-up that wires output-window Close through both host modes.

  • WM_CLOSE handler signals X2W_SESSION_CLOSE_EVENT for managed windows and hides the window for direct hosts.
  • present loop respects the output_closed flag.
  • debug_launch.py creates and monitors the close event in managed mode, terminates the job, and logs the event.
  • run.ps1 passes --managed-window when -Render is used.
  • Test fixture covers minimize → restore → close → timer path.
  • CMake wiring adds the test to the smoke preset.

The approach is consistent with existing session-close patterns in the codebase.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean follow-up that wires output-window Close through both host modes.

  • WM_CLOSE handler signals X2W_SESSION_CLOSE_EVENT for managed windows and hides the window for direct hosts.
  • present loop respects the output_closed flag.
  • debug_launch.py creates and monitors the close event in managed mode, terminates the job, and logs the event.
  • run.ps1 passes --managed-window when -Render is used.
  • Test fixture covers minimize → restore → close → timer path.
  • CMake wiring adds the test to the smoke preset.

The approach is consistent with existing session-close patterns in the codebase.

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head a2cb59d5 against main 212d4b5f by reading the diff and git objects, plus git merge-tree. Nothing was built or run.

Verdict: comment. The close handling answers the changes request on #2344, and the pr preset now lists the affected tests, but the branch conflicts with main.

  1. Conflict in tools/startup/run.ps1. git merge-tree --write-tree 212d4b5f a2cb59d5 exits 1 with CONFLICT (content) there. main (539c3ad) appends @holdArgs to the same debugger line where this PR appends @windowArgs. Keeping both as @captureArgs @holdArgs @windowArgs, with both $holdArgs and $windowArgs definitions, matches the auto-merged startup_run_ps1_check.py: it appends --managed-window 1 after the passed arguments, and its -SuspendOthers cases don't pass -Render. The other files auto-merge.

  2. Dropping the inherited event name is still unpinned. debug_launch.py:221 drops an inherited X2W_SESSION_CLOSE_EVENT, but the check passes its stale name (startup_output_window_close_check.py:23) only together with --managed-window 1, and debug_launch.py:229 then overwrites the value. With line 221 removed the check still passes. A launcher run without --managed-window and with a stale name would cover it: with the pop removed, the child takes the managed branch and exits 22 (startup_present_producer.cpp:170-172) instead of 0.

What checks out:

  • d3d12_present.inl:39-54: Close no longer minimizes (main :39) and does not exit the process. With an event it can open and set, it returns. Otherwise it marks the output closed, stops the hider timer, shows the hidden windows again and hides the output window. present_to_window refuses after Close (:179), so d3d12_xs_device.cpp:7381 records the frame as not shown. That is what the changes request on #2344 asked for: the launcher ends the session, and a direct host stays alive.
  • No test on main asserts the old minimize-on-close behaviour (WM_CLOSE, SC_CLOSE and minimi have no match under tests/, apart from an unrelated shader check).
  • The direct-host case now checks that the hidden helper window comes back (startup_present_producer.cpp:174) and stays visible after a hider timer message (:176-180). By reading, that catches dropping the reshow call at Close. It should also catch present_to_window ignoring the closed flag, provided the present on the hidden window returns a success code.
  • CMake adds only add_test/set_tests_properties, an include path and user32. In CMakePresets.json, the pr build preset gains the startup_present_producer target and the pr test filter gains startup_output_window_close, startup_present_producer_warp and startup_run_ps1. The Windows build-and-test check passes on a2cb59d5.

Minor:

  • The return 2 path at debug_launch.py:1278 is not reached with the test child.
  • --managed-window is missing from the usage text at the top of debug_launch.py; docs/startup-runtime.md:261 mentions it.
  • The body mentions a follow-up commit; those changes are inside the merge commit 2ef859e5, so git diff 44f14769 2ef859e5 -- tests/ shows them.

The body presents this PR as the replacement for #2344, which is still open at 44f14769 (both of its commits are in this branch) and whose changes request is on 5633a0d3.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Review of head a2cb59d5 against main c04e0dd6. I read the diff and git objects only; nothing was built or run.

This needs a rebase. git merge-tree --write-tree origin/main a2cb59d5 exits 1. Since the earlier review on 212d4b5f, main has moved, and the branch now conflicts in three files instead of one:

  • tools/startup/run.ps1: the same debugger line as before. main appends @holdArgs, and this PR appends @windowArgs.
  • tests/startup_run_ps1_check.py: 75db835a ("default to native shaders") changed run_case at the line where this PR adds the --managed-window 1 expectation. main now has native_default = (native or "-Render" in switches) and not translate. Both lines are needed. Every rendered case (translate, native, or -Render in switches) passes -Render, so it still expects --managed-window 1.
  • CMakePresets.json: the pr test filter. main has added entries to the same name regex, so keep both sets.

Checked, by reading, on the default path: without -Render, run.ps1 passes no --managed-window, and debug_launch.py creates no event, so a run without -Render behaves as before apart from the new CreateJobObject, SetInformationJobObject and AssignProcessToJobObject failure exits. A direct shim host, with no X2W_SESSION_CLOSE_EVENT, now hides the output window on Close instead of minimizing it, and present_to_window returns false from then on. That change is documented in docs/startup-runtime.md.

MUST

  1. Rebase onto current main, resolving the three conflicts above. Then re-run startup_run_ps1, because main's native-default expectations and this PR's --managed-window expectation now meet in run_case.

SHOULD / NIT: none beyond the review of 29 November.

Held: not mergeable until rebased.

AI-assisted.

@pigalot pigalot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed a2cb59d5. It conflicts with main 17b662a2, so I built and tested the PR head on its own (it already contains main up to 7e5c378d), not an integrated tree.

I merged main into this branch earlier as 44f14769 (pushed to #2344's branch, which this PR builds on); I checked that resolution again here with git show --remerge-diff 44f14769. It touches only the four conflicted files: present_to_window keeps main's plane-surface signature with the output_closed check added, the final window capture keeps not window_close, run.ps1 passes both @captureArgs and @windowArgs, and startup_run_ps1_check.py expects --managed-window 1 for -Render, translate and native cases. Nothing else is in it.

Blocking: conflicts with main. git merge-tree --write-tree 17b662a2 a2cb59d5 reports three files:

  • tools/startup/run.ps1: main appends @holdArgs to the debugger line this PR appends @windowArgs to. Both are needed: @captureArgs @holdArgs @windowArgs.
  • tests/startup_run_ps1_check.py: main (75db835) added native_default and two more record fields next to this PR's want.extend(["--managed-window", "1"]). Keep main's native_default line and expected list, and the PR's two lines.
  • CMakePresets.json: the pr test filter. main added startup_inline_retire_(on|control)_warp, startup_resource_retire_title_inline_warp_debug0, startup_table_lock_(control_)?warp and startup_compute_packed_d16_x_uav_reference; keep those and add this PR's three names.

I have not built those resolutions. Please merge main (a merge, not a rebase) and I will retest the new head.

What I ran at a2cb59d5. Built startup_present_producer and d3d12_xs_shim in dev and release, then

ctest --test-dir out/build/<preset> --no-tests=error -j 1 --output-on-failure -R '^(startup_output_window_close|startup_present_producer_(warp|hardware)|startup_run_ps1.*)$'

4/4 passed in Debug and Release /O2, no skips. git diff --check against main is clean.

Mutants (dev build, startup_output_window_close for the shim and launcher, startup_run_ps1 for run.ps1): 20 run, 14 killed, 5 survive, 1 equivalent.

Killed:

  • shim: event branch disabled (child exits 22); output_closed never set; present_to_window ignoring output_closed; reshow step at Close dropped; minimize instead of hide.
  • launcher: --managed-window test inverted; event name not passed to the child; job not terminated on Close; job exit code 1 instead of 0; close message dropped; no wait after Close.
  • run.ps1: @windowArgs not passed; flag set without -Render; flag value 0.

Survive:

  1. debug_launch.py:221, env.pop("X2W_SESSION_CLOSE_EVENT", None) removed. This confirms Leyukaka's second point: the check only passes the stale name together with --managed-window 1, where line 229 overwrites it. A launcher run with the stale name and no --managed-window would pin it.
  2. debug_launch.py:1278, return 0 if child_stopped else 2 replaced by return 0. The test child always dies with the job, so the failure path is not reached.
  3. debug_launch.py:1257, and not window_close removed from the final capture. Diagnostics only.
  4. d3d12_present.inl:46, if (sent) return 0; removed, and
  5. the same line inverted to if (!sent) return 0;. In both the managed window is also hidden before the job ends it; the test cannot tell.

Equivalent: KillTimer at Close removed. Presents are refused after Close, so a later timer tick sees no shown frame and leaves the title window visible.

None of the survivors blocks; the first is worth a test case while the branch is being updated anyway.

Other notes.

  • The second commit by the author, 2ef859e5, is a merge of main that also carries the follow-up changes (fixture, check, docs, preset, a comment in debug_launch.py); git show --remerge-diff 2ef859e5 shows them. a2cb59d5 is a clean merge.
  • #2344 is still open with the same work up to 44f14769. One of the two should be closed as superseded.
  • Title run of this head (prwatch job 38) ended in an error and gave no verdict, so this review does not rely on one.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; NVIDIA GeForce RTX 5090 driver 32.0.16.1088, debug layer enabled; inbox WARP.
CI: Build and test on Windows passed on a2cb59d5.

This reply was AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants