pygame-ce icon indicating copy to clipboard operation
pygame-ce copied to clipboard

nuitka and libpng

Open Starbuck5 opened this issue 1 year ago • 15 comments

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.

Starbuck5 avatar Jun 23 '24 23:06 Starbuck5

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 avatar Jun 24 '24 03:06 oddbookworm

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

oddbookworm avatar Jun 24 '24 05:06 oddbookworm

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

Starbuck5 avatar Jun 24 '24 05:06 Starbuck5

I tried with audio and fonts, and they seemed fine

oddbookworm avatar Jun 24 '24 05:06 oddbookworm

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 

oddbookworm avatar Jun 24 '24 05:06 oddbookworm

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?

Starbuck5 avatar Jun 24 '24 05:06 Starbuck5

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

oddbookworm avatar Jun 24 '24 05:06 oddbookworm

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

Starbuck5 avatar Jun 24 '24 05:06 Starbuck5

Yep, because our stuff is in the pygame folder

oddbookworm avatar Jun 24 '24 05:06 oddbookworm

insert plug for briefcase, which just works

oddbookworm avatar Jun 24 '24 05:06 oddbookworm

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!

Starbuck5 avatar Jun 24 '24 05:06 Starbuck5

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

oddbookworm avatar Jun 25 '24 00:06 oddbookworm

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.

Starbuck5 avatar Jun 25 '24 02:06 Starbuck5

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

oddbookworm avatar Jun 26 '24 00:06 oddbookworm

Going to wait to close this until Nuitka 2.4.8 comes out, which I've been promised will have the pull request incorporated which fixes the issue https://github.com/Nuitka/Nuitka/pull/2947

oddbookworm avatar Aug 20 '24 03:08 oddbookworm

@oddbookworm I'm assuming the issue is fixed and this can be closed?

Starbuck5 avatar May 11 '25 02:05 Starbuck5