UCEERR_RENDERTHREADFAILURE when hosting ElementHost within WindowsFormsHost
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version:
Did not find a quick way doing this in .net core
* Have you experienced this same bug with .NET Framework?:
Yes
.net 4.8
**Problem description:**
I have a hybrid WinForms/WPF (so I'm not sure if its a WinForms or WPF issue) application with an ElementHost. The child element is a WPF UserControl with a TabControl. Via the ItemsSource different types of tabs are displayed.
1. WinForms Controls, integrated via a WindowsFormsHost
2. WPF Controls, directly through the ElementHost
3. WPF Control, provided via a WinForms UserControl, hosted on a WindowsFormsHost, which displays a WPF Control via an ElementHost
The third case seems pretty crazy and stupid, but is the case.
Switching between the tabs, the application crashes pretty fast with 2 exceptions.
1st UCEERR_RENDERTHREADFAILURE System.Windows.Media.Composition.DUCE+Channel.SyncFlush
2nd FATAL_USER_CALLBACK_EXCEPTION An unhandled exception was encountered during a user callback.
```
PresentationCore_ni!System.Windows.Media.Composition.DUCE+Channel.SyncFlush+0x98b9ae
PresentationCore_ni!System.Windows.Media.MediaContext.CompleteRender+0x57
PresentationCore_ni!System.Windows.Interop.HwndTarget.OnResize+0x1cb
PresentationCore_ni!System.Windows.Interop.HwndTarget.HandleMessage+0x2f4
PresentationCore_ni!System.Windows.Interop.HwndSource.HwndTargetFilterMessage+0x3f
WindowsBase_ni!MS.Win32.HwndWrapper.WndProc+0xc4
WindowsBase_ni!MS.Win32.HwndSubclass.DispatcherCallbackOperation+0x84
WindowsBase_ni!System.Windows.Threading.ExceptionWrapper.InternalRealCall+0x68
WindowsBase_ni!System.Windows.Threading.ExceptionWrapper.TryCatchWhen+0x36
WindowsBase_ni!System.Windows.Threading.Dispatcher.LegacyInvokeImpl+0x172
WindowsBase_ni!MS.Win32.HwndSubclass.SubclassWndProc+0x152
WindowsBase_ni!MS.Win32.UnsafeNativeMethods.CallWindowProc+0x1
WindowsBase_ni!MS.Win32.HwndSubclass.DefWndProcWrapper+0x97
WindowsBase_ni!MS.Win32.UnsafeNativeMethods.CallWindowProc+0x1
WindowsBase_ni!MS.Win32.HwndSubclass.SubclassWndProc+0x1e2
```

**Expected behavior:**
The render thread failure is not random and always renders on the correct thread.
**Minimal repro:**
https://github.com/AndreasBreuninger/ElementHost_RenderError
CrashDumps included.
**Related issues**
These issues seem to be related, but still different. They all rely on the HostVisual element.
[wpf/128](https://github.com/dotnet/wpf/issues/128)
[wpf/3100](https://github.com/dotnet/wpf/issues/3100)
[wpf/3567](https://github.com/dotnet/wpf/pull/3567)
Also checked the release notes of [kb4562900-cumulative-update-for-net-framework](https://support.microsoft.com/en-us/help/4562900/kb4562900-cumulative-update-for-net-framework)
Contributor guide
Assessment
This issue has not been assessed yet.