royerlab / aydin

Aydin — User-friendly, Fast, Self-Supervised Image Denoising for All.
https://royerlab.github.io/aydin/
BSD 3-Clause "New" or "Revised" License
151 stars 14 forks source link

aydin bundle fails to start on linux with fontconfig 2.13/2.14 #163

Open anntzer opened 2 years ago

anntzer commented 2 years ago

Describe the bug Unpacking the aydin bundle and trying to run ./run_aydin.sh on a linux (fedora or arch) box with fontconfig 2.13 or fontconfig 2.14 installed at the OS level fails with

Fontconfig warning: "/etc/fonts/fonts.conf", line 5: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/48-spacing.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 4: unknown element "description"
Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 4: unknown element "description"
Fontconfig warning: FcPattern object weight does not accept value [40 210)

(even though these are listed as "warnings", they seem to break the process). (@AhmetCanSolak You may remember that I communicated this issue to you privately as well.)

To Reproduce See above.

Expected behavior No error.

Screenshots N/A

Desktop (please complete the following information):

Additional context I believe this occurs because the aydin process from the bundle uses the bundled libfontconfig.so (which is 2.12.06), but the fontconfig config files that comes with the OS (at /etc/fonts/conf.d), which use elements ("description") that are only understood by newer versions of fontconfig. Forcing the use of OS-level fontconfig (and the corresponding dependencies freetype and harfbuzz) via LD_PRELOAD =/usr/lib/libfreetype.so:/usr/lib/libharfbuzz.so:/usr/lib/libfontconfig.so solves the issue, for example; perhaps it could work to just not vendor these shared objects and assume that the host OS has recent enough versions of them? (possibly pre-running a small check that this is indeed the case)

AhmetCanSolak commented 2 years ago

Hi @anntzer ! Thank you for the bug report. Yes I remember we previously communicated about this issue.

I will check if we can ship the bundle without libfontconfig.so and make use of OS-level fontconfig files and let you know.

Meanwhile if you don't mind you can give the pypi version a chance with pip install aydin and let me know if you face the same/similar problem again?

AhmetCanSolak commented 2 years ago

Indeed I removed libfontconfig.so.1, libfreetype.so.6 and libfreetype-21ca3c10.so.6.18.2 from v0.1.13 linux bundle, and it seems to work that way on ubuntu20.04+. Could you do the same test on Fedora 35 @anntzer ?

I will also need to verify this on ubuntu18.04+ tomorrow, then if works for Fedora 35 too I can make a PR to address this for future bundles.

anntzer commented 2 years ago

Unfortunately I don't have readily access to a fedora machine anymore these days.

AhmetCanSolak commented 2 years ago

no worries @anntzer ! I will get my hands on one Fedora 35 machine and test. I will keep you posted.

AhmetCanSolak commented 2 years ago

hello @anntzer ,

I finally got a Fedora machine and I have some good news and some bad news.

good news: pip install aydin on Fedora works great as far as I tested. bad news: With Aydin bundle I am not, yet, able to reproduce the problem you shared. I faced multiple other gnome/qt/fontconfig/freetype related errors indeed. Solved some of them but not all. As we discussed before, I can basically remove the libfontconfig.so.1, libfreetype.so.6 and libfreetype-21ca3c10.so.6.18.2 files from our bundle but I am not convinced, that alone would help to make our bundle work on different Fedora installations. I might also try to make a fedora-specific build in a github-action with a fedora docker image if that helps. What do you think?

anntzer commented 2 years ago

Perhaps trying a docker image on GHA would work indeed. Sorry, I (mostly) don't have access anymore to the old fedora machine of the original (private) bug reports.