Closed Bug 1397292 Opened 7 years ago Closed 7 years ago

MacOS: Font Cache gets slammed with Noto fonts on startup

Categories

(Core :: Graphics: Text, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: Gankra, Assigned: jfkthame)

Details

Attachments

(1 file)

While investigating https://bugzilla.mozilla.org/show_bug.cgi?id=1396056 I found that on start up, the font cache was receiving many rapid invalidations from a series of CTFontManagerAvailableFontURLsAdded messages for Noto fonts. On MacOS we completely rebuild the font cache for insertions. 

This ended up being a race condition with Webrender, which we're "fixing" by just making webrender more resilient to missing fonts.

Still, the fact that we're recreating the font cache so many times doesn't seem very good.
This should be much more efficient and less noisy. Local testing confirms that it results in a single notification for the whole batch of fonts, instead of one for each individual file.
Attachment #8905079 - Flags: review?(jmuizelaar)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #8905079 - Flags: review?(jmuizelaar) → review+
Is it possible to do this earlier in the startup process so that we don't end up rebuilding the font cache at all?
It's not clear to me how we can avoid this. The activation is (currently) done from the gfxMacPlatformFontList constructor, which is called during gfxPlatform::Init (prior to any attempt to actually build the font list and use fonts), and before we have registered an observer for the RegisteredFontsChanged notification. So on the face of things, we shouldn't be seeing such a notification at all; by the time we register for it, and build our font list (for the first time), the registration call here has long since completed.

Nevertheless, what actually happens is that we get the fonts-changed notification after some delay. I assume the whole CFNotificationCenter mechanism is asynchronous, so even though we're doing the registration pretty early, we don't get the resulting notification until some unspecified time later...
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/799fd39912bd
Activate all fonts from the "Language Support" folder in a single batch instead of individually, to reduce font-list churn. r=jrmuizel
https://hg.mozilla.org/mozilla-central/rev/799fd39912bd
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.