startup: keep fallback GDI off the swap-chain presenter #1235
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1242"
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 R0Y00 on 2026-11-24T05:01:48Z.
Refs #870 and #874.
The swap chain and diagnostic GDI overlay use separate HWNDs. The fallback enumerated all visible, unowned top-level windows of the process, so z-order or closing the guest window could send a diagnostic background fill to the swap-chain presenter. Exclude the presenter class and query a currently visible, unowned guest window at draw time.
Tested commit
ac4bd0ccin MSVC Release on Windows build 26200. Built the runtime DLL. The source-built Win32 regression created the presenter, guest, hidden and owned windows, then changed stacking order and destroyed the guest. The overlay selected the guest in both z-orders, and found no target with only the presenter and ineligible windows present. One test passed, zero skips. No title-side inputs required.This reproduces a fallback-window selection error. Confirming whether a reported periodic dark frame uses that fallback needs a corresponding surface/Present trace.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:07:45Z.
Review: COMMENTED
Reviewed PR #1242 at commit
ac4bd0cc(ac4bd0cc0d3621496d9fcbd8d0437b61253f9743).Findings
src/startup_stubs/overlay_window.h,src/startup_stubs/d3d12_xs_device.cpp,src/startup_stubs/d3d12_present.inl): Sharingx2w_startup::presenter_class(L"X2WOutputWindow") and queryingEnumWindowsat draw time fixes both the presenter-selection bug and stalestatic HWNDcaching across z-order changes or guest window destruction.draw_overlaystill has a benign TOCTOU window betweenoverlay_window()returning anHWNDandGetDC/FillRectif the guest window is destroyed concurrently on another thread (GetDCreturningnullptris guarded; subsequent GDI calls fail harmlessly).CMakeLists.txtinsertsstartup_overlay_window'sadd_executable/target_*/add_testblock betweenadd_executable(startup_dump_fence_check ...)andstartup_dump_fence_check'starget_*calls (lines 8–16); functionally valid in CMake, just slightly interleaved.AGENTS.mdtitle-neutrality is preserved across code, tests, anddocs/startup-runtime.md.Verification (Linux host)
Windows MSVC build and Win32 test
startup_overlay_windowwere not run locally on this Linux environment.Commands run on
ac4bd0cc:git diff --check $(git merge-base origin/main HEAD)..HEAD-> exit 0 (clean)/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py-> passed (Self-test passed. Checked 16 Markdown files and 280 links., 0 fail, 0 skip)/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py-> passed (Self-test passed. Checked 1050 tracked source, script and build/CI files: no bidirectional controls., 0 fail, 0 skip)/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py-> passed (form coverage checks passed, 0 fail, 0 skip)