Open Bug 1819097 Opened 3 years ago Updated 1 year ago

[macOS] Reduce the cost of handling RegisteredFontsChanged notification during startup

Categories

(Core :: Graphics: Text, enhancement)

Unspecified
macOS
enhancement

Tracking

()

ASSIGNED

People

(Reporter: jfkthame, Assigned: jfkthame)

Details

Attachments

(1 file)

See profile: https://share.firefox.dev/3xXmtEm

This is a profile of launching a local (opt) mozilla-central build to about:blank.

Note that starting around 0.76s, the main thread spends about 130ms in gfxMacPlatformFontList::RegisteredFontsChangedNotificationCallback.

This is unfortunate, because it is redundant work. Early in startup, we "register" the OS collection of supplemental fonts, so as to get more complete language support. This is done by the RegisterFonts thread, which runs as early as possible in startup.

After this completes, we initialize the platform font list with the available font families. This is done on the InitFontList thread. As part of this, we register for notifications of any updates to the installed font list.

Unfortunately, the Core Text font manager seems to be running a bit behind us, and even though we completed font registration before registering for the notification, we receive one a bit later -- at which point we throw away the work we'd done, and re-create the font list.

So the intent of this bug is to try and avoid this duplicated work (particularly as it's on the startup path).

During font-list initialization, we call Core Text to "activate" the supplemental language fonts,
and potentially any bundled fonts shipped with the app. But this generates an OS notification,
which if we process it will cause a redundant rebuild of our list. So to avoid this, set a flag
when we activate the fonts, telling us that the upcoming notification can be ignored.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1c6351a80663 Avoid repeating InitFontList due to RegisteredFontsChanged notification during startup on macOS. r=gfx-reviewers,lsalzman

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:jfkthame, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit auto_nag documentation.

Flags: needinfo?(lsalzman)
Flags: needinfo?(jfkthame)
Flags: needinfo?(lsalzman)

I'd like to try re-landing this, but have not yet been able to reliably resolve the test issues that showed up.

Flags: needinfo?(jfkthame)
Severity: -- → N/A
Type: defect → enhancement
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: