Skip to content

WPF App crashes due to COMException (UCEERR_RENDERTHREADFAILURE) from System.Windows.Media.Composition.DUCE.Channel.SyncFlush #3100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SamBent opened this issue Jun 8, 2020 · 10 comments
Assignees
Labels
Bug Product bug (most likely)
Milestone

Comments

@SamBent
Copy link
Contributor

SamBent commented Jun 8, 2020

Problem description: HostVisual interacts with its rendering channel on the wrong thread. This can lead to render thread failures, perhaps minutes or hours after the bad interaction.

[Port of servicing fix for .NET 4.7-4.8]

@fabiant3 fabiant3 added the Bug Product bug (most likely) label Jun 22, 2020
@fabiant3 fabiant3 added this to the 5.0.0 milestone Jun 22, 2020
@BrannonKing
Copy link

Is this a duplicate of #128?

@jakeyeagley
Copy link

I'm also seeing this issue. Here is my stack trace.

System.Runtime.InteropServices.COMException (0x88980406): UCEERR_RENDERTHREADFAILURE (Exception from HRESULT: 0x88980406)
at MS.Internal.HRESULT.Check(Int32 hr)
at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()
at System.Windows.Media.MediaContext.CompleteRender()
at System.Windows.Media.MediaContext.CreateChannels()
at System.Windows.Media.MediaSystem.ConnectChannels(MediaContext mc)
at System.Windows.Media.MediaContext..ctor(Dispatcher dispatcher)
at System.Windows.Media.MediaContext.From(Dispatcher dispatcher)
at System.Windows.Media.MediaContext.RegisterICompositionTarget(Dispatcher dispatcher, ICompositionTarget iv)
at System.Windows.Media.VisualTarget..ctor(HostVisual hostVisual)

@SamBent
Copy link
Contributor Author

SamBent commented Aug 12, 2020

SyncFlush is a catch-all for all render thread failures. The callstack just shows how the main thread learned that the render thread failed, without telling us anything at all about the failure.

This issue addresses a very specific failure, caused by the HostVisual element doing work on the wrong thread. It is not a dupe of #128, and is unlikely to be @jakeyeagley's issue (unless maybe you're using HostVisual).

@BrannonKing
Copy link

BrannonKing commented Aug 13, 2020

There's something wrong with .NET Framework 4.8.4200.0 -- that version specifically that came out just recently and was applied via Windows Update over the last few days. That's causing complete breakage of HostVisual, throwing this COMException error. The specific patch is TBD. If you're on Windows build 2004, you can uninstall KB4569745 to repair the issue (and go back to Framework version 4180). If you have KB4562900 installed, you may have success removing that update.

@SamBent
Copy link
Contributor Author

SamBent commented Aug 13, 2020

One problem was reported this week: it occurs when two (or more) HostVisual elements disconnect at (roughly) the same time, and the threads involved interleave in the wrong way. If this doesn't apply to your problem, tell me more.

We have a fix for the new problem, but it will take some time to push it through the Windows Update process. Meanwhile you can opt out of the HostVisual change in the recent update by setting "Switch.System.Windows.Media.HostVisual.DisconnectsOnWrongThread=true", using instructions here.

You should remove the switch when the new fix is published, to guard against the original bug.

@BrannonKing
Copy link

Sweet! A workaround! Thank you. Your problem description does describe my issue.

@superware
Copy link

One problem was reported this week: it occurs when two (or more) HostVisual elements disconnect at (roughly) the same time, and the threads involved interleave in the wrong way. If this doesn't apply to your problem, tell me more.

I'm still getting this exception on 4.8.4300.0 with multiple displays when disconnecting one of the screens. Should this happen? Is there a workaround and/or fix coming?

Thanks!

@SamBent
Copy link
Contributor Author

SamBent commented Jan 6, 2021

@superware Your problem is almost certainly unrelated to this issue. The same exception is just a coincidence - see here for a full discussion. Please open a new issue to track your problem, following the advice in the doc. To set expectations, there may be nothing WPF can do about it - disconnecting a screen is a pretty violent action that may disrupt lower-level components (graphics drivers, DX, etc) beyond WPF's ability to cope. Meanwhile, the obvious workaround is "don't do that".

@vatsan-madhavan
Copy link
Member

disconnecting a screen is a pretty violent action that may disrupt lower-level components (graphics drivers, DX, etc) beyond WPF's ability to cope.

From what I understood about how this works, WPF relies on DdQueryDisplaySettingsUniqueness/GdiEntry13 to listen to mode changes - which treats screen disconnection at par with more common events like screen lock/unlock, remote-desktop connection/disconnection, DPI change etc. events. IIRC WPF simply re-enumerates the display-adapter and monitor topology every time the retval from DdQueryDisplaySettingsUniqueness changes.

For e.g., I believe that monitor-disconnections (and even display-adapter disconnections) - frequently involving changes to multimon topology - is 'seen' by WPF when RDP to console (or vice-versa) transitions happen.

@SamBent
Copy link
Contributor Author

SamBent commented Aug 17, 2021

Fixed in 3.1.19, 5.0.0, and 6.0.

[Reminder: that's only the HostVisual crash. For other crashes with the same callstack, see here.]

@SamBent SamBent closed this as completed Aug 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Product bug (most likely)
Projects
None yet
Development

No branches or pull requests

6 participants