[gnome-desktop/wip/hadess/thumbnail-font-cache] thumbnail: Fix slow thumbnailer due to missing font cache



commit 9bc2e33656d7e7df95e7453e7fa82cb1df8abb7d
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 8 12:47:05 2019 +0100

    thumbnail: Fix slow thumbnailer due to missing font cache
    
    On some distributions, the font cache doesn't live in /usr but in /var,
    which we don't allow access to when sandboxing the thumbnailers. Bind
    mount the fontconfig cache directory read-only if it lives outside /usr,
    to speed up thumbnailer startup.
    
    Closes: #90

 libgnome-desktop/gnome-desktop-thumbnail-script.c | 4 ++++
 libgnome-desktop/meson.build                      | 1 +
 meson.build                                       | 2 ++
 3 files changed, 7 insertions(+)
---
diff --git a/libgnome-desktop/gnome-desktop-thumbnail-script.c 
b/libgnome-desktop/gnome-desktop-thumbnail-script.c
index 52576638..9468b51c 100644
--- a/libgnome-desktop/gnome-desktop-thumbnail-script.c
+++ b/libgnome-desktop/gnome-desktop-thumbnail-script.c
@@ -565,6 +565,10 @@ add_bwrap (GPtrArray   *array,
         }
     }
 
+  /* fontconfig cache if necessary */
+  if (!g_str_has_prefix (FONTCONFIG_CACHE_PATH, "/usr/"))
+    add_args (array, "--ro-bind", FONTCONFIG_CACHE_PATH, FONTCONFIG_CACHE_PATH, NULL);
+
   add_args (array,
            "--proc", "/proc",
            "--dev", "/dev",
diff --git a/libgnome-desktop/meson.build b/libgnome-desktop/meson.build
index 75bfee2a..c365b448 100644
--- a/libgnome-desktop/meson.build
+++ b/libgnome-desktop/meson.build
@@ -5,6 +5,7 @@ libargs = [
   '-DGNOMELOCALEDIR="@0@"'.format(localedir),
   '-DLIBLOCALEDIR="@0@"'.format(liblocaledir),
   '-DISO_CODES_PREFIX="@0@"'.format(iso_codes_prefix),
+  '-DFONTCONFIG_CACHE_PATH="@0@"'.format(fontconfig_cache_path),
   '-DXKB_BASE="@0@"'.format(xkb_base)
 ]
 
diff --git a/meson.build b/meson.build
index 44f73d7d..0ac909cf 100644
--- a/meson.build
+++ b/meson.build
@@ -42,6 +42,7 @@ glib_dep = dependency('glib-2.0', version: glib_req)
 gio_dep = dependency('gio-2.0', version: glib_req)
 gio_unix_dep = dependency('gio-unix-2.0', version: glib_req)
 schemas_dep = dependency('gsettings-desktop-schemas', version: schemas_req)
+fontconfig_dep = dependency('fontconfig')
 xkb_config_dep = dependency('xkeyboard-config')
 iso_codes_dep = dependency('iso-codes')
 x_dep = dependency('x11')
@@ -58,6 +59,7 @@ if supported_os.contains(host_os) and not unsupported_cpus.contains(host_cpu)
 else
   seccomp_dep = dependency('', required: false)
 endif
+fontconfig_cache_path = fontconfig_dep.get_pkgconfig_variable('cachedir')
 
 xkb_base = xkb_config_dep.get_pkgconfig_variable('xkb_base')
 iso_codes_prefix = iso_codes_dep.get_pkgconfig_variable('prefix')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]