Closed Bug 1758721 Opened 3 years ago Closed 3 years ago

Enable font preferences to be accessed by worker threads

Categories

(Core :: Layout: Text and Fonts, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

To support text rendering in offscreen canvas2d, we'll need to access the font prefs (font.name-list.serif.<lang> etc) in order to resolve CSS generics and handle fallback. These are an open-ended set of string prefs, so we can't simply move them to StaticPrefs.

My current thought is to preload the font prefs, probably during gfxPlatformFontList initialization, and store them in-memory in a hash table or similar; worker threads will be allowed read-only access.

Any pref changes can be handled on the main thread only, and then the cached in-memory copy atomically replaced by a new version.

This doesn't in itself make them thread-safe, but it provides a basis to do so by avoiding
dependence on the Preferences service at textrun-construction time.

The FontPrefs record is inert once constructed, so one approach to worker-thread use would
be to make it refcounted, and have the worker hold a strong reference to the record it's using,
so that it won't be affected if the main thread handles a pref-change and replaces its
FontPrefs. Alternatively, maybe we can just protect access with the same lock as other uses
of the font list, once that is in place (bug 1756474).

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e349896dac17 Preload font prefs that may be needed at textrun-construction time, to avoid use of the (main-thread-only) preference service. r=lsalzman
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 100 Branch

== Change summary for alert #33533 (as of Tue, 15 Mar 2022 18:28:25 GMT) ==

Regressions:

Ratio Test Platform Options Absolute values (old vs new)
2% Base Content Heap Unclassified linux1804-64-shippable-qr 1,986,578.00 -> 2,029,086.67

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=33533

Regressions: 1759856
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: