none
presentationhost.exe running at 50% CPU

    Question

  • Hi,

    We have one user that is seeing high CPU usage with presentationhost.exe when running our WPF app. The user starts the WPF app, the CPU goes immediately to 50% and the UI hangs. This is happening on just one laptop running XP.

    I got the user to run adplus -hang and this is the call stack of the thread that is using the CPU. it looks like the problem might be in wpfgfx_v0300.dll

    Thanks for looking...

    Brian



    0:000> !runaway
     User Mode Time
      Thread       Time
      15:15c0      0 days 0:01:57.656
       0:12b4      0 days 0:00:00.843
      14:158c      0 days 0:00:00.015
      13:1584      0 days 0:00:00.000
      12:1580      0 days 0:00:00.000
      11:14f8      0 days 0:00:00.000
      10:14f4      0 days 0:00:00.000
       9:14ec      0 days 0:00:00.000
       8:14e8      0 days 0:00:00.000
       7:1424      0 days 0:00:00.000
       6:1420      0 days 0:00:00.000
       5:130c      0 days 0:00:00.000
       4:1304      0 days 0:00:00.000
       3:1300      0 days 0:00:00.000
       2:12fc      0 days 0:00:00.000
       1:12f8      0 days 0:00:00.000
    0:000> ~15e !dumpstack
    OS Thread Id: 0x15c0 (15)
    Current frame:  (JitHelp: CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE)
    ChildEBP RetAddr  Caller,Callee
    0579f0e8 578484c3 (MethodDesc 0x577c9d94 +0x13 MS.Internal.Invariant.Assert(Boolean)), calling  (JitHelp: CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE)
    0579f0f0 547f6621 (MethodDesc 0x546a5fbc +0x31 MS.Internal.FontCache.ElementCacher.get_Mapping()), calling (MethodDesc 0x577c9d94 +0 MS.Internal.Invariant.Assert(Boolean))
    0579f10c 547f6945 (MethodDesc 0x546a60d4 +0x35 MS.Internal.FontCache.HashTable.GetElementInfo(Int32* ByRef, ElementHeader* ByRef, MS.Internal.FontCache.CheckedPointer ByRef)), calling (MethodDesc 0x546a5fbc +0 MS.Internal.FontCache.ElementCacher.get_Mapping())
    0579f134 547f677a (MethodDesc 0x546a6140 +0xaa MS.Internal.FontCache.HashTable.Lookup(MS.Internal.FontCache.IFontCacheElement, Boolean)), calling (MethodDesc 0x546a60d4 +0 MS.Internal.FontCache.HashTable.GetElementInfo(Int32* ByRef, ElementHeader* ByRef, MS.Internal.FontCache.CheckedPointer ByRef))
    0579f160 792d9963 (MethodDesc 0x7910eb1c +0x13 System.SZArrayHelper.get_Item[[System.UInt16, mscorlib]](Int32)), calling mscorwks!JIT_IsInstanceOfArray
    0579f174 547feb27 (MethodDesc 0x546a8b58 +0x277 MS.Internal.FontCache.FontCacheAccessor.GetGlyphs(MS.Internal.FontCache.BaseGlyphElement, System.Collections.Generic.IList`1<UInt16>, Void*[])), calling (MethodDesc 0x546a6140 +0 MS.Internal.FontCache.HashTable.Lookup(MS.Internal.FontCache.IFontCacheElement, Boolean))
    0579f1bc 547fe7a7 (MethodDesc 0x54617644 +0xd7 MS.Internal.FontCache.FontCacheAccessor.GetBitmaps(System.String, Int32, Int32, Int32, UInt16, UInt16, UInt16, Int32, UInt16[], Void*[])), calling (MethodDesc 0x546a8b58 +0 MS.Internal.FontCache.FontCacheAccessor.GetGlyphs(MS.Internal.FontCache.BaseGlyphElement, System.Collections.Generic.IList`1<UInt16>, Void*[]))
    0579f1f0 547fe682 (MethodDesc 0x54617638 +0x82 MS.Internal.FontCache.FontCacheAccessor.CreateGlyphBitmapsHelper(IntPtr, FontFaceID, UInt16[], UInt32)), calling (MethodDesc 0x54617644 +0 MS.Internal.FontCache.FontCacheAccessor.GetBitmaps(System.String, Int32, Int32, Int32, UInt16, UInt16, UInt16, Int32, UInt16[], Void*[]))
    0579f240 547fe580 (MethodDesc 0x5461762c +0xa0 MS.Internal.FontCache.FontCacheAccessor.CreateGlyphsAtRenderTime(IntPtr, IntPtr, UInt16)), calling (MethodDesc 0x54617638 +0 MS.Internal.FontCache.FontCacheAccessor.CreateGlyphBitmapsHelper(IntPtr, FontFaceID, UInt16[], UInt32))
    0579f26c 547fe482 (MethodDesc 0x546a8ae4 +0x42 MS.Internal.FontCache.FontCacheAccessor.CreateGlyphsCallback(IntPtr, IntPtr, UInt16)), calling (MethodDesc 0x5461762c +0 MS.Internal.FontCache.FontCacheAccessor.CreateGlyphsAtRenderTime(IntPtr, IntPtr, UInt16))
    0579f29c 79e71b4c mscorwks!CallDescrWorker+0x33
    0579f2b0 79e821b1 mscorwks!CallDescrWorkerWithHandler+0xa3, calling mscorwks!CallDescrWorker
    0579f330 79fa987a mscorwks!ForwardCallToManagedMethod+0x55, calling mscorwks!CallDescrWorkerWithHandler
    0579f350 79fa9a32 mscorwks!DoUMThunkCallWorker+0x1de, calling mscorwks!ForwardCallToManagedMethod
    0579f3e4 79e79cba mscorwks!ClrFlsSetValue+0x57, calling mscorwks!_EH_epilog3
    0579f41c 79fd8733 mscorwks!Thread::EnterContextRestricted+0x21d, calling mscorwks!_EH_epilog3
    0579f44c 7a0c9b40 mscorwks!DoUMThunkCall+0x1e8, calling mscorwks!DoUMThunkCallWorker
    0579f4d0 4fe7341e d3d9!CD3DDDIDX9::SurfaceBlt+0xe, calling d3d9!CD3DDDIDX6::GetHalBufferPointer
    0579f52c 003c607d 003c607d, calling mscorwks!DoUMThunkCall
    0579f55c 540343e4 wpfgfx_v0300!CMilSlaveGlyphCache::EnsureGlyphBitmapsArePresent+0x5d
    0579f57c 540343e4 wpfgfx_v0300!CMilSlaveGlyphCache::EnsureGlyphBitmapsArePresent+0x5d
    0579f5e0 54031df7 wpfgfx_v0300!CGlyphRunResource::CreateRealization+0x1bf, calling wpfgfx_v0300!CMilSlaveGlyphCache::EnsureGlyphBitmapsArePresent
    0579f610 54032289 wpfgfx_v0300!CGlyphRunResource::GetAvailableScale+0x1a0, calling wpfgfx_v0300!CGlyphRunResource::CreateRealization
    0579f644 4fe52ba5 d3d9!CD3DBase::SetTransform+0xb5, calling ntdll!RtlLeaveCriticalSection
    0579f68c 54031063 wpfgfx_v0300!CBaseGlyphRunPainter::Init+0x1ad, calling wpfgfx_v0300!CGlyphRunResource::GetAvailableScale
    0579f6d4 54037c69 wpfgfx_v0300!CD3DGlyphRunPainter::Paint+0xa9, calling wpfgfx_v0300!CBaseGlyphRunPainter::Init
    0579f6f0 540501b9 wpfgfx_v0300!CD3DDeviceLevel1::SetSurfaceToClippingMatrix+0xc4, calling wpfgfx_v0300!CHwRenderStateManager::Set2DTransformForFixedFunction
    0579f708 54055a54 wpfgfx_v0300!CD3DDeviceLevel1::SetClipRect+0x17b, calling wpfgfx_v0300!CCodeTracer::IsTracingEnabled
    0579f770 540374fd wpfgfx_v0300!CHwSurfaceRenderTarget::DrawGlyphs+0x191, calling wpfgfx_v0300!CD3DGlyphRunPainter::Paint
    0579f844 5400d780 wpfgfx_v0300!CBrushRealizer::CBrushRealizer+0x48, calling wpfgfx_v0300!CMilAlphaMaskWrapper::SetVisualPreviousOuterBounds
    0579f864 540129ea wpfgfx_v0300!CBrushRealizer::CreateResourceRealizer+0x44
    0579f8a8 7818efed msvcr80!_handle_exc+0x1d2, calling msvcr80!_set_statfp
    0579f8d0 78190ff7 msvcr80!_87except+0xc4, calling msvcr80!_ctrlfp
    0579f8e4 5400f7b4 wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::Intersect+0x6f, calling wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::IsEmpty
    0579f8e8 5400e8da wpfgfx_v0300!CMetaIterator::SetupForNextInternalRT+0x1ce, calling wpfgfx_v0300!CDisplaySet::GetDisplaySettings
    0579f8fc 54013318 wpfgfx_v0300!CMetaIterator::CMetaIterator+0x47, calling wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::IsEmpty
    0579f914 540375a4 wpfgfx_v0300!CHwDisplayRenderTarget::DrawGlyphs+0x1c, calling wpfgfx_v0300!CHwSurfaceRenderTarget::DrawGlyphs
    0579f928 54030778 wpfgfx_v0300!CMetaRenderTarget::DrawGlyphs+0xb6
    0579f958 54012418 wpfgfx_v0300!CDrawingContext::DrawRectangle+0x102, calling wpfgfx_v0300!CCodeTracer::IsTracingEnabled
    0579f990 5400d359 wpfgfx_v0300!CBaseMatrix::Transform2DBounds+0x5f, calling wpfgfx_v0300!CBaseMatrix::Transform
    0579f9e0 54030683 wpfgfx_v0300!CDrawingContext::DrawGlyphRun+0x1de
    0579fa38 540124f0 wpfgfx_v0300!CMilSlaveRenderData::Draw+0x4a4
    0579fa80 54012040 wpfgfx_v0300!InflateRectF_InPlace+0xb, calling wpfgfx_v0300!InflateRectF_InPlace
    0579fa84 5400f7b4 wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::Intersect+0x6f, calling wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::IsEmpty
    0579fa88 5400f816 wpfgfx_v0300!CDrawingContext::GetClippedWorldSpaceBounds+0x5c, calling wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::Intersect
    0579faac 54010f74 wpfgfx_v0300!CSnappingFrame::PushFrame+0x89, calling wpfgfx_v0300!CSnappingFrameEmpty::PushFrame
    0579fadc 54012562 wpfgfx_v0300!CMilVisual::RenderContent+0x2a, calling wpfgfx_v0300!CMilSlaveRenderData::Draw
    0579faf4 5400f950 wpfgfx_v0300!CDrawingContext::PreSubgraph+0x485
    0579fb6c 540156f1 wpfgfx_v0300!CMetaRenderTarget::Clear+0x129, calling wpfgfx_v0300!CMetaIterator::~CMetaIterator
    0579fbc4 540105da wpfgfx_v0300!CWatermarkStack<CModelWalker::CFrame,64,2,10>::Push+0xdf
    0579fbd8 54009f0d wpfgfx_v0300!CPtrArrayBase::operator[]+0x7, calling wpfgfx_v0300!CPtrMultisetBase::GetCount
    0579fbdc 5400f6c5 wpfgfx_v0300!CMilVisual::GetChildAt+0x21, calling wpfgfx_v0300!CPtrArrayBase::operator[]
    0579fbec 5400f725 wpfgfx_v0300!CGraphWalker::GotoFirstChild+0x61
    0579fc0c 5400e646 wpfgfx_v0300!CGraphIterator::Walk+0x32
    0579fc34 5400f622 wpfgfx_v0300!CDrawingContext::DrawVisualTree+0x324, calling wpfgfx_v0300!CGraphIterator::Walk
    0579fc48 54015b24 wpfgfx_v0300!CPreComputeContext::ConvertInnerToOuterBounds+0xbf, calling wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::IsWellOrdered
    0579fcd0 54009f0d wpfgfx_v0300!CPtrArrayBase::operator[]+0x7, calling wpfgfx_v0300!CPtrMultisetBase::GetCount
    0579fcd4 5400f6c5 wpfgfx_v0300!CMilVisual::GetChildAt+0x21, calling wpfgfx_v0300!CPtrArrayBase::operator[]
    0579fcdc 54009f0d wpfgfx_v0300!CPtrArrayBase::operator[]+0x7, calling wpfgfx_v0300!CPtrMultisetBase::GetCount
    0579fce0 5400f6c5 wpfgfx_v0300!CMilVisual::GetChildAt+0x21, calling wpfgfx_v0300!CPtrArrayBase::operator[]
    0579fcf0 5400f688 wpfgfx_v0300!CGraphWalker::GotoSibling+0x4f
    0579fd00 5400eba9 wpfgfx_v0300!CGraphWalker::EndWalk+0x12, calling wpfgfx_v0300!CWatermarkStack<CModelWalker::CFrame,64,2,10>::Optimize
    0579fd08 5400ebc1 wpfgfx_v0300!CGraphIterator::Walk+0x110, calling wpfgfx_v0300!CGraphWalker::EndWalk
    0579fd30 5400ecb2 wpfgfx_v0300!CPreComputeContext::PreCompute+0xfc, calling wpfgfx_v0300!CWatermarkStack<TMilRect_<float,MilRectF,MilPointAndSizeF,RectUniqueness::NotNeeded>,8,2,8>::Clear
    0579fd44 5400ecfa wpfgfx_v0300!CDrawingContext::PreCompute+0x52, calling wpfgfx_v0300!CPreComputeContext::PreCompute
    0579fd5c 5400eef8 wpfgfx_v0300!CDirtyRegion2::GetDirtyRegion+0x3b, calling msvcr80!memset
    0579fd68 5400ef14 wpfgfx_v0300!CDirtyRegion2::GetDirtyRegion+0x57, calling wpfgfx_v0300!TMilRect<float,MilRectF,RectUniqueness::NotNeeded>::IsEmpty
    0579fd80 540302f6 wpfgfx_v0300!CDrawingContext::Render+0x324, calling wpfgfx_v0300!CDrawingContext::DrawVisualTree
    0579fda0 54007231 wpfgfx_v0300!CDisplaySet::HasDisplayStateChanged+0x10, calling wpfgfx_v0300!CDisplaySet::IsUpToDate
    0579fdfc 5400c019 wpfgfx_v0300!CSlaveHWndRenderTarget::Render+0x209, calling wpfgfx_v0300!CDrawingContext::Render
    0579fe54 540076e0 wpfgfx_v0300!FreeBatch+0x14, calling wpfgfx_v0300!COcclusionContext::`scalar deleting destructor'
    0579fe60 54007391 wpfgfx_v0300!CComposition::ProcessCommandBatch+0x22d6, calling wpfgfx_v0300!FreeBatch
    0579fea8 540073c4 wpfgfx_v0300!CComposition::ProcessPartitionCommand+0x70, calling wpfgfx_v0300!CComposition::ProcessCommandBatch
    0579febc 5400be78 wpfgfx_v0300!CRenderTargetManager::Render+0x2e
    0579fedc 54007523 wpfgfx_v0300!CComposition::Render+0x21, calling wpfgfx_v0300!CRenderTargetManager::Render
    0579fef4 540075d6 wpfgfx_v0300!CComposition::ProcessComposition+0xf3, calling wpfgfx_v0300!CComposition::Render
    0579ff20 5400700e wpfgfx_v0300!CPartitionManager::LogEvent+0x26, calling kernel32!InterlockedCompareExchange
    0579ff2c 5400700e wpfgfx_v0300!CPartitionManager::LogEvent+0x26, calling kernel32!InterlockedCompareExchange
    0579ff34 5400700e wpfgfx_v0300!CPartitionManager::LogEvent+0x26, calling kernel32!InterlockedCompareExchange
    0579ff38 5400700e wpfgfx_v0300!CPartitionManager::LogEvent+0x26, calling kernel32!InterlockedCompareExchange
    0579ff58 54007667 wpfgfx_v0300!CComposition::Compose+0x3e, calling wpfgfx_v0300!CComposition::ProcessComposition
    0579ff6c 540076a2 wpfgfx_v0300!CPartitionThread::RenderPartition+0x1c
    0579ff88 5400717b wpfgfx_v0300!CPartitionThread::Run+0x48, calling wpfgfx_v0300!CPartitionThread::RenderPartition
    0579ff9c 5400b68e wpfgfx_v0300!CPartitionThread::ThreadMain+0x1e
    0579ffa0 79e8209e mscorwks!Module::EnsureActive+0x5f, calling mscorwks!DomainFile::EnsureLoadLevel
    0579ffb4 7c80b729 kernel32!BaseThreadStart+0x37
    0579ffbc 79e8209e mscorwks!Module::EnsureActive+0x5f, calling mscorwks!DomainFile::EnsureLoadLevel

    Monday, June 22, 2009 4:42 PM

All replies

  • Probably due to font cache data file corruption. Try the below workaround.

    1. Run services.msc
    2. Stop Windows Presentation Foundation Font Cache 3.0.0.0 service
    3. Delete FontCache3.0.0.0.dat

    in XP:
    %systemdrive%\Documents and Settings\LocalService\Local Settings\Application Data

    in Vista: %windir%\ServiceProfiles\LocalService\AppData\Local

    4. Restart the machine
    Monday, July 20, 2009 6:58 PM
  • Probably due to font cache data file corruption. Try the below workaround.

    1. Run services.msc
    2. Stop Windows Presentation Foundation Font Cache 3.0.0.0 service
    3. Delete FontCache3.0.0.0.dat

    in XP:
    %systemdrive%\Documents and Settings\LocalService\Local Settings\Application Data

    in Vista: %windir%\ServiceProfiles\LocalService\AppData\Local

    4. Restart the machine
    I had a similar problem here. Almost randomly my app hung at 100% CPU on one CPU core and did not respond. The running thread was also running something in
    wpfgfx_v0300!CMilSlaveGlyphCache
     In the end I found out that all those "random" hangups were related to font changes. For example, it happened when I increased the font size of WPF controls at runtime to something around 20 (I think it was between 17 and 21). And it also happened when a trigger set a TextBlock's FontWeight property to Bold.

    Rath's suggestion worked for me. Clearing the WPF font cache solved the problem! Many thanks, Rath!
    Wednesday, March 16, 2011 9:35 AM
  • Even I was having same issue. If I openany wpf window, it was not responding. With above steps my issue is addressed. Thanks gehho1

    Tuesday, May 15, 2012 1:22 PM
  • This solution worked for me, too!!   THANKS!    

    We have our application hanging at 50% CPU in a thread showing the call stack with a function called from  wpfgfx_v0300.dll.   The offending method is

     wpfgfx_v0300.dll --->  MilChannel_SetNotificationWindow

    When I delete the font cache file mentioned here, the problem goes away.  When I restore the offending file, the problem comes back.  So I know that is the cause.  

    Another thing to note, this happens with our application using the German language culture setting on the main thread, on Windows XP SP3.  i.e. the main UI application thread culture is switched to "de-DE" at startup.  Problem does not happen with English  (en-US). Also, this app uses thread pools for some background tasks. I understand the thread pools do NOT inherit the culture of the main app thread, and are always "en-US" or whatever the system culture/language setting is.


    Thursday, December 6, 2012 9:14 PM
  • How do you delete the fontcache? I stopped the application but I don't see any option to delete it. Please advise. Thanks.
    Tuesday, March 1, 2016 9:52 PM