rebuild osx platform fontlist more efficiently when font changes occur

NEW
Unassigned

Status

()

5 years ago
3 years ago

People

(Reporter: jtd, Unassigned)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
Created attachment 8370579 [details] [diff] [review]
debug patch, dump key/value pairs passed to font change callback

While working on bug 964613, I noticed some funky behavior in the way font change notifications occur under OSX. Current OSX platform fontlist code deals with underlying changes to the system fontlist by using the OSX CFNotificationCenter API. A callback is registered within the gfxMacPlatformFontList constructor which calls RegisteredFontsChangedNotificationCallback when changes occur.  This callback rebuilds the fontlist via a call to the UpdateFontList method.

However, it turns out that this API has some quirks. When fonts are disabled, the callback is called a single time but when fonts are enabled, the callback is called twice. So in the enable case, Gecko re-initializes the fontlist twice (including associated background fontloader thread runs).  At this point there's nothing cataclysmic about this, it's just inefficient.

The attached patch dumps out the information within the dictionary passed to the callback:

Disable two fonts:

CTFontManagerFontChangedNotification
CTFontManagerAvailableFontURLsRemoved
(
    "file:///Library/Fonts/Georgia%20Bold.ttf#postscript-name=Georgia-Bold",
    "file:///Library/Fonts/Georgia%20Bold%20Italic.ttf#postscript-name=Georgia-BoldItalic"
)

Enable the same two fonts:

CTFontManagerFontChangedNotification
CTFontManagerAvailableFontURLsAdded
(
    "file://localhost/Library/Fonts/Georgia%20Bold%20Italic.ttf",
    "file://localhost/Library/Fonts/Georgia%20Bold.ttf"
)

CTFontManagerFontChangedNotification
CTFontManagerAvailableFontURLsAdded
(
    "file:///Library/Fonts/Georgia%20Bold.ttf#postscript-name=Georgia-Bold",
    "file:///Library/Fonts/Georgia%20Bold%20Italic.ttf#postscript-name=Georgia-BoldItalic"
)

Seems like the first of the two enable callbacks can be ignored, since it doesn't contain the font URLs that match the disabled font URLs.  I think it would also be a good idea to simply rebuild the affected families (i.e. destroy the existing gfxFontFamily object and insert a new, empty one) rather than dumping and rebuilding the entire font list.
(Reporter)

Updated

3 years ago
Assignee: jd.bugzilla → nobody
You need to log in before you can comment on or make changes to this bug.