New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 631258 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Aug 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

initializeScriptFontMap unnecessarily loads fonts

Project Member Reported by kulshin@chromium.org, Jul 25 2016

Issue description

When initializeScroptFontMap is called, it tests for existence of fonts, which loads font data for the fonts. This will load a large number of unneeded fonts. See example stack below.

At least on Windows, existence of fonts can be tested without loading font data, but we should also consider whether we need to do this pre-initialization in the first place.

As an alternative, we can reduce the number of fonts in the script map in cases where font fallback is sufficient (need to be careful, especially on win7, since fallback might rely on this map).

 	content.dll!content::DWriteFontCollectionProxy::CreateEnumeratorFromKey(IDWriteFactory * factory, const void * collection_key, unsigned int collection_key_size, IDWriteFontFileEnumerator * * font_file_enumerator) Line 212	C++
 	DWrite.dll!FontCollectionConstructionTask::AddElementData()	Unknown
 	DWrite.dll!CacheWriter::AddElement()	Unknown
 	DWrite.dll!IBaseCacheContext::AddElementInternal()	Unknown
 	DWrite.dll!ClientSideCacheContext::AddElementInternal()	Unknown
 	DWrite.dll!DWriteFactory::AddElement(class IElementConstructionTask *,struct CachedElementData *)	Unknown
 	DWrite.dll!ElementTaskList::ExecuteTask(class IBaseCacheContext *,class IElementConstructionTask *,bool)	Unknown
 	DWrite.dll!ElementTaskList::GetElementData()	Unknown
 	DWrite.dll!FontCollection::FontCollection(class IBaseCacheContext *,class FontCollectionElementKey const *)	Unknown
 	DWrite.dll!ComObject<class DWriteFontCollection,struct DeleteOnZeroReference>::ComObject<class DWriteFontCollection,struct DeleteOnZeroReference><class DWriteFactory * const,class FontCollectionElementKey *>(class DWriteFactory * const &&,class FontCollectionElementKey * &&)	Unknown
 	DWrite.dll!DWriteFactory::CreateCustomFontCollection()	Unknown
 	content.dll!content::DWriteFontCollectionProxy::LoadFamily(unsigned int family_index, IDWriteFontCollection * * containing_collection) Line 288	C++
 	content.dll!content::DWriteFontFamilyProxy::LoadFamily() Line 488	C++
 	content.dll!content::DWriteFontFamilyProxy::GetFirstMatchingFont(DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STRETCH stretch, DWRITE_FONT_STYLE style, IDWriteFont * * matching_font) Line 421	C++
 	skia.dll!SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle & pattern) Line 1033	C++
 	skia.dll!SkFontMgr_DirectWrite::onMatchFamilyStyle(const char * familyName, const SkFontStyle & fontstyle) Line 513	C++
 	skia.dll!SkFontMgr::matchFamilyStyle(const char * familyName, const SkFontStyle & fs) Line 108	C++
 	blink_platform.dll!blink::`anonymous namespace'::isFontPresent(const wchar_t * fontName, SkFontMgr * fontManager) Line 52	C++
>	blink_platform.dll!blink::`anonymous namespace'::initializeScriptFontMap(const wchar_t *[167] & scriptFontMap, SkFontMgr * fontManager) Line 301	C++
 	blink_platform.dll!blink::getFontFamilyForScript(UScriptCode script, blink::FontDescription::GenericFamilyType generic, SkFontMgr * fontManager) Line 463	C++
 	blink_platform.dll!blink::getFallbackFamily(int character, blink::FontDescription::GenericFamilyType generic, UScriptCode contentScript, const WTF::AtomicString & contentLocale, UScriptCode * scriptChecked, blink::FontFallbackPriority fallbackPriority, SkFontMgr * fontManager) Line 518	C++
 	blink_platform.dll!blink::FontCache::fallbackFontForCharacter(const blink::FontDescription & fontDescription, int character, const blink::SimpleFontData * originalFontData, blink::FontFallbackPriority fallbackPriority) Line 127	C++
 	blink_platform.dll!blink::FontFallbackIterator::uniqueSystemFontForHint(int hint) Line 193	C++
 	blink_platform.dll!blink::FontFallbackIterator::next(const WTF::Vector<int,0,WTF::PartitionAllocator> & hintList) Line 94	C++
 	blink_platform.dll!blink::FontFallbackIterator::next(const WTF::Vector<int,0,WTF::PartitionAllocator> & hintList) Line 124	C++
 	blink_platform.dll!blink::HarfBuzzShaper::shapeResult() Line 611	C++
 	blink_platform.dll!blink::CachingWordShapeIterator::shapeWordWithoutSpacing(const blink::TextRun & wordRun, const blink::Font * font) Line 84	C++
 	blink_platform.dll!blink::CachingWordShapeIterator::shapeWord(const blink::TextRun & wordRun, const blink::Font * font) Line 98	C++
 	blink_platform.dll!blink::CachingWordShapeIterator::shapeToEndIndex(WTF::RefPtr<blink::ShapeResult const > * result, unsigned int endIndex) Line 173	C++

 
Project Member

Comment 1 by bugdroid1@chromium.org, Aug 9 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3f489f6b953f464a1a0b5996bc79e468ba9e35e1

commit 3f489f6b953f464a1a0b5996bc79e468ba9e35e1
Author: kulshin <kulshin@chromium.org>
Date: Tue Aug 09 17:38:23 2016

Remove unnecessary font loading when loading font fallbacks.

Previously, we were going through all possible fallback fonts and
testing each for existence as soon as something asked for any fallback
font. Due to how isFontPresent is implemented, it actually loads the
font. This change defers testing font existence (and loading them) until
a font for that script is actually needed. I expect this will result in
a perf gain, since I expect most pages will need only a few fallback
fonts.

In my very limited and not very rigorous testing, I observed about a 5%
improvement in warm startup (Startup.FirstWebContents.NonEmptyPaint2)
when navigating to emojipedia.org.

BUG= 631258 

Review-Url: https://codereview.chromium.org/2215543002
Cr-Commit-Position: refs/heads/master@{#410729}

[modify] https://crrev.com/3f489f6b953f464a1a0b5996bc79e468ba9e35e1/third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp

Status: Fixed (was: Available)

Sign in to add a comment