Skip to content

Prevent GDI+ startup from blocking Windows shell - #628

Merged
coneilen merged 1 commit into
mainfrom
coneilen-microsoft-windows-preview-rebuild
Oct 5, 2026
Merged

coneilen merged 1 commit into
mainfrom
coneilen-microsoft-windows-preview-rebuild

Conversation

@coneilen

@coneilen coneilen commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Prevent optional GDI+ initialization from blocking the Windows UI thread before
the native shell window is created. The beta5 Dev Box evidence narrowed the
90-second no-window hang to synchronous GdiplusStartup; plain GDI remains the
fallback until asynchronous initialization succeeds.

Changes

  • Start process-global GDI+ initialization on a detached worker instead of the
    UI thread.
  • Publish GDI+ availability and coordinate draw sessions/shutdown under one
    mutex, preventing data races and shutdown during active drawing.
  • Keep GDI+ disabled for the existing daemon-handoff and UIA hooks.
  • Add a child-process regression whose startup provider deliberately blocks,
    while the process uses exactly the supported 11-key environment and must
    still expose a native window within a bounded deadline.
  • Register the live regression in the Windows shell suite with explicit
    exited/no-window/window and zero-observation outcomes.

Test plan

RED: pwsh -NoProfile -File Tools\windows\Tests\GdiplusStartup.Live.Tests.ps1 with pinned Zig and Winghostty -> process remained alive but no native window appeared; observations=80; exact 11 keys
GREEN: pwsh -NoProfile -File Tools\windows\Tests\GdiplusStartup.Live.Tests.ps1 with pinned Zig and Winghostty -> PASS; executed=1; observations=2; native window appeared
REGRESSION: pwsh -NoProfile -File Tools\windows\validate.ps1 -Task windows-shell -SkipTrayLive -ShellValidationRoot C:\v7 -> PASS; Windows shell 53/53, App 739/739, scrubbed startup 4/4

  • zig test src\GdiplusAA.zig with pinned Zig: 1/1 passed.
  • Tools\windows\Tests\ValidationRunner.Tests.ps1: passed, including 380
    multi-project protocol contracts.
  • The real source-built shell passed all four exact-environment onboarding
    cases with developer-tool paths excluded.
  • Microsoft documents that GdiplusStartup and GdiplusShutdown may run on
    different threads when GDI+ objects are gone before shutdown. Shutdown is
    therefore invoked only after the message loop, while the mutex prevents
    overlap with active draw sessions.
  • A rebuilt candidate and attended Dev Box rerun are still required. No tag,
    package, release, backend, Worktrees, Nod, dump, or publication action is
    included here.
  • macOS make test and make check were not run because this change is scoped
    to the Windows Zig shell and Windows validation.

Checklist

  • I have read the Contributing Guidelines
  • I have signed off my commits (git commit -s) per the DCO
  • Tests pass locally (make test)
  • Code follows the existing style (make check)
  • I added the test/contract before the implementation and observed the intended RED failure

Initialize optional GDI+ rendering on a detached worker with mutex-protected publication and plain-GDI fallback, and add an exact 11-key child-process native-window regression.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Colin Neilens <[email protected]>
@coneilen
coneilen merged commit a0a1a3e into main Oct 5, 2026
24 checks passed
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.

1 participant