[macOS] Text rendering issues when users have multiple fonts which internally use the same name, and the OS chooses differently among them for different Firefox processes
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
People
(Reporter: dholbert, Assigned: jfkthame)
References
(Regression)
Details
(Keywords: regression)
Attachments
(4 files, 1 obsolete file)
We've had several bug reports for a general category of issue, which I'm grouping under this bug.
bug 1771496 comment 39 and nearby comments have some STR. Essentially the setup is:
- Have several fonts that identify themselves as being the same font
In some configurations, our different processes seem to get back a different answer from the OS when we query for the font, though we expect the result to be deterministic / reliable. This can cause substantial problems if the font metrics disagree, as discussed in bug 1771496 comment 44.
(We don't yet fully understand what's going on here or why the OS seems to be returning different values, or what our options are to work around this, but hopefully we can address this somehow; because from a user perspective, it seems to manifest as a Firefox-specific bug.)
| Reporter | ||
Updated•3 years ago
|
| Reporter | ||
Updated•3 years ago
|
| Reporter | ||
Comment 3•3 years ago
•
|
||
(Note RE the "fonts with the same name" setup here - the user-facing font name may differ, but the issue seems to happen when internal hidden fields in the font itself declare it to be the same. E.g. in bug 1771496 comment 45, we have a font that's called "Brady Bunch" but which internally has "Arial" and "ArialMT" in some of its name fields, and that naming [combined with other Arial/ArialMT fonts on the system] is what causes trouble here.)
Comment 4•3 years ago
|
||
The following field has been copied from a duplicate bug:
| Field | Value | Source |
|---|---|---|
| Regressed by | bug 1696504 | bug 1771496 |
For more information, please visit auto_nag documentation.
Comment 5•3 years ago
|
||
:glandium, since you are the author of the regressor, bug 1696504, could you take a look?
For more information, please visit auto_nag documentation.
Updated•3 years ago
|
Comment 6•3 years ago
|
||
Set release status flags based on info from the regressing bug 1696504
Updated•3 years ago
|
Comment 7•3 years ago
|
||
Set release status flags based on info from the regressing bug 1696504
Updated•3 years ago
|
Updated•3 years ago
|
| Assignee | ||
Comment 11•3 years ago
|
||
I've been looking into this, and think I may have a possible solution here.
Currently, on recent macOS versions the gfxPlatformMac::RegisterSupplementalFonts() function, which gives Firefox access to a bunch of fonts for additional language support, only performs the font registration in the parent process. This is enough to get them into the global font list, which is then shared with content processes, and the fonts appear to work fine.
However, what I'm seeing through local testing is that while the content process has no problem using these fonts, the fact that CTFontManagerRegisterFontsForURLs was not called in the content process in the same way it was in the parent means that the font databases in the processes are not identical. And this can result in inconsistent font lookup results even for fonts that weren't part of the "supplemental" collection, like locally-installed Arial and Helvetica versions.
So to ensure that the OS font manager database is consistent between parent and content processes, we need to go ahead and call CTFontManagerRegisterFontsForURLs for the supplemental fonts in all processes, not just in the parent.
Unfortunately, this comes at a considerable cost -- I'm seeing something up to around 300ms locally on my MacBook. So that will be a substantial cpstartup regression. It's less clear to me how user-perceivable it will be, as much of the time we presumably use a preallocated process when the user opens a new tab, in which case the regression may have gone unnoticed in the background. But it does seem likely that in some scenarios it'll be quite bad. :-(
| Assignee | ||
Comment 12•3 years ago
|
||
Local testing indicates that if we don't do this, there's a risk that Core Text will resolve font names
differently in the content vs parent processes when duplicate fonts are installed (e.g. old versions of
Arial, Helvetica, etc that some users have "inherited" from ancient systems). The mismatched fonts used
for layout (in the content process) vs painting (by the parent) lead to the "garbled text" issue.
Unfortunately, this will impact content-process startup on macOS, so expect a perf regression report.
In my local testing, this appears to prevent the "garbled text" problem when an old version of Arial is
installed, or other similar font mismatch situations. There should be no user-visible behavior change
for systems with a "clean" font installation.
Updated•3 years ago
|
| Assignee | ||
Comment 13•3 years ago
|
||
No user-visible behavior change; just trying to move a bit more work onto a secondary thread,
in the hope of improving startup perf (althogh if there's too much contention for disk i/o,
or not enough CPU cores available, it may not help much).
Depends on D170286
| Assignee | ||
Comment 14•3 years ago
|
||
This replaces CTFontManagerRegisterFontsForURLs, which is deprecated since macOS 10.15.
(No user-visible behavior change.)
Depends on D170287
| Assignee | ||
Comment 15•3 years ago
|
||
Setting perf? flag to get this on the team's radar, as the patch here will result in a substantial cpstartup hit on macOS (see comment 11), which I can't currently see how to avoid. It's unclear to me how user-visible this will be overall, thanks to preallocated content processes, but nevertheless it's obviously a concern.
Comment 16•3 years ago
|
||
Comment 18•3 years ago
|
||
There are some r+ patches 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.
Updated•3 years ago
|
| Assignee | ||
Comment 19•2 years ago
|
||
I'd like to try re-landing this, but have not yet been able to reliable resolve the test issues that showed up.
Comment 20•2 years ago
|
||
I don't think this qualifies as a perf impact issue itself as this cost is mostly hidden from the user. Thanks for letting us know though so we can keep an eye out!
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 22•2 years ago
|
||
Comment 23•2 years ago
|
||
Comment 24•2 years ago
|
||
Backed out for causing WR bustages.
Backout link: https://hg.mozilla.org/integration/autoland/rev/ab3dfad46d1c0953e1c833dcf2b76d987bc50fd2
Failure log:
https://treeherder.mozilla.org/logviewer?job_id=430814147&repo=autoland&lineNumber=191
https://treeherder.mozilla.org/logviewer?job_id=430814168&repo=autoland
Comment 25•2 years ago
|
||
Comment 26•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/00ebd5f86930
https://hg.mozilla.org/mozilla-central/rev/87d83c56fbe5
https://hg.mozilla.org/mozilla-central/rev/6a82f1f120aa
| Assignee | ||
Comment 27•2 years ago
•
|
||
Given the problem shown in bug 1858869, I'm going to back out the changes here pending further investigation -- this is clearly still too fragile to be trusted. :-(
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 28•2 years ago
|
||
| Assignee | ||
Comment 29•2 years ago
|
||
Actually, to reduce supply-chain churn, I'll leave the core-text version bump (00ebd5f86930) in place, as by itself it should have no effect.
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
Comment 30•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Comment 31•2 years ago
|
||
| bugherder | ||
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Comment 33•2 years ago
|
||
Given the issues we saw in bug 1858869, it appears that passing kCTFontOptionsPreferSystemFont to Core Text does not do the "right thing" (for our purposes, at least.... the documentation is pretty sparse). So I've removed that, leaving just the original fix to make content processes do the same supplemental-font activation as the parent process.
Hoping this time it can land without causing new problems....!
Comment 34•2 years ago
|
||
Comment 35•2 years ago
|
||
Backed out for causing OSX failures/leakchecks
Backout link: https://hg.mozilla.org/integration/autoland/rev/68721f0d6aec0facf9c8f271ea2bb2719348014a
Failure log -> TEST-UNEXPECTED-FAIL | leakcheck | tab 8 bytes leaked (nsStringBuffer)
Updated•2 years ago
|
| Assignee | ||
Comment 36•2 years ago
|
||
Backed out for causing OSX failures/leakchecks
The leak here must be the static sSystemFontName string from the second patch here; it was supposed to be freed on shutdown, but I guess that didn't reliably happen. For now I'm going to try re-landing just the first (main) patch, and see if that sticks.
Comment 37•2 years ago
|
||
Comment 38•2 years ago
|
||
| bugherder | ||
Comment 39•2 years ago
|
||
Should we close this bug out and move any follow-up work to a new bug so it's easier to track across cycles?
| Assignee | ||
Comment 40•2 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM] from comment #39)
Should we close this bug out and move any follow-up work to a new bug so it's easier to track across cycles?
Yes, that'd make sense once we're reasonably confident the patch that landed here is sticking this time.... I'd hoped to land D170287 as well but that needs some further testing, given its apparent tendency to leak a string. So we can take that to a followup (as well as any work on the test issues that have been reported).
Updated•2 years ago
|
Description
•