问题
Note - this question is a follow-up to Find infinite loop in progress in a modal form?. Once I learned how to debug that issue, it raised this question.
I have a rare condition which causes my WPF app to consume maximum CPU and the GUI become unresponsive. Based on the high CPU usage it obviously is running (not blocked externally)
Using Process Explorer I can see that in the stack trace nearly all the time is being spent inside functions in wpfgfx_v0400.dll
, mostly in functions Utility_PolygonBounds
or Utility_PathGeometryBounds
. I'm not sure what that means.
Here's an example stack trace:
ntoskrnl.exe!KeSynchronizeExecution+0x5c16
ntoskrnl.exe!KeWaitForMutexObject+0x1070
ntoskrnl.exe!KeWaitForMutexObject+0x9ee
ntoskrnl.exe!KeWaitForMutexObject+0x1c9
ntoskrnl.exe!ExWaitForRundownProtectionRelease+0x763
ntoskrnl.exe!KeWaitForMutexObject+0x2c10
ntoskrnl.exe!KeSynchronizeExecution+0x2e1c
wpfgfx_v0400.dll!MilUtility_PolygonBounds+0xb0d
wpfgfx_v0400.dll+0xc860
By refreshing the stack trace repeatedly I can see that 90% of the time is being spent in one of these wwpfgfx... functions.
I've set numerous breakpoints in any WPF-related code / code-behind, and none of them are hit. Furthermore, if I manually 'break' in the C# debugger, the CPU usage REMAINS very high, and I can see in Process Explorer that the unmanaged wpf_gfx stuff continues to run. So it seems like it never returns back to the app's own code.
How can I debug or figure out what is going wrong here?
Note: It was suggested in a comment that "using shadowing effects, drop shadows, especially around windows borders, could cause this. The idea being that when a shadow (or a similar effect) is drawn around the edges, it breaks the rectangle calculations and the window is redrawn continuously, even when it's not required. CPU usage goes very high." But my app is not using these effects, even though this describes what seems to be happening.
来源:https://stackoverflow.com/questions/57219993/app-frozen-inside-wpfgfx-v0400-dll-utility-polygonbounds-and-utility-pathgeometr