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



commit 436c72d17300b5a533ae7ae5822362c5f3f231bf
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

 configure.ac                                      | 4 ++++
 libgnome-desktop/Makefile.am                      | 1 +
 libgnome-desktop/gnome-desktop-thumbnail-script.c | 4 ++++
 3 files changed, 9 insertions(+)
---
diff --git a/configure.ac b/configure.ac
index 16273aef..be1a23a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,10 @@ PKG_CHECK_MODULES(GNOME_DESKTOP, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED
                                  iso-codes
                                  $UDEV_PKG $SECCOMP_PKG)
 
+PKG_CHECK_MODULES(FONTCONFIG, fontconfig)
+FONTCONFIG_CACHE_PATH=$($PKG_CONFIG --variable cachedir fontconfig)
+AC_SUBST(FONTCONFIG_CACHE_PATH)
+
 XKB_BASE=$($PKG_CONFIG --variable xkb_base xkeyboard-config)
 AC_SUBST(XKB_BASE)
 
diff --git a/libgnome-desktop/Makefile.am b/libgnome-desktop/Makefile.am
index 06367001..80245edc 100644
--- a/libgnome-desktop/Makefile.am
+++ b/libgnome-desktop/Makefile.am
@@ -14,6 +14,7 @@ AM_CPPFLAGS =                                                 \
        -DGNOMELOCALEDIR=\""$(localedir)"\"                     \
        -DGTK_DISABLE_DEPRECATION_WARNINGS                      \
        -DISO_CODES_PREFIX=\""$(ISO_CODES_PREFIX)"\"            \
+       -DFONTCONFIG_CACHE_PATH=\""$(FONTCONFIG_CACHE_PATH)"\"  \
        -DLIBLOCALEDIR=\""$(prefix)/lib/locale"\"               \
        -DPNP_IDS=\""$(PNP_IDS)"\"                              \
        -DXKB_BASE=\""$(XKB_BASE)"\"
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",


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