starting Chrome makes Firefox content processes hang for about two minutes, due to FontConfig font rescanning (FcInitReinitialize)
Categories
(Core :: Graphics: Text, defect, P3)
Tracking
()
People
(Reporter: dbaron, Assigned: jfkthame)
References
Details
(Keywords: perf)
Attachments
(2 files)
6.17 KB,
text/plain
|
Details | |
47 bytes,
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-beta+
|
Details | Review |
Reporter | ||
Updated•7 years ago
|
Assignee | ||
Comment 1•7 years ago
|
||
Updated•7 years ago
|
Reporter | ||
Comment 2•7 years ago
|
||
Reporter | ||
Comment 3•7 years ago
|
||
Reporter | ||
Comment 4•7 years ago
|
||
Assignee | ||
Comment 5•7 years ago
|
||
Reporter | ||
Comment 6•7 years ago
|
||
Comment 8•7 years ago
|
||
Assignee | ||
Comment 9•7 years ago
|
||
Comment 11•6 years ago
|
||
Comment 12•6 years ago
|
||
Assignee | ||
Comment 13•6 years ago
|
||
Comment 15•6 years ago
|
||
Reporter | ||
Comment 16•6 years ago
|
||
Reporter | ||
Comment 17•6 years ago
|
||
Assignee | ||
Comment 18•6 years ago
|
||
Reporter | ||
Comment 19•6 years ago
|
||
Reporter | ||
Comment 20•6 years ago
|
||
Reporter | ||
Comment 21•6 years ago
|
||
Reporter | ||
Comment 22•6 years ago
|
||
Comment 24•6 years ago
|
||
Comment 26•6 years ago
|
||
FWIW, this issue probably also happens with Android Emulator as well.
Comment 27•6 years ago
|
||
(In reply to Hiroyuki Ikezoe (:hiro) from comment #26)
FWIW, this issue probably also happens with Android Emulator as well.
Android does not use FontConfig, so is not affected by this.
Comment 28•6 years ago
|
||
(In reply to Lee Salzman [:lsalzman] from comment #27)
(In reply to Hiroyuki Ikezoe (:hiro) from comment #26)
FWIW, this issue probably also happens with Android Emulator as well.
Android does not use FontConfig, so is not affected by this.
Oh, you mean qemu or something like that doesn't use it at all on Linux? I've been seeing quite often similar issue when I run the emulator.
Comment 29•6 years ago
|
||
Hmm actually qemu-system-x86_64 doesn't linked to libfontconfig.so (I am not sure it's dynamically loaded or not), so probably some other processes might affect Firefox.
Comment 30•6 years ago
|
||
(In reply to svansintjan from comment #11)
Just wanted to pipe up and confirm that installing the latest fontconfig
packages from cosmic significantly reduced the wait time for me, which makes
running my tests a whole lot more manageable :)For the record I just installed these debs:
http://mirrors.kernel.org/ubuntu/pool/main/f/fontconfig/fontconfig-config_2.
13.0-5ubuntu3_all.deb
http://mirrors.kernel.org/ubuntu/pool/main/f/fontconfig/libfontconfig1_2.13.
0-5ubuntu3_amd64.deb
Looks like the files specified in these links have a problem. Firefox is complaining that the files have 'Virus or Malware' when trying to download them. I downloaded the same package from 'Launchpad.net', it did not complain - https://launchpad.net/ubuntu/disco/amd64/fontconfig/2.13.1-2ubuntu2
Probably the links need to be removed and people should download the packages from Launchpad.
Comment 33•5 years ago
|
||
I am using Ubuntu 18.04, is it possible to fix this? I cant seem to install the deb files provided.
Comment 34•5 years ago
|
||
Hi folks,
David, can you try to see whether other apps are affected on your system
actually, when in my spare time, there are only three desktop apps that i use on my system:
Firefox, Chromium, and skype. There is actually no difference in handling w.r.t this problem.
So starting skype oftentimes freezes chromium and firefox, as well as starting chromium might freeze the others.
This is likely wontfix for 64 at this point, though it'd be good to figure out a way to avoid this.
Well, we are at 71 now (in my distribution), and the problem is still there.
That reduces the pause from 2-3 minutes to about 4-5 seconds, though there's still a pause.
Well, even 4-5 seconds are too much, when there is a video or a real time financial trader running in the browser,
or a chat with a friend just having asked you the "ultimate question" and you cannot answer for several minutes ....
As user "contacto" above, I cannot install 2.13 on my system due to missing dependencies, and the next stable long time version will not come so soon.
Can you please let us know, why firefox has to do this job synchroneously and wait for fontconfig to finish? Can't that be done in an async way?
Why does firefox have to update the fonts anyway? If the user installs new fonts, why just don't wait until the user restarts firefox to see the new fonts in the app? How about a user-option to opt-out of this behaviour?
Finally: What can we do now to fix this problem?
Comment 35•5 years ago
|
||
I seem to have run into this when starting Atom, which uses Electron (which is itself based on Chromium).
Every firefox process is at max CPU. Looking at strace it seems to mainly hang out after opening a NotoSansCJK or NotoSerifCJK font. These fonts have 2^16 - 1 glyphs, the maximum for a truetype font. It's possible the delay wouldn't be perceivable without such large fonts installed.
Firefox 72.0.1+build1-0ubuntu0.18.04.1
libfontconfig1 2.12.6-0ubuntu2
Ubuntu 18.04.3 LTS
x86-64
I believe I'm using X, not Wayland.
Can't seem to trigger it with other GTK apps. Tried epiphany, gedit, evince, Gimp, Inkscape, QuodLibet, and LibreOffice Writer (not sure if that's GTK), and Thunderbird (although I don't have an account configured in Thunderbird).
Comment 36•5 years ago
|
||
Morgan,
yes, I have that fonts, too. But even when deactivating NotoCJK, the load of the firefox (sub)processes/threads goes up to 95% (while with the Noto*CJK fonts all of them went up to 100+%).
Still waiting here for an answer that I can use as a workaround, since I cannot install the 2.13 lib version.
Comment 37•5 years ago
|
||
Waiting for a workaround too :(
Comment 38•5 years ago
|
||
This is a very frustrating bug, hoping for a fix soon as possible.
Comment 39•5 years ago
|
||
Out of curiosity, does this repro with MOZ_DISABLE_CONTENT_SANDBOX=1
? I expect it'd be at least much faster with that...
Comment 40•5 years ago
|
||
No. As far as I can tell it eliminates the hang completely.
Comment 41•5 years ago
|
||
So this may be because we route all the system calls through the parent process, which means that file reads from content have a lot of overhead... Next thing to figure out would be whether the FcReinitialize stuff still happens consistently with the sandbox disabled...
Jed, do you know if the broker thread is registered with the profiler? It'd be kinda cool to see where time is spent there if the sandboxing is indeed the culprit.
Comment 42•5 years ago
|
||
I don't think they are, but that could be changed; this is the top of the broker threads' main function.
But something else to consider: is fontconfig trying to shell out to fc-cache
from the content processes? That will fail under sandboxing, and that might explain some of the difference between sandboxed and unsandboxed. One experiment to try there is to set security.sandbox.content.level
to 1, which should block fork
but allow direct (unbrokered) filesystem access.
Comment 43•5 years ago
|
||
(In reply to David Baron :dbaron: 🏴 ⌚UTC-8 from comment #0)
Today I decided to profile, and the profile at https://perfht.ml/2y8pYIS
showed what I expected to be the problem: FontConfig. In particular, we
spend basically all of the time inside FcInitReinitialize.
In particular, this appears to be spending almost all of the time doing computations in fontconfig itself, not blocked on opening files (seen as recvmsg
with inverted call stacks), which — assuming the nature of the problem hasn't changed since then — supports the idea that the cause of the bad performance isn't the file brokering, but it might be fontconfig falling back to ignoring a cache after failing to run an external command to rebuild it.
Comment 44•5 years ago
|
||
I've keep security.sandbox.content.level
to 4, but whitelisted fontconfig caches
user_pref("security.sandbox.content.read_path_whitelist", "/var/cache/fontconfig/,/home/lynn/.cache/fontconfig/");
Now touch ~/.local/share/fonts/
doesn't make firefox to eat 100% of CPU.
Assignee | ||
Comment 45•5 years ago
|
||
According to comment 44, it looks like the problem here arises because the sandbox is blocking fontconfig from reading its caches (which then results in it doing a full rescan in each process).
So if we add these cache dirs to the sandbox policy, it may help with this issue.
Assignee | ||
Comment 46•5 years ago
|
||
Updated•5 years ago
|
Comment 47•5 years ago
|
||
(In reply to Alexey Ten (Lynn) from comment #44)
I've keep
security.sandbox.content.level
to 4, but whitelisted fontconfig cachesuser_pref("security.sandbox.content.read_path_whitelist", "/var/cache/fontconfig/,/home/lynn/.cache/fontconfig/");
Now
touch ~/.local/share/fonts/
doesn't make firefox to eat 100% of CPU.
FWIW, with the pref value (though I used my home directory) Firefox crashes when a wpt finished running on my environment.
Assignee | ||
Comment 48•5 years ago
|
||
FWIW, with the pref value (though I used my home directory) Firefox crashes when a wpt finished running on my environment.
Huh, that's a bit worrying..... it looks a bit like bug 1627605, but that only applies when gfx.e10s.font-list.shared
is enabled, which I don't see in your crash report. Setting needinfo? to remind myself to see if I can reproduce that locally.
Comment 49•5 years ago
|
||
Hmm I don't recall when I set gfx.e10s.font-list.shared to false and re-set to true, but today I can't reproduce the crash so far, I think I am using a nightly which is not yet including bug 1627605.
Comment 50•5 years ago
|
||
Bugbug thinks this bug is a regression, but please revert this change in case of error.
Updated•5 years ago
|
Comment 51•5 years ago
|
||
![]() |
||
Comment 52•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Comment 53•5 years ago
|
||
Isn't firefox-77 a tad ahead? For example, Ubuntu 18.04 is a LTS release that should benefit from having stable software, and Firefox is at 75.
This bug is a bit of a show-stopper for people who have to develop websites and test them on both Firefox and Chromium, and/or simultaneously use an Electron-based editor such as the enormously popular VSCode.
What other workarounds are available in a shorter timeframe?
Comment 54•5 years ago
|
||
Dennis: there was a workaround posted in this bug thread that may help you, namely, upgrade libfontconfig1 to 2.13.*. I am also on Ubuntu 18.04/Firefox 75 and this bug isn't causing me problems now. You will probably have to grab a newer libfontconfig deb from a later release of Ubuntu.
Comment 55•5 years ago
|
||
(In reply to Dennis Mayr from comment #53)
Ubuntu LTS has special policy for some programs (e.g. Firefox) to upgrade them. I'm using Ubuntu 16.04 and have latest stable Firefox. So this is not a problem.
What other workarounds are available in a shorter timeframe?
Comment 56•5 years ago
|
||
Any chance this can be backported to the firefox 66 branch?
Comment 57•5 years ago
|
||
Firefox 66 is highly highly insecure! Please update!
Comment 58•5 years ago
|
||
D'oh, I meant the 76 branch, of course.
Assignee | ||
Comment 59•5 years ago
|
||
Comment on attachment 9139105 [details]
Bug 1495900 - Add fontconfig cache directories to content-process sandbox read paths. r=jld
Beta/Release Uplift Approval Request
- User impact if declined: Long pause (jank) in Firefox as a result of starting up chrome (or possibly other triggers)
- Is this code covered by automated tests?: No
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: No
- If yes, steps to reproduce: On affected system, launch chrome while firefox is running, observe whether firefox pauses for a noticeable period. (Dependent on fontconfig version and possibly other aspects of system configuration.)
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Trivial, just whitelisting directory where fontconfig caches may be stored
- String changes made/needed:
Comment 61•5 years ago
|
||
Comment on attachment 9139105 [details]
Bug 1495900 - Add fontconfig cache directories to content-process sandbox read paths. r=jld
May help ameliorate jank experienced by some users by whitelisting the fontconfig cache directory. Approved for 76.0rc1.
Comment 62•5 years ago
|
||
bugherder uplift |
Updated•5 years ago
|
Updated•5 years ago
|
Comment 63•5 years ago
|
||
Hello,
Since I was unable to reproduce this issue in first place, I cannot confirm if it's indeed fixed or not.
Tried to reproduce it using Firefox 67.0, 75.0, 76.0b4 and 73.0a1 (2020-01-01) on multiple Ubuntu 18.04 x64 machines with the STR found in this bug and within the duplicates, I’ve also used a Firefox 68.7.0esr build from Ubuntu Store. It worked fine on each attempt, Firefox worked as expected.
I assume this might also be related to the older Chromium/Chrome versions that were available within that timeframe.
The Chromium version that is installed on the machines I've used is 81.0.4044.122.
Comment 64•4 years ago
|
||
Bug 1719279 suggests this fix never worked.
Description
•