3

我已经为一个问题烦恼了好几个星期。

我的应用程序的 UI 有时会永远忙碌,光标一圈又一圈,UI 似乎无法接受任何点击事件。这是零星的。

今天我很幸运在我的测试计算机上发生了这种情况。我可以看到这个进程总是占用 25%的 CPU 使用率,而且我的计算机是四核的。我使用“Windbg”并附加了该进程(在此之前我使用“Process Explorer”并发现线程使用最多的资源是 1a24 )。

然后我使用以下命令和相应的输出:

0:011> !threads
ThreadCount:      20
UnstartedThread:  0
BackgroundThread: 10
PendingThread:    0
DeadThread:       8
Hosted Runtime:   no
                                           PreEmptive                                                   Lock
       ID  OSID        ThreadOBJ     State GC       GC Alloc Context                  Domain           Count APT Exception
   0    1  1840 0000000000604c20   2006020 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 STA
   2    2   200 000000000060af60      b220 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 MTA (Finalizer)
XXXX    3       000000001d5cff50     19820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 MTA
  11    4  1a24 000000001d5e1fe0      7020 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 STA
XXXX    5       000000001d64a600   1019820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
XXXX    6       000000001d634c40   1019820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
XXXX    7       00000000244efa40   1019820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
XXXX    8       0000000024547280   1019820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
XXXX    9       0000000024503790   1019820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
  23    a  1754 00000000244c8c40   100a220 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 MTA (Threadpool Worker)
  24    b   d44 00000000245b5020   1000220 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
  25    c  1368 0000000024618140   8009220 Enabled  0000000005f22278:0000000005f236a8 00000000005f89f0     0 MTA (Threadpool Completion Port)
  10    d  1604 0000000024615810       220 Enabled  0000000005f29338:0000000005f296a8 00000000005f89f0     0 Ukn
  29    e  1b5c 00000000244ed820      b220 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 MTA
  30    f  1fb8 00000000246914e0      b220 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 MTA
  16   10   b70 0000000034246b00       220 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn
  28   11  20b8 000000003427bdd0   2000220 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn
XXXX   12       0000000034361dc0  21019820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
XXXX   13       00000000343624d0  21019820 Enabled  0000000000000000:0000000000000000 00000000005f89f0     0 Ukn (Threadpool Worker)
  38   14  1a48 0000000034362be0   1009220 Enabled  0000000005f299d8:0000000005f2b6a8 00000000005f89f0     0 MTA (Threadpool Worker)
