pygame-community / pygame-ce

🐍🎼 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
766 stars 120 forks source link

nuitka and libpng #2954

Open Starbuck5 opened 1 week ago

Starbuck5 commented 1 week ago

Received a report from a user on discord that png loading in their game crashes when frozen with Nuitka

Windows, Py3.10, pygame-ce 2.5.0, "latest nuitka"

https://discord.com/channels/772505616680878080/822265298085347368/1254516405492256949

Opening this as a placeholder so it doesn't get lost, seems like Andrew has already investigated.

oddbookworm commented 1 week ago

According to the tool nuitka uses to determine binary dependencies, here's what imageext depends on upstream image

Here's what imageext depends on for pygame-ce image

oddbookworm commented 1 week ago

For now, I've opened a pull request with Nuitka

Starbuck5 commented 1 week ago

I believe this issue would also occur with other video and audio formats, beyond just libpng and libjpeg.

oddbookworm commented 1 week ago

I tried with audio and fonts, and they seemed fine

oddbookworm commented 1 week ago

reproducer.zip

Here's the sample project I was working with Build command:

nuitka --standalone main.py --include-data-files=./alien1.png=alien1.png --include-data-files=./alien1.jpg=alien1.jpg --include-data-files=./Roboto-Regular.ttf=Roboto-Regular.ttf --include-data-files=./boom.wav=boom.wav 
Starbuck5 commented 1 week ago

SDL_image additional DLLs: image

SDL_mixer additional DLLs: image

We don't bundle 100% of these (filesize concerns), but we bundle most of them.

Can't we just tell nuitka if it's a DLL and it's in our directory it's important?

oddbookworm commented 1 week ago

I tried a wildcard *.dll, and that didn't work

Starbuck5 commented 1 week ago

Also we have to share this "hook" space with pygame?

oddbookworm commented 1 week ago

Yep, because our stuff is in the pygame folder

oddbookworm commented 1 week ago

insert plug for briefcase, which just works

Starbuck5 commented 1 week ago

I tried with audio and fonts, and they seemed fine

You tried with a WAV file. It would have the same issue as the original reporter if you tried opus or mp3 or anything else.

insert plug for briefcase, which just works

Let's have all the tools work!

oddbookworm commented 6 days ago

I've updated the pull request to Nuitka to do a wildcard glob of all dlls in the pygame(-ce) install. I don't like doing that, but it seems to be our only option with the way the sdl dynamic linking works. libpng doesn't work without the nuitka fix for us, but does work for upstream because of our custom SDL_image build. Other dlls are broken for both of us, such as libtiff and libjpeg

Starbuck5 commented 6 days ago

I feel like nuitka should do a wildcard glob of DLLs by default. What’s wrong with including all the executables?

We’re not ever going to ship out executables in our wheels that aren’t actually used.

oddbookworm commented 5 days ago

I feel like nuitka should do a wildcard glob of DLLs by default. What’s wrong with including all the executables?

We’re not ever going to ship out executables in our wheels that aren’t actually used.

This has already been basically answered in the nuitka pull request, but for future reference: It's basically nuitka trying to save on executable size by not including things that aren't necessary. All of our dlls are necessary, but I wouldn't be surprised if there are quite a few projects out there which include things that aren't really necessary