Snapped app not loading fonts on Fedora (and Arch)

Please make sure you remove ~/snap/inkscape/common/.cache/fontconfig directory first. FWIW the inkscape snap from edge works here on Arch too.

The gimp or glimpse-editor snaps segfault and render boxes in the splash screen, but as I understand those do not have the special sauce @kenvandine added.

1 Like

@kenvandine Are you planning to upstream your fontconfig magic? This would benefit from being included as a snapcraft extension.

Yes, we are planning to add this to the snapcraft extension. We need to work out some details first to make this more generic.

2 Likes

I got hit by this with codium https://github.com/VSCodium/vscodium/issues/426

Any hints how to patch https://github.com/snapcrafters/codium/blob/master/snap/snapcraft.yaml to make the fonts great again?

Fedora 2.45 package has some cherry-picks that disable system font cache handling. You may need to remove the userā€™s fonts cache too rm -f ~/.cache/fontconfig/* and one from the snap, usually ~/snap/codium/common/.cache/fontconfig/*. Unfortunately deskop helpers do some weird thing and copy over the userā€™s fonts cache (which may have been generated with a problematic version of fontconfig), to the snap. Hence, a workaround is needed.

I donā€™t understand why fontconfig doesnā€™t migrate the cache ā€œdatabaseā€ like any modern app does nowadays?

If the problem with desktop helpers, then maybe they should run the migration function when copying fonts?

@mborzecki For me this wasnā€™t enough, on Fedora 32 KDE. For example, with the boxy-svg snap I had to remove the snapā€™s fontconfig folder entirely, and replace it with an empty file to prevent it from being created again, or else every time the snap launched it would regenerate the problematic fontconfig cache, and fonts wouldnā€™t work.

There is one caveat to this, is that every time I use the snap, the first time I do something that requires fontconfig cache, it hangs for a few seconds and then works.

That didnā€™t help. F32, Gnome.

āœ— rm -rf ~/.cache/fontconfig 
āœ— rm -rf ~/snap/codium/common/.cache
āœ— codium

About.

image

you were missing one command to re-generate the cache, so you just end up with a generated cache by the snap again, the full sequence should be:

$ rm -rf ~/.cache/fontconfig 
$ rm -rf ~/snap/codium/common/.cache
$ fc-cache -r
$ codium

see if this works any better ā€¦

Didnā€™t work.

image

image

well, was worth a try at least :slight_smile:

1 Like

image

Recently I was digging into the following font related bug report:

Itā€™s not an identical problem, but I think it might point to the root cause: that the contents of the fontconfig cache depend on both the fontconfig version (for the exact cache file format) and Freetype version (for what information about the font is stored in the cache).

One possibility here is that the host system has a newer Freetype than inside the snapā€™s sandbox, so the host system fontconfig caches suggest the use of a font in a way the sandbox Freetype canā€™t handle.

I think the solution is going to involve ignoring the host system fontconfig caches, and having each GNOME platform snap create and maintain a fontconfig cache that matches their (fontconfig, freetype) pair. By having all snaps that use the same platform snap share the cache, the overhead should be manageable.

2 Likes

FWIW, I see this problem in Kubuntu 20.04 with Plasma. When I first install my snap using the gnome-3-28 extension, I see rectangles. The suggested workaround fixes it:

sudo rm /var/cache/fontconfig/*
rm ~/.cache/fontconfig/*
fc-cache -r

I am trying to follow along with all of you but wondering if this is the same error.

$ cloudcompare.CloudCompare

QSocketNotifier: Can only be used with threads started with QThread
Gtk-Message: 21:49:04.756: Failed to load module ā€œcanberra-gtk-moduleā€
Gtk-Message: 21:49:04.790: Failed to load module ā€œcolorreload-gtk-moduleā€
Fontconfig warning: FcPattern object weight does not accept value [40 210)
Segmentation fault (core dumped)

Confirm this works for me too (in my case, testing with joplin-james-carroll.joplin)

I maintain Beekeeper Studio and users have reported this issue on Fedora 32 and Manjaro. Iā€™ve confirmed the broken fonts with a totally fresh VM.

Iā€™ve tried all the workarounds listed here and nothing seems to fix the fonts.

Did anyone find the correct workaround?

Any way to fix this issue in my Electron build process?

2 Likes

This does not work for me on Manjaro KDE and trying to use CloudCompare:

rm ~/.cache/fontconfig/*
[somebody ~]$ fc-cache -r
[somebody ~]$ cloudcompare.CloudCompare       
QSocketNotifier: Can only be used with threads started with QThread
Gtk-Message: 21:14:02.771: Failed to load module "canberra-gtk-module"
Gtk-Message: 21:14:02.806: Failed to load module "colorreload-gtk-module"
Fontconfig warning: FcPattern object weight does not accept value [40 210)
Segmentation fault (core dumped)

I know there is some ongoing work to make the snap caches private to respective snaps. @kenvandine did a PoC with Inkscape snap which worked well when I tried it. Perhaps he or @jamesh can comment on the current status.

2 Likes

@mborzecki thanks so much.

@kenvandine @jamesh would love to learn more about your work and how you worked around this problem. Even if I have to hard-code a font into my app or something it would be a big improvement.

Thanks for your time on this bug :pray: