Fix PowerToys Run crashes when DWM desktop composition is disabled#47414
Draft
Copilot wants to merge 4 commits into
Draft
Fix PowerToys Run crashes when DWM desktop composition is disabled#47414Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
Open
- ExceptionHelper.IsRecoverableDwmCompositionException now walks the full exception chain (including inner exceptions) to detect wrapped DWM composition errors - ErrorReporting.HandleException passes the exception directly instead of casting to COMException first, enabling inner-exception checks - ThemeManager.UpdateThemeWithRetryAsync catches any Exception (not just COMException) that represents a DWM composition error, so WPF wrapper exceptions are also handled with retry logic - MainWindow.OnSourceInitialized wraps DwmSetWindowAttribute in a try-catch so a disabled DWM only logs a warning instead of crashing Agent-Logs-Url: https://github.com/microsoft/PowerToys/sessions/9cfe5580-2f9e-4888-863a-659ebdbcb04f Co-authored-by: MuyuanMS <116717757+MuyuanMS@users.noreply.github.com>
Addresses code review feedback - caps inner-exception traversal at 10 levels to prevent pathological overhead while still covering typical 1-3 level wrapping patterns. Agent-Logs-Url: https://github.com/microsoft/PowerToys/sessions/9cfe5580-2f9e-4888-863a-659ebdbcb04f Co-authored-by: MuyuanMS <116717757+MuyuanMS@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/PowerToys/sessions/9cfe5580-2f9e-4888-863a-659ebdbcb04f Co-authored-by: MuyuanMS <116717757+MuyuanMS@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix disabled desktop synthesis in PowerToys
Fix PowerToys Run crashes when DWM desktop composition is disabled
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
PowerToys Run crashes with
COMException: 已禁用桌面合成(HRESULT0x80263001/DWM_E_COMPOSITIONDISABLED) in scenarios where DWM composition is temporarily or permanently unavailable (e.g. RDP sessions, compatibility modes). The existing recovery logic failed to catch DWM errors wrapped in WPF framework exception types.ExceptionHelper.IsRecoverableDwmCompositionExceptionCOMExceptioninside other typesErrorReporting.HandleExceptione as COMException(→nullfor non-COMExceptiontypes) to a method whose signature takesException, making inner-exception detection a no-opedirectlyThemeManager.UpdateThemeWithRetryAsynccatch (COMException ex) when (IsRecoverableDwmCompositionException(ex))misses WPF wrapper typescatch (Exception ex) when (...)— thewhenguard keeps semantics identical for non-DWM exceptionsMainWindow.OnSourceInitializedDwmSetWindowAttribute(rounded corners, Win11 only) was unprotected; a DWM failure here propagated to the global handler, disrupting window initializationtry/catch— only consequence of failure is non-rounded corners (cosmetic)PR Checklist
Detailed Description of the Pull Request / Additional comments
The core detection logic in
IsRecoverableDwmCompositionExceptionnow walks the exception chain:The
HandleExceptionfix removes the redundant narrowing cast that prevented inner-exception detection from working even after this method was updated:Validation Steps Performed
Exception.HResultis a public property in .NET (used consistently elsewhere in the codebase, e.g.ProgramLogger.cs,Log.cs)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
o3svsblobprodcus318.vsblob.vsassets.io/usr/bin/dotnet dotnet build --no-restore(dns block)If you need me to access, download, or install something from one of these locations, you can either: