WPF render thread hangs WPF render thread hangs wpf wpf

WPF render thread hangs


The freeze was caused by a hosted activex control rendering video.

There was a race condition in the way the control used directshow which caused directx to hang.

We found this problem by taking a process dump using procdump and then opening the dump file in the windows debugger.

Hunting around on the net and inspecting the native callstacks showed a problem where the high order byte of a critical section pointer was zeroed, which meant that one of the threads was waiting on a non-existent critical section which can never be signaled.

This allowed us to create a repeatable hang by exercising the code that started and stoped the video. We removed the controls, and the hang stopped.


I don't know why it happens, but I have experienced it before. It's easier to observe it in systems that target framework 4.0 and run on older machines (XP, Vista).

What I did to solve was:

  1. Delete FontCache3.0.0.0.dat
  2. Permanently disable the font cache service on the offending machine

Solution 1 worked in one XP machine. It also worked in a Vista machine, but after a while the problem showed up again.

To delete FontCache3.0.0.0.dat you will need to stop the "Windows Presentation Foundation Font Cache 3.0.0.0" service before you can delete that file. In Vista it is located under c:\windows\serviceprofiles\localservice\appdata\local. In XP it is under c:\windows\system32\documents and settings\localservice\local settings\application data (I might have mispelled some folder)

I have also found that disabling the system altogether (solution 2) did not affect the performance of my .net apps.


The only way to find the root cause of the issue is going to be constant logging from the thread until you can find a reason why it hangs. I can suggest lots of ways to do that logging, but it depends on how complex that code in the render thread is. Without having lots of debugging information (the sort of thing that introduces enough latency to temporarily resolve the problem, no less) you're not going to be able to drill down to the one time where it does occur.

If you can repeat it in VS, then you should use some console logging around the anticipated trouble parts, otherwise you're likely going to have to pull it into a textfile, or send it to the system logger.

Can you get it to reoccur in a simple app that only does the rendering and related parts of the rest of the app, or does it only occur (can only occur?) in the full program?