Commit bfaff1c6 authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

Disable fontconfig scans on all Linux builds

Fontconfig APIs that use the default config (config == nullptr) trigger
periodic automatic updates of font lists. When fontconfig is used on
multiple threads, as in Chromium, such a scan is able to free the default
config while it's being used by another thread.

Disable background scans to avoid this issue. This doesn't have any
effect on call sites that pass the config explicitly, including those
that pass the result of gfx::GetGlobalFontConfig().

Bug: 1004254
Change-Id: If7aa1b3d7b5823c3c93717557349a9d327ca2672
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872467Reviewed-by: default avatarEtienne Bergeron <etienneb@chromium.org>
Commit-Queue: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707961}
parent f24743af
......@@ -455,13 +455,6 @@ void CastBrowserMainParts::ToolkitInitialized() {
#endif // defined(USE_AURA)
#if defined(OS_LINUX)
// Setting rescan interval to 0 will disable re-scan. More details in
// b/141204302#comment41.
// TODO(crbug/1015146): move re-scan disable logic to GetGlobalFontConfig().
if (!FcConfigSetRescanInterval(gfx::GetGlobalFontConfig(), 0)) {
LOG(WARNING) << "Cannot disable fontconfig rescan.";
}
base::FilePath dir_font = GetApplicationFontsDir();
const FcChar8 *dir_font_char8 = reinterpret_cast<const FcChar8*>(dir_font.value().data());
if (!FcConfigAppFontAddDir(gfx::GetGlobalFontConfig(), dir_font_char8)) {
......
......@@ -33,6 +33,12 @@ class GFX_EXPORT GlobalFontConfig {
// being used (see http://crbug.com/1004254).
fc_config_ = FcConfigGetCurrent();
FcConfigReference(fc_config_);
// Set rescan interval to 0 to disable re-scan. Re-scanning in the
// background is a source of thread safety issues.
// See in http://crbug.com/1004254.
FcBool result = FcConfigSetRescanInterval(fc_config_, 0);
DCHECK_EQ(result, FcTrue);
}
~GlobalFontConfig() { FcConfigDestroy(fc_config_); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment