28

I get this exception in my application. I have found links discussing it on the web but nothing indicating how to track it down and/or workaround it.

Please do not reply with links from the internet. Please reply with strategies of tracking the source. Please reply with workarounds if you found them.

Source: PresentationCore
Message: Exception from HRESULT: 0x88980406
Stack Trace:
   at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()
   at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)
   at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)
   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
cbuteau
  • 736
  • 1
  • 7
  • 15
  • 2
    i think this post can be helpful, the accepted answer contains a list of tactics to debug this issue. http://stackoverflow.com/questions/1944577/win32-window-in-wpf – invalidusername Mar 18 '13 at 15:39
  • 2
    There is a very good MSDN blog describing this issue in depth. The short answer is that there is no single cause: https://blogs.msdn.microsoft.com/dsui_team/2013/11/18/wpf-render-thread-failures/. – RB. May 18 '16 at 08:48

3 Answers3

10

This is old, but I will answer anyways, since I had the same issue that I just resolved.https://stackoverflow.com/a/18003004/1415307

Basically, my issue with this error came down to an outdated video card driver. After updating to the newest driver, the issue has been resolved.

Community
  • 1
  • 1
TrialAndError
  • 1,784
  • 3
  • 20
  • 41
9

In my case it turned out the application in question was already pressing up on memory limits of its specced hardware. Any time I added code that used a decent amount of memory this would crop up.

I ended up using a MemoryFailPoint mechanism when I implemented a feature that placed processing an image buffer on another thread.

https://learn.microsoft.com/en-us/dotnet/api/system.runtime.memoryfailpoint

First implementation did the trick but after many tries QA caused a OOM bomb. So I implemented a MemoryFailPoint() with GC.Collect() loop (hackish I know...but sometimes...get er done).

The main things I learned were:

  1. This is a really bad bug in WPF.
  2. You only have to worry about it if you have truly consumed an inordinate amount of memory.
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
cbuteau
  • 736
  • 1
  • 7
  • 15
  • I am seeing same exception on one user computer (only one out of 30!?) I don't understand neither exact cause of the problem, nor the solution. Can you please help? Could you please send some code how did you use MemoryFailPoint and expecially how did you forced GarbageCollector to free some memory? thank you – lot Mar 21 '14 at 15:59
  • And also, I don't understand why would my app take too much memory. It usually has about 50MB of RAM in Task Manager and that computer has 2GB. Only thing I can think about is broken Garbage Collector. My users are are working whole day, constantly opening and closing forms. While about two dozens users are doing just fine, this particular one is getting OutOfMemory exception or this specific exception mentioned in original topic. – lot Mar 21 '14 at 16:03
  • Hi @lot sorry I did not see your comments until StackExchange emailed me. You can try analyzing your code for points where you may be holding references to objects so the GC can do its job. – cbuteau Mar 23 '14 at 00:20
  • You can investigate whether moving to a different version of .NET is possible. In my case (the past) moving to another version of .NET was not possible. I have been using 4.5 in my current position and have not seen this problem at all (_thank god_). But it is a **bug**. It is either related to how much you are pressing the WPF framework and DirectX itself...or the drivers on the problematic system. Investigate these things first...and good luck. – cbuteau Mar 23 '14 at 00:31
4

With Microsoft's excellent help, we just solved a SyncFlush problem that has plagued us for more than a year. It turns out that we were creating multimedia timers in native code, but we weren't freeing them every time. More specifically, we called timeBeginPeriod and timeEndPeriod, but we called begin more times than end, thus creating a resource leak. The WPF rendering thread needs to use those timers, but we exhausted a limited supply of them (perhaps 65k). The result was that the rendering thread stopped rendering and either hung or caused a crash. Watch out for timers!

Dale Barnard
  • 779
  • 1
  • 7
  • 16