0:011> !clrstack
OS Thread Id: 0x1a24 (11)
Child SP         IP               Call Site
0000000020f55b10 000000005d221fc8 [NDirectMethodFrameStandalone: 0000000020f55b10] System.Windows.Media.Composition.MilCoreApi.MilUtility_PolygonHitTest(System.Windows.Media.Composition.MilMatrix3x2D*, System.Windows.Media.Composition.MIL_PEN_DATA*, Double*, System.Windows.Point*, Byte*, UInt32, UInt32, Double, Boolean, System.Windows.Point*, Boolean ByRef)
0000000020f55a90 000007fee273aa54 DomainBoundILStubClass.IL_STUB_PInvoke(System.Windows.Media.Composition.MilMatrix3x2D*, System.Windows.Media.Composition.MIL_PEN_DATA*, Double*, System.Windows.Point*, Byte*, UInt32, UInt32, Double, Boolean, System.Windows.Point*, Boolean ByRef)
0000000020f55bc0 000007fee26f8459 System.Windows.Media.Geometry.ContainsInternal(System.Windows.Media.Pen, System.Windows.Point, Double, System.Windows.Media.ToleranceType, System.Windows.Point*, UInt32, Byte*, UInt32)
0000000020f55d00 000007fee2dbbc07 System.Windows.Media.LineGeometry.ContainsInternal(System.Windows.Media.Pen, System.Windows.Point, Double, System.Windows.Media.ToleranceType)
0000000020f55e50 000007fee309cd23 System.Windows.Media.HitTestWithPointDrawingContextWalker.DrawGeometry(System.Windows.Media.Brush, System.Windows.Media.Pen, System.Windows.Media.Geometry)
0000000020f55f00 000007fee2dce89d System.Windows.Media.HitTestDrawingContextWalker.DrawLine(System.Windows.Media.Pen, System.Windows.Point, System.Windows.Point)
0000000020f55f90 000007fee26d4907 System.Windows.Media.RenderData.DrawingContextWalk(System.Windows.Media.DrawingContextWalker)
0000000020f56390 000007fee26f86b0 System.Windows.Media.RenderData.HitTestPoint(System.Windows.Point)
0000000020f563e0 000007fee2c29a6e System.Windows.Media.DrawingVisual.HitTestCore(System.Windows.Media.PointHitTestParameters)
0000000020f56460 000007fee26ab086 System.Windows.Media.Visual.HitTestPointInternal(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f56490 000007fee26aae70 System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f568e0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f56d30 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f57180 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f575d0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f57a20 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f57e70 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f582c0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f58710 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f58b60 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f58fb0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f59400 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f59850 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f59ca0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5a0f0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5a540 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5a990 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5ade0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5b230 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5b680 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5bad0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5bf20 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5c370 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5c7c0 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5cc10 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5d060 000007fee26aad2c System.Windows.Media.Visual.HitTestPoint(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.PointHitTestParameters)
0000000020f5d4b0 000007fee26aa7c6 System.Windows.Media.Visual.HitTest(System.Windows.Media.HitTestFilterCallback, System.Windows.Media.HitTestResultCallback, System.Windows.Media.HitTestParameters)
0000000020f5d560 000007fee26a4d40 System.Windows.UIElement.InputHitTest(System.Windows.Point, System.Windows.IInputElement ByRef, System.Windows.IInputElement ByRef)
0000000020f5d640 000007fee26ddf11 System.Windows.Input.MouseDevice.LocalHitTest(Boolean, System.Windows.Point, System.Windows.PresentationSource, System.Windows.IInputElement ByRef, System.Windows.IInputElement ByRef)
0000000020f5d720 000007fee26ddbdf System.Windows.Input.MouseDevice.GlobalHitTest(Boolean, System.Windows.Point, System.Windows.PresentationSource, System.Windows.IInputElement ByRef, System.Windows.IInputElement ByRef)
0000000020f5d880 000007fee2ba87e0 System.Windows.Input.MouseDevice.GlobalHitTest(Boolean, System.Windows.Point, System.Windows.PresentationSource)
0000000020f5d8e0 000007fee308d638 System.Windows.Input.MouseDevice.PreNotifyInput(System.Object, System.Windows.Input.NotifyInputEventArgs)
0000000020f5db60 000007fee26ccc69 System.Windows.Input.InputManager.ProcessStagingArea()
0000000020f5dbf0 000007fee26dc66d System.Windows.Input.MouseDevice.Synchronize()
0000000020f5dca0 000007fee26df32d System.Windows.Input.InputManager.HitTestInvalidatedAsyncCallback(System.Object)
0000000020f5dce0 000007fee478d11a System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
0000000020f5dd40 000007fee478d0a7 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
0000000020f5dda0 000007fee49ba6ad System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate, System.Object, Int32, System.Delegate)
0000000020f5de00 000007fee4791105 System.Windows.Threading.DispatcherOperation.InvokeImpl()
0000000020f5deb0 000007fef6103188 System.Threading.ExecutionContext.runTryCode(System.Object)
0000000020f5e5d8 000007fef70935b4 [HelperMethodFrame_PROTECTOBJ: 0000000020f5e5d8] System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
0000000020f5e700 000007fef60f17f1 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
0000000020f5e760 000007fef60f173b System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000000020f5e7b0 000007fee4790f3d System.Windows.Threading.DispatcherOperation.Invoke()
0000000020f5e820 000007fee478abff System.Windows.Threading.Dispatcher.ProcessQueue()
0000000020f5e8d0 000007fee478af53 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
0000000020f5e990 000007fee478d440 MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
0000000020f5ea40 000007fee478d2b7 MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
0000000020f5ea90 000007fee478d11a System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
0000000020f5eaf0 000007fee478d0a7 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
0000000020f5eb50 000007fee49ba6ad System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate, System.Object, Int32, System.Delegate)
0000000020f5ebb0 000007fee478a258 System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
0000000020f5ec70 000007fee478c914 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
0000000020f5eda0 000007fee4936cc0 DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int32, Int64, Int64)
0000000020f5f0d8 000007fef7035757 [NDirectMethodFrameStandalone: 0000000020f5f0d8] MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
0000000020f5f0a0 000007fee47b0ff0 DomainBoundILStubClass.IL_STUB_PInvoke(System.Windows.Interop.MSG ByRef)
0000000020f5f170 000007fee478943a System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
0000000020f5f250 000007ff0017d0d8 MyApplication.StartWindow()
0000000020f5f2e0 000007fef60f182c System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
0000000020f5f340 000007fef60f173b System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000000020f5f390 000007fef6186f9d System.Threading.ThreadHelper.ThreadStart()
0000000020f5f7e8 000007fef70935b4 [GCFrame: 0000000020f5f7e8] 
0000000020f5fbd0 000007fef70935b4 [DebuggerU2MCatchHandlerFrame: 0000000020f5fbd0] 
0:011> ~11s

我发现只找到调用堆栈是“0000000020f5f250 000007ff0017d0d8 MyApplication.StartWindow()”。并且不能遵循以下调用堆栈。

并且任何时候我从“Process Explorer”中找到当前线程“CallStack”是:

wpfgfx_v0400.dll!RenderOptions_IsSoftwareRenderingForcedForProcess+0x23b95
wpfgfx_v0400.dll!RenderOptions_IsSoftwareRenderingForcedForProcess+0x24ec7
wpfgfx_v0400.dll!RenderOptions_IsSoftwareRenderingForcedForProcess+0x242bc
wpfgfx_v0400.dll!WgxConnection_Create+0x2a39
wpfgfx_v0400.dll!MilCompositionEngine_DeinitializePartitionManager+0x398f
wpfgfx_v0400.dll!MilUtility_PolygonBounds+0x705
wpfgfx_v0400.dll!MilUtility_PolygonBounds+0x742
wpfgfx_v0400.dll!MilUtility_PolygonBounds+0x610
wpfgfx_v0400.dll!MilCompositionEngine_DeinitializePartitionManager+0x3aad
wpfgfx_v0400.dll!MilCompositionEngine_DeinitializePartitionManager+0x39c7
wpfgfx_v0400.dll!MilUtility_PathGeometryBounds+0x1993
wpfgfx_v0400.dll!RenderOptions_IsSoftwareRenderingForcedForProcess+0x235ea
wpfgfx_v0400.dll!WgxConnection_Create+0x204ee
clr.dll+0x17c7
PresentationCore.ni.dll+0x33aa54
PresentationCore.ni.dll+0x2f8459
PresentationCore.ni.dll+0x9bbc07
PresentationCore.ni.dll+0xc9cd23
PresentationCore.ni.dll+0x9ce89d
PresentationCore.ni.dll+0x2d4907
PresentationCore.ni.dll+0x2f86b0
PresentationCore.ni.dll+0x829a6e
PresentationCore.ni.dll+0x2ab086
PresentationCore.ni.dll+0x2aae70
PresentationCore.ni.dll+0x2aad2c
PresentationCore.ni.dll+0x2aa7c6
PresentationCore.ni.dll+0x2a4d40
PresentationCore.ni.dll+0x2ddf11
PresentationCore.ni.dll+0x2ddbdf
PresentationCore.ni.dll+0x7a87e0
PresentationCore.ni.dll+0xc8d638
PresentationCore.ni.dll+0x2ccc69
PresentationCore.ni.dll+0x2dc66d
PresentationCore.ni.dll+0x2df32d
WindowsBase.ni.dll+0x11d11a
WindowsBase.ni.dll+0x11d0a7
WindowsBase.ni.dll+0x34a6ad
WindowsBase.ni.dll+0x121105
mscorlib.ni.dll+0x383188
clr.dll!StrongNameErrorInfo+0x53f34
clr.dll!StrongNameErrorInfo+0x54049
clr.dll!StrongNameErrorInfo+0x540c5
clr.dll!CoUninitializeEE+0x32872
clr.dll!CoUninitializeEE+0x32691
mscorlib.ni.dll+0x3717f1
mscorlib.ni.dll+0x37173b
WindowsBase.ni.dll+0x120f3d
WindowsBase.ni.dll+0x11abff
WindowsBase.ni.dll+0x11af53
WindowsBase.ni.dll+0x11d440
WindowsBase.ni.dll+0x11d2b7
WindowsBase.ni.dll+0x11d11a
WindowsBase.ni.dll+0x11d0a7
WindowsBase.ni.dll+0x34a6ad
WindowsBase.ni.dll+0x11a258
WindowsBase.ni.dll+0x11c914
WindowsBase.ni.dll+0x2c6cc0
clr.dll!CoUninitializeEE+0x31a67
USER32.dll!TranslateMessageEx+0x2a1
USER32.dll!TranslateMessage+0x1ea
clr.dll+0x17c7
WindowsBase.ni.dll+0x140ff0
WindowsBase.ni.dll+0x11943a

谁能帮忙告诉我如何找到解决这个问题的方法?

4

0 回答 0