startup-tools: save the title's window every N seconds (--capture-every) #2814
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2822"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:40:48Z.
Part of #870
Fixes #2819
What this unblocks: a tester who drives the title with
X2W_INPUT_SCRIPTgets one picture per screen with its time, so a run that stops on a late screen (or never reaches one) can be read from the pictures instead of from the last frame only.What changed
tools/startup/debug_launch.py --capture-every <s>(alsorun.ps1 -CaptureEvery,run.sh --capture-every): saves the title window's client area every N seconds aswindow_<sss>s.png(seconds since the process started) next to the logs. Off by default (0); N below 1, negative or not a number is refused with exit code 2. The end-of-runwindow.pngis unchanged.window captures: 12 saved, 7 unchanged skipped, first change at 74 s, plusfile cap 120 reached (N changed frames dropped)andN ticks without a windowwhen they apply.GetDC+BitBlt+GetDIBits, as before) and writes the file.capture_window()is split intograb_window()(returns the BGRA pixels or the reason there is no window; it now also deletes its bitmap and device context and releases the window DC, which the single end-of-run call never needed) and the PNG writer, which the timer and the end-of-run capture share.tools/startup/window_capture.pyholds the parts that need no Windows API: BGRA to PNG with whole-buffer slice copies instead of the per-byte generator (1920x1080: about 0.3 s at zlib level 1 on random pixels, the old conversion alone took about 0.7 s), file names, duplicate skip, cap, summary.Tests
tests/startup_window_capture_check.py(Linux and Windows, 12 cases): decoded PNG equals a per-pixel reference (sizes 1x1 to 64x3, alpha dropped, channels swapped), a buffer of the wrong size is refused, names arewindow_<sss>s.png(whole seconds, three digits), duplicates are skipped and changes saved, a size change counts as a change, the cap (2 in a small case, 120 by default) stops saving and counts the dropped changes, the summary line, a failing write leaves the counters alone.tests/startup_debug_window_check.py+ new source-builttests/startup_window_probe.cpp(a 160x120 window, red, blue after 3.5 s; no existing fixture had a picture that changes):--capture-every 1 --timeout 9must save exactly one red and one blue file, reportfirst changein the second the probe changes it, skip the other frames, and still writewindow.png(blue). Controls: without the option nowindow_<sss>s.pngand no summary line; intervals0.5,-1,abcare refused. Registered asstartup_debug_window(andstartup_window_capture_check), so-R '^startup_debug'runs it. It exits 77 (ctest SKIP) only when the machine shows no window at all.tests/startup_run_sh_check.pyandtests/startup_run_ps1_check.pyget a case that--capture-every 5/-CaptureEvery 5reaches the debugger (the sh case fails when the wrapper drops it).docs/startup-runtime.md: new "Window pictures" paragraph.Verification
python3 -B tests/startup_window_capture_check.py: 12 tests OKpython3 -B tests/startup_run_sh_check.py: 0 failed (1 failed with the wrapper'scapture_argsremoved);python3 -B tests/startup_run_ps1_check.py: 0 failed (text only, not a Windows host)x86_64-w64-mingw32-g++ -std=c++17 -Wall -Wextra tests/startup_window_probe.cpp -luser32 -lgdi32: builds; the probe printswindow-probe shownandwindow-probe flippedunder Winestartup_debug_window+startup_window_capture_check(dev + release), real window capture: pending Stage-2Source: Microsoft Learn, Win32 GDI (
GetDC,BitBlt,GetDIBits,DeleteObject,DeleteDC,ReleaseDC); W3C PNG Specification, Second Edition, section 11 (IHDR, IDAT, IEND, filter type 0); earlier code of this repo (debug_launch.pycapture_window()).Real-hardware testing: @Makto94 - thanks for the help.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:54:14Z.
@MasterDomino Ready for review: head
0d4a8afe4(Fixes #2819).Independent Stage-2 check on this exact head.
Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP), Proxmox slots, dev and release
/O2:startup_debug_windowreturns the capability skip (77) on this Win2025 host because its session has no visible desktop; a skip is not a pass. It was run with a real window instead on Linux, Wine 10.0 with Xvfb, Windows Python 3.12.8 and the repository'stests/startup_window_probe.cppbuilt with MinGW:So on a real window the periodic files change when the picture changes (red first, blue last, the first change reported at 3 to 6 s), the unchanged frames between them are skipped (2 files saved for a 9 s run at
--capture-every 1), the end-of-runwindow.pngis unchanged, the option is off by default, and an interval below one second, negative or not a number is refused with exit code 2.Controls (one change each in the same real-window run, the check must fail): the duplicate skip disabled (a file every second), every frame hashed as equal (the blue picture never saved), the timer never offering a frame to the series. All three fail the check.
Also run:
startup_window_capture_check.py,startup_run_sh_check.py,startup_run_ps1_check.py(text only off Windows),docs_links_check.py,bidi_controls_check.pypass; the translation break-it comparison againstorigin/main: 173 shapes, all the same.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T11:54:25Z.
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.0d4a8afℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T11:54:27Z.
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T18:37:00Z.
Review: APPROVED
Independently reviewed
0d4a8afeintegrated overmain429f11d5(tree2915e02b, clean merge).This adds a native Windows desktop run of
startup_debug_window. Until now it had been skipped on the Win2025 host (no visible desktop) and had only run under Wine.What I traced. I compared
grab_window()with the removedcapture_window()body. It does the same enumeration, client-rect clamp,BitBltandGetDIBits. It now releases the bitmap, the memory DC and the window DC in afinallyblock. The end-of-runwindow.pnguses the same grab and the newpng_bytes.The capture thread only grabs the window and hands the frame to
Series. An exception or a missing window counts as a miss, and the debug loop never waits on it.The two wrappers pass the option through only when it is non-zero.
What I ran. I built
startup_debug_probe,startup_debug_callsandstartup_window_probeindevandrelease.ctest --test-dir out/build/<preset> --no-tests=error -j 4 --output-on-failure -R '^(startup_debug|startup_debug_log|startup_debug_hooks|startup_debug_launch_args|startup_window_capture_check|startup_run_ps1|startup_run_sh)$'startup_run_shwas a capability skip (no POSIX host), in Debug and Release/O2.ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^startup_debug_window$'startup_debug_window: PASS (red then blue saved once each, unchanged frames skipped, change time reported, window.png unchanged, off by default, bad interval refused).On
main429f11d5,startup_debug_windowandstartup_window_capture_checkare not registered.Mutant. I accepted intervals below one second (
0 < capture_everyinstead of1 <= capture_every). That failsstartup_debug_windowwithAssertionError: ('0.5', 0, ...): the run went ahead and saved captures every 0.5 s. tedin7's three controls cover the duplicate skip and the timer.git diff --checkis clean.Verdict: approve on
0d4a8afe.Environment: Windows 11 25H2 build 26200.9974, interactive desktop session; MSVC 19.52.37029; Python 3.12.10.
CI:
Build and test on Windowspasses on0d4a8afe.This reply was AI-assisted.