Repository navigation
Conversation
stb_image is a public domain implementation of several image decoders in a single C header file. SDL2_image includes a copy of it and uses it by default for JPEG and PNG. A comment in stb_image says "Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface" Since the flatpak runtimes generally do include libjpeg and libpng, there is no reason to use a possibly limited implementation. It probably also receives less security testing than the de-facto standard libraries.
|
I don't really know what to think about this. Maybe I'm too old, but "limited implementation with trivial interface" sounds like the essence of security to me. (but I can't judge the actual code myself) As for its limits: We use somewhat esoteric PNGs to save space (indexed colours with separate full alpha) that most image editors can't edit and save properly, but they work just fine with the current SDL2-image builds. And SDL itself is "Primarily of interest to game developers". :) |
|
@s09bQ5 I've just read your linked comment. Have you tried building UltraStarDeluxe with including the current manifest? If so, are you aware of any actual image files that didn't work with that build? |
|
Our game requires users to add content, so we don't have any control over the images. |
This comment was marked as spam.
This comment was marked as spam.
|
Reopen/ask to reopen if this is still relevant. The linked PR that this was made for seems to vendor SDL2_image now, and is quite possibly an exception to the use case here? |
|
Recently I've been researching this myself, so it seems the only benefit in using stb_image over native libjpeg and libpng is simply convenience and if someone just wants to minimize reliance on external libraries. For example, it might be useful for proprietary games that bundle their own version of SDL2_image. Otherwise, using native libjpeg and libpng will only give you technical advantages, not only due to security, but also due to improved performance, as they're faster than stb_image, so games might experience some improvements in loading times when loading large amount of images for example. Besides, I've also seen more upstream bug reports with stb_image usage and all major distros disable it in their SDL2_image package. So I think it wouldn't hurt to re-open and merge this. |
|
Could you please provide some links? Especially the mentioned bug reports, but also about the performance and distro package definitions, and if available, about the reasons why they do it. (I guess debian and redhat/fedora may do it at least in part because of their policy against vendoring.) I'm not against this, I'd just like to make an informed decision. |
|
I researched it about 2 weeks ago, so I don't have most of the links with me from which I acquired this info, as it was in various places. I'll share whatever I have now or have recently found: As for bug reports, here is one: libsdl-org/SDL_image#294. Here is another issue asking why stb_image is the default: libsdl-org/SDL_image#302 mentioning some of the downsides that I mentioned, plus the fact that it supports less formats. Here are some benchmarks showing that libjpeg and libpng are mostly faster: https://gudoshnikovn.github.io/libphash/benchmarks/2026-10-04-decoders-vs-stb And here are the distro packages: I haven't found any info about distro decision making regarding adding P.S, here is another bug report for NixOS, requesting disabling stb_image. It's about SDL3_image, but it mentions the downsides of stb_image: NixOS/nixpkgs#400074 |
|
I can merge a PR to ues libjpeg and libpng if somebody makes one. (given author here has not responded yet) |
stb_image is a public domain implementation of several image decoders in a single C header file. SDL2_image includes a copy of it and uses it by default for JPEG and PNG. A comment in stb_image says
"Primarily of interest to game developers and other people who can
avoid problematic images and only need the trivial interface"
Since the flatpak runtimes generally do include libjpeg and libpng, there is no reason to use a possibly limited implementation. It probably also receives less security testing than the de-facto standard libraries.