[WpfGfx] RenderTargetBitmap can produce blank output in headless sessions
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
# [WpfGfx] RenderTargetBitmap can produce blank output in headless sessions
## Summary
RenderTargetBitmap may produce blank images when an app runs without attached display devices.
## Observed behavior
- Rendered bitmap output is blank in headless or temporarily display-detached environments.
- The issue is intermittent but can persist until display topology is restored.
## Repro notes
1. Start a WPF app that uses `RenderTargetBitmap.Render`.
2. Run the app in a session where no display devices are currently available (for example, a disconnected remote environment).
3. Trigger bitmap rendering and inspect the result.
## Impact
- Breaks scenarios that depend on off-screen bitmap generation.
- Affects remote/headless workflows and reconnect scenarios where image output must remain reliable.
## Expected behavior
`RenderTargetBitmap.Render` should render valid bitmap content even when no display is attached for this UI-thread synchronous rendering path.
## Actual behavior
Rendering can be skipped when display state is invalid, causing blank bitmap output.
## Suspected root cause
The composition pipeline blocks rendering on invalid display state unless a compatibility switch is enabled globally. The synchronous UI-thread bitmap rendering path needs a targeted override.
## Proposed fix direction
- Thread a `canRenderWithoutDisplayDevices` flag through `Partition::Compose` and `CComposition::ProcessComposition`.
- Pass `true` for the UI-thread synchronous compose path used by `RenderTargetBitmap`-style rendering.
- Pass `false` in the regular partition-thread rendering path to preserve existing default behavior.
- Keep compatibility-switch behavior intact as an additional opt-in path for general rendering.
Contributor guide
Assessment
This issue has not been assessed yet.