Don't do anything in FontPrefs::Init() very late in shutdown to avoid NS_WARNING spam
Categories
(Core :: Layout: Text and Fonts, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox116 | --- | fixed |
People
(Reporter: mccr8, Assigned: mccr8)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
Looking at a recent Linux64 run on mozilla-central, the second most common warning in the logs, with 225,428 instances, is this one:
WARNING: NS_ENSURE_TRUE(InitStaticMembers()) failed: file /builds/worker/workspace/obj-build/dist/include/mozilla/Preferences.h:129
While running a single Mochitest plain directory locally, every occurrence of this particular warning was happening because while shutting down the layout XPCOM component, we call ~gfxPlatformFontList(), which calls gfxPlatformFontList::ClearLangGroupPrefFontsLocked(), which creates a new FontPrefs object to replace the existing one. FontPrefs::Init() calls Preferences::GetRootBranch() so that it can read a bunch of pref stuff, but that fails because we're deep in shutdown, and produces the warning seen above.
I think the easiest fix here is to bail out from FontPrefs::Init() if we're deep in shutdown, because it will likely fail. I've chosen XPCOMShutdownFinal because it sounds less bizarre than CCPostLastCycleCollection, even though the latter is slightly later, because both are extremely late in shutdown (for instance, XPCOM threads no longer exist). I can't imagine a good reason for somebody actually initializing fonts this late.
I'm not sure if this accounts for every instance of this warning, but given that we're doing it every time we shutdown a process it must be a huge percentage of them.
Assignee | ||
Comment 1•1 year ago
|
||
If we're initializing FontPrefs this late, we're probably in the middle
of shutting down the XPCOM component manager, and the preference service
will not be available.
Technically there's a later phase, CCPostLastCycleCollection, before we
actually do the component shutdown, but both of these phases are so late
(for instance, XPCOM threads no longer exist) that we should really not be
starting up any font stuff.
The goal of this change is to avoid a very common warning in debug builds.
Comment 3•1 year ago
|
||
bugherder |
Description
•