Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF render thread hangs

Tags:

I'm experiencing a problem in a wpf app where the render thread stops rendering, but the UI thread and helper threads are still pumping messages.

It appears to be related to the corruption of the presentation font cache, however this seems unlikely, as the app recovers fine on reboot.

The render thread will occasionally hang, preventing drawing updates, but the UI thread is still pumping messages.

We have seen a similar issue (similar to here) that occured when applying a scale transform to a textblock that was solved by deleting the font cache, however this particular problem is not reliably repeatable.

What is the best way to diagnose the root cause of this problem?

I have open a bug with microsoft at connect, but it will not be considered unless others vote it up.

like image 377
LukeN Avatar asked May 26 '11 01:05

LukeN


1 Answers

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.

like image 195
LukeN Avatar answered Nov 17 '22 02:11

LukeN