After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 773556 - fontconfig-monitor: do not recreate configuration every event
fontconfig-monitor: do not recreate configuration every event
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: xsettings
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2016-10-26 21:29 UTC by Cosimo Cecchi
Modified: 2016-10-28 00:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fontconfig-monitor: do not recreate configuration every event (2.10 KB, patch)
2016-10-26 21:29 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2016-10-26 21:29:56 UTC
See attached patch and commit message for an explanation of why this is needed.
Comment 1 Cosimo Cecchi 2016-10-26 21:29:58 UTC
Created attachment 338546 [details] [review]
fontconfig-monitor: do not recreate configuration every event

Currently, the fontconfig monitor will call FcInitReinitialize() for
every event triggered by the file monitor on the fontconfig
configuration directories.

For large font files this creates a situation where the configuration is
reinitialized before the file has been fully copied and available for
use in fontconfig. The result is that the cache mtime for that directory
will be updated to use the current modification time, with the new font
file not registered in the cache yet, preventing the new font to be
avaialble to applications until the fontconfig cache is forcefully
recreated.

We can fix this by ignoring CREATED and CHANGED events from the file
monitor; in both those cases we will receive a CHANGES_DONE_HINT event
when the file is completely copied in the directory.

https://phabricator.endlessm.com/T13909
Comment 2 Bastien Nocera 2016-10-27 11:28:28 UTC
Review of attachment 338546 [details] [review]:

::: plugins/xsettings/fontconfig-monitor.c
@@ +113,3 @@
+         */
+        if (event_type == G_FILE_MONITOR_EVENT_CHANGED ||
+            event_type == G_FILE_MONITOR_EVENT_CREATED)

This isn't good enough though. The G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT event is not sent for the FAM monitor, which is used when the home directory is on NFS. Instead, you should queue up a timeout (the local polling monitor uses 5 seconds, which is probably a decent default), which you'd push back for every event received.
Comment 3 Cosimo Cecchi 2016-10-27 15:07:44 UTC
(In reply to Bastien Nocera from comment #2)
> This isn't good enough though. The G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT
> event is not sent for the FAM monitor, which is used when the home directory
> is on NFS. 

I am not sure that's correct... the FAM file monitor uses GFileMonitorSource internally which will end up emitting the G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT.

See https://git.gnome.org/browse/glib/tree/gio/glocalfilemonitor.c#n272
Comment 4 Bastien Nocera 2016-10-28 00:11:37 UTC
(In reply to Cosimo Cecchi from comment #3)
> (In reply to Bastien Nocera from comment #2)
> > This isn't good enough though. The G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT
> > event is not sent for the FAM monitor, which is used when the home directory
> > is on NFS. 
> 
> I am not sure that's correct... the FAM file monitor uses GFileMonitorSource
> internally which will end up emitting the
> G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT.
> 
> See https://git.gnome.org/browse/glib/tree/gio/glocalfilemonitor.c#n272

Fine then. But please remove the reference to the internal phabricator instance, we can't read that bug (would be nice to know the origin story of that bug though).
Comment 5 Cosimo Cecchi 2016-10-28 00:33:23 UTC
Attachment 338546 [details] pushed as f1b8257 - fontconfig-monitor: do not recreate configuration every event
Comment 6 Cosimo Cecchi 2016-10-28 00:34:57 UTC
(In reply to Bastien Nocera from comment #4)
> Fine then. But please remove the reference to the internal phabricator
> instance, we can't read that bug (would be nice to know the origin story of
> that bug though).

Whoops, I forget that every time! Removed now.
The story is that clicking on the Install button of gnome-font-viewer was failing for a specific font file that was very large (around 20MB). That was caused by multiple issues -- see https://git.gnome.org/browse/gnome-font-viewer/commit/?id=15c98a962ae1fe5bea03c71943313c3abffbe6e6 for another piece of it.