wpf
wpf copied to clipboard
Avoid UCEERR_RENDERTHREADFAILURE
Fixes #9042
Main PR
Description
WPF applications with D3DImage can crash when a monitor is off or unavailable and IDirect3D9.GetAdapterMonitor returns NULL. For example on laptops with connected HDMI external display and display setting “Extend” and control panel “when I close the lid” = “Do nothing”, when closing the lid or on sleep / awake.
Customer Impact
WPF applications crash.
Regression
This bug exists in existing .NET releases like 4.8.
Testing
Take a laptop with connected HDMI external display and set display setting “Extend” and control panel “when I close the lid” = “Do nothing”, then close the lid and check if a WPF application with D3DImage crashes.
Risk
Unclear.
Microsoft Reviewers: Open in CodeFlow
The fix looks reasonable to me and should probably be backported to .NET Framework, did you try out your solution? The "Testing" part is referring to how the PR changes were tested.
No, I have no time to test it sorry. I just run into the crash all the time. Maybe @Const-me tested it. See https://github.com/dotnet/wpf/issues/9042#issuecomment-2112139487
or @vladimir-cheverdyuk-altium, especially since this one requires particular hardware setup
particular hardware setup
A notebook and a monitor?
This also happens with a two monitor setup. Start the application on the primary monitor, disconnect the cable from the machine (the application gets moved to the second screen). Now you have the same exception.
It alsof happens when you remote desktop to a two monitor machine, disconnect the session and reconnect.
Hope these extra cases help to fix the problem faster, it's really annoying.
Thank you @petsuter for the contribution!