gfxPlatformFontList shutdown sometimes takes 300ms on shutdown

NEW
Unassigned

Status

()

Core
Graphics: Text
5 years ago
4 years ago

People

(Reporter: BenWa, Unassigned)

Tracking

(Depends on: 1 bug, Blocks: 1 bug)

Trunk
x86
Mac OS X
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
Profile:
http://people.mozilla.com/~bgirard/cleopatra/#report=943aaf49ccd73081df7cdda6cbe89c71a3102d5a

We should avoid doing this in an optimized shutdown. We just need to wait for confirmation from the telemetry shutdown write information.
(Reporter)

Comment 1

5 years ago
bug 662444 would fix this.
Depends on: 662444

Comment 2

4 years ago
It would be nice to include more specifics so that we don't need to dig around profiles. 

In the attached profile, from about 1260ms onwards the code is iterating all the fonts contained in the list of fonts with gfxPlatformFontList::~gfxPlatformFontList. It looks like most of the time is spent in the CFRelease of the CTFont object associated with a MacOSFontEntry object.

I suspect we may be holding on to the CTFont object unnecessarily for a lot of these fonts, it may just be a side effect of the sniffing of localized font name data rather than represent fonts that are actually used. I guess one question is whether we can simply somehow bulk dump these at shutdown without clearing out each font one by one.
Summary: gfxFontFamily sometimes takes 300ms on shutdown → gfxPlatformFontList shutdown sometimes takes 300ms on shutdown

Comment 3

4 years ago
Two typical stacks:

mach_msg_trap
_CGSCacheGetUniqueID
CGSCacheGetUniqueID
CGFontGetGFID
CGFontGetIdentifier
CGFontCacheRemoveFont
font_finalize
CFRelease
MacOSFontEntry::~MacOSFontEntry()
nsTArray<nsRefPtr<gfxFontEntry>, nsTArrayDefaultAllocator>::RemoveElementsAt(unsigned int, unsigned int)
gfxFontFamily::~gfxFontFamily()
gfxMacFontFamily::~gfxMacFontFamily()
nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsRefPtr<gfxFontFamily> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*)
PL_DHashTableFinish
gfxPlatformFontList::~gfxPlatformFontList()
gfxMacPlatformFontList::~gfxMacPlatformFontList()
gfxPlatform::Shutdown()
nsTArray<nsAutoPtr<nsComponentManagerImpl::KnownModule>, nsTArrayDefaultAllocator>::Clear()
nsComponentManagerImpl::Shutdown()
mozilla::ShutdownXPCOM(nsIServiceManager*)
ScopedXPCOMStartup::~ScopedXPCOMStartup()
XREMain::XRE_main(int, char**, nsXREAppData const*)
Startup::XRE_Main
XRE_main
main
start
(root)

madvise
arena_run_dalloc
arena_dalloc
free
CGFontNameTableRelease
font_finalize
CFRelease
MacOSFontEntry::~MacOSFontEntry()
nsTArray<nsRefPtr<gfxFontEntry>, nsTArrayDefaultAllocator>::RemoveElementsAt(unsigned int, unsigned int)
gfxFontFamily::~gfxFontFamily()
gfxMacFontFamily::~gfxMacFontFamily()
nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsRefPtr<gfxFontFamily> > >::s_ClearEntry(PLDHashTable*, PLDHashEntryHdr*)
PL_DHashTableFinish
gfxPlatformFontList::~gfxPlatformFontList()
gfxMacPlatformFontList::~gfxMacPlatformFontList()
gfxPlatform::Shutdown()
nsTArray<nsAutoPtr<nsComponentManagerImpl::KnownModule>, nsTArrayDefaultAllocator>::Clear()
nsComponentManagerImpl::Shutdown()
mozilla::ShutdownXPCOM(nsIServiceManager*)
ScopedXPCOMStartup::~ScopedXPCOMStartup()
XREMain::XRE_main(int, char**, nsXREAppData const*)
Startup::XRE_Main
XRE_main
main
start
(root)
You need to log in before you can comment on or make changes to this bug.