HarfBuzzShaper asks FontFallbackIterator::next for a font by calling next() each time it is done shaping with this font and still has non-rendered glyphs. Depending on what the font-stack, user-preference font, and fallback fonts returned by the system are, the shaper may try to shape with the same font several times, not ending up finding a result before the LastResort font.
Since HarfBuzzFaces are internally cached and unified using Skia unique SkTypeface IDs, we can filter for SkTypeFace uniqueIds earlier in FontFallbackIterator and not shape redundantly.
Examples would be:
Empty font-family CSS, but CSS code seems to set the default serif font before we reach shaping, then we try with that, and afterwards attempt to shape with the users default font again, which is the same, Times New Roman in both cases. Similarly, a font-family: that has Times or Times New Roman which we alias to the same font, etc.
Changing this should help performance-wise especially on pages where we fallback from web fonts to the default webkit-serif and preference font before attempting system fallbakc.
Comment 1 by bugdroid1@chromium.org
, Aug 10 2016