malmeloo / wiimmfi-rpc

A Discord rich presence implementation for Wiimmfi
GNU General Public License v3.0
34 stars 3 forks source link

Fontconfig warnings + seg-fault. #20

Open Magicrafter13 opened 3 years ago

Magicrafter13 commented 3 years ago
$ ./Wiimmfi-RPC\ v1.7.5
INFO:root:Starting...
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/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/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)
zsh: segmentation fault (core dumped)  ./Wiimmfi-RPC\ v1.7.5

Running on Manjaro Linux x86_64.

malmeloo commented 3 years ago

Hey!

Thanks for notifying me about this. I just tried running the latest version on my arch system and I'm getting the same error as you.

I'm not entirely sure what the underlying error is, but I assume it has something to do with differences in font configurations across systems. The binaries provided are built on a Ubuntu system, so that might be why.

In the meantime, you can clear your font cache to at least get it to start:

sudo rm /var/cache/fontconfig/*
rm ~/.cache/fontconfig/*

After clearing it will still show the Fontconfig warnings, but it no longer segfaults (at least on my system.)

Please let me know if this worked for you.

Magicrafter13 commented 3 years ago

Can confirm, it no longer segfaults, and I notice that the final line of text does not display either;

Fontconfig warning: FcPattern object weight does not accept value [40 210) Maybe that can help.

Also, I didn't actually delete the contents of each directory - I backed them up first. I'm going to re-add the files 1 at a time (or several at a time if that proves too cumbersome), in hopes that maybe I can narrow down a specific file for you?

Edit: Okay, well, interestingly: when I moved both of the backup directories back to their original names (sudo mv /var/cache/fontconfig.bak /var/cache/fontconfig), the program still launches successfully, no segfault...

malmeloo commented 3 years ago

That's interesting... I'm honestly kind of clueless how PyQt works with fonts on Linux, so I have no idea why that happens.

I suspect this is an issue with the system the binaries are built on, because it works fine when building it on my own system. Perhaps it works fine out of the box when using it on Ubuntu, but I can't check that myself.

I've been wanting to transfer the CI stuff to GitHub Actions anyway, so maybe that makes it more reliable on other Linux distros? It's possible that the fonts on AppVeyor's Ubuntu machine are out of date. So much guesswork here...

Anyway, I probably won't get around to really mess with this until later next week. I'll run a quick strace now to see if I can find anything obvious, though.

malmeloo commented 3 years ago

I couldn't help myself. Quick update:

PyInstaller packages the libfontconfig.so.1 from the system that the module was built on. My guess is that these warnings:

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"
...

are caused by the system that the binary was built on running an older version of fontconfig. When you then run it on a newer system (such as arch, because it's bleeding edge), your system will use the older library to read newer config files because your system-wide fontconfig is on the latest version, and these config files are auto-generated by your newer fontconfig.

The only real way to solve this is to build the program on a newer machine, or to upgrade fontconfig on an old machine (ew). I'll look into this when I switch over to GH Actions, hopefully that also solves the segfaults.

Magicrafter13 commented 3 years ago

I suspect this is an issue with the system the binaries are built on, because it works fine when building it on my own system. Perhaps it works fine out of the box when using it on Ubuntu, but I can't check that myself.

I'd like to build it myself, but I've never compiled anything without a Makefile :) (I don't use/know python.). Is it pretty simple to build? I have python, and pip already.

malmeloo commented 3 years ago

It should be pretty simple, yes. There's a build script in the root of the repo, so you can just clone it and run python3 build.py build.

If you can't get it to work just let me know, but I'm heading off to sleep now so I'll respond in the morning.

Magicrafter13 commented 3 years ago

I had to change line 60 of build.py, added a space before the -m like so: command = os.environ['PYTHON'] + ' -m PyInstaller'. Otherwise I got output complaining about how python-m command wasn't found :) .

After that it seemed to build fine (minus errors/warnings about some .so files not having executable permissions which I changed so it would stop showing that). When I ran it though, after unzipping it, I got this:

Traceback (most recent call last):
  File "rpcgui.py", line 9, in <module>
    from PyQt5 import QtGui as Qg
ModuleNotFoundError: No module named 'PyQt5.sip'
[80224] Failed to execute script rpcgui

I looked into it a bit, but kinda gave up. (I made sure I had everything in requirements.txt.)

malmeloo commented 3 years ago

whoops, sorry for that. I just pushed a commit that fixes the python-m error as well as the PyQt5-sip one. It should build successfully now.

I'll probably create a "bugfix" release soon where I fix all of the building shenanigans, I also realized it does not package the icons directory which means that backgrounding to the systray does not work properly. Probably gonna fully switch over to GH Actions while I'm at it as well.

EDIT: Building has finished, use the binary here if you don't feel like rebuilding it yourself: BUILD-38772300

malmeloo commented 3 years ago

I just set up GitHub Actions and tried building some releases, and I'm no longer getting any warnings whatsoever on my arch system. There's still some issues related to the build system itself that I need to iron out, so I haven't completely dropped Appveyor yet. However, I'm expecting to be able to make the full switch soon.

You can find the current prerelease builds here: https://github.com/DismissedGuy/wiimmfi-rpc/actions/runs/774676686#artifacts The zip structure is like, really weird, I still need to fix that but I'm sure you'll figure it out.

Magicrafter13 commented 3 years ago

I still get the same runtime error about PyQt5.sip. EDIT - When I compile it, not when running the one from GitHub Actions. As per my best guess, I appear tohave the necessary library installed.

$ pacman -Ss qt5 | grep sip
extra/python-pyqt5-sip 12.8.1-3 [installed]
    The sip module support for PyQt5

It doesn't matter too much, since I can still just run the pre-built from the release, but I am curious what's different about my environment.

(Also if I were to throw out a gripe, having to unzip every time is a little annoying ;).) -Nevermind, I just realized it puts it in the dist directory.

malmeloo commented 3 years ago

Considering the build from GitHub Actions runs the exact same script (as long as you've pulled the latest code from master), I'm afraid that's something on your end. You could try removing all pip packages, uninstalling python-pyqt5-sip using pacman and re-cloning the project to remove all cache dirs before rebuilding, but if that doesn't work I don't know what's wrong either.

The build script creates a zip file because it made it easier to just upload the zip as an artifact on AppVeyor so I could just re-upload them to a GH release. It appears that the current GH Actions setup is able to zip directories automatically (which is what created the weird structure in the first place, I think) so I can just have it move all the relevant files to a directory and remove all pyinstaller cache dirs, that should clean up the build environment by a lot.