dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.1k stars 1.17k forks source link

UCEERR_RENDERTHREADFAILURE when hosting ElementHost within WindowsFormsHost #3719

Open AndreasBreuninger opened 4 years ago

AndreasBreuninger commented 4 years ago

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

Example

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 wpf/3100 wpf/3567

Also checked the release notes of kb4562900-cumulative-update-for-net-framework

RussKie commented 4 years ago

The stack trace is all WPF, so transferring there until it can be established the issue is in our code.

AndreasBreuninger commented 3 years ago

Is there anything new regarding this ticket?

julian-di commented 11 months ago

Hi this is still an issue are there any updates on this?

lindexi commented 11 months ago

@julian-di Do you find the repro?

julian-di commented 11 months ago

@lindexi, what do you mean with repro?

byayex commented 8 months ago

Are there any news on this?

Tim-Bendig commented 3 weeks ago

Are there any updates on this issue / underlaying problem ? Any approach how the bug can be solved or prevented ?