Open HexagonWin opened 3 months ago
That's pretty weird. Sounds like an error coming from the PNG library that isn't being handled right in xv, perhaps, but I'm not sure. Sounds like a library problem that's being exasperated by bad error handling is my guess. I don't think I'm going to have time to dig into this one anytime soon though, but maybe someone else can.
Did you build xv with PNG support? If not, this would result in the format not being supported. Note that it is not good enough just to set "XV_ENABLE_PNG" to true for CMake. You must also have the PNG library actually installed and it must be found by CMake; otherwise, a warning will be issued and "XV_ENABLE_PNG" will be automatically set to false.
That's a good point I hadn't considered, this does indeed sound like xv might not be able to find your PNG library.
I'm pretty sure it is built with PNG support as I'm using the FreeBSD ports collection to build it. The official binary package (from pkg) as well as the one I built from ports has the same issue. This is xv on FreeBSD's ports: https://github.com/freebsd/freebsd-ports/tree/main/graphics/xv
Running make configure
on /usr/ports/graphics/xv
does show -- Found PNG: /usr/local/lib/libpng.so (found version "1.6.43")
and PNG: ON
among the outputs. Just tested many other images and GIF, WebP, JPEG all seems to open correctly.
Can you open the two PNG files in the data/images directory of the xv repository? They all work for me with the most recent commit on the main branch.
I tried opening all the images on data/images and all except the two PNGs open correctly. Are you also on FreeBSD? This is on the latest xv 5.2.0 pkg binary (just updated my system now)
I was testing with Fedora 40. On this platform, both of the PNG files are correctly opened by xv. So, this issue appears to be BSD specific. I do not have any systems running BSD.
I have no difficulty opening those PNG files on my 14.1-STABLE using xv v5.2 and v6.0. I also build the ports myself using a poudriere environment.
What does pkg options
give you? For myself:
$ pkg options png xv
png - APNG: on
png - SIMD: on
xv - DOCS: on
xv - M17N: off
Just to verify xv thinks it can use PNG:
$ xv -V
XV - version 6.0.0-20240812.
Compiled with libjpeg 8.
Compiled with libjasper 4.2.4; using libjasper 4.2.4.
Compiled with libtiff 4.6.0 of 20230908.
Compiled with libpng 1.6.43; using libpng 1.6.43.
Compiled with zlib 1.3.1; using zlib 1.3.1.
Compiled with libwebp; decoder version: 0.4.1
encoder version: 0.4.1
...
xv is finding the libraries it wants on your system, otherwise, you would see this:
$ xv -V
ld-elf.so.1: Shared object "libpng16.so.16" not found, required by "xv"
BTW, what does file say those PNG files are?
$ file newtonian_fractal.png
newtonian_fractal.png: PNG image data, 832 x 624, 8-bit/color RGBA, non-interlaced
Lastly, what does which xv
tell you? I just want to make sure you are not using a stale xv binary or xv
is wrapped with an alias or function.
That is weird.. Here's all the outputs from my machine. (xv from quarterly pkg)
$ pwd
/home/hexagonwin/xv/data/images
$ pkg options png xv
png - APNG: on
png - SIMD: on
xv - DOCS: on
xv - M17N: off
$ xv -V
XV - version 5.2.0-20240625.
Compiled with libjpeg 8.
Compiled with libjasper 4.2.4; using libjasper 4.2.4.
Compiled with libtiff 4.6.0 of 20230908.
Compiled with libpng 1.6.43; using libpng 1.6.43.
Compiled with zlib 1.3; using zlib 1.3.1.
Compiled with libwebp; decoder version: 0.4.1
encoder version: 0.4.1
...
$ file newtonian_fractal.png
newtonian_fractal.png: PNG image data, 832 x 624, 8-bit/color RGBA, non-interlaced
$ which xv
/usr/local/bin/xv
I can open all PNGs just fine with other programs like feh.
I can open all PNGs just fine with other programs like feh.
Heh. That was going to be one of my next questions (i.e., feh). At least, it seems like the png library is good.
More things to try:
sudo pkg check -s png xv
sudo pkg check -sa
to check all packages./var/log/Xorg.0.log
or ~/.xsession-errors
.env -i DISPLAY=${DISPLAY} USER=${USER} HOME=${HOME} xv
xv -DEBUG 31 "path to PNG file"
ktrace xv "path to PNG file"
then look, using kdump, for something "odd" where it loads the file. You can jump to where it says something like NAMI "/boot/images/freebsd-brand-rev.png"
. It loads the file shortly afterwards.First two didn't show any errors, nothing related on Xorg.0.log either and ~/.xsession-errors doesn't exist.
Running env -i DISPLAY=${DISPLAY} USER=${USER} HOME=${HOME} xv ~/xv/data/images/newtonian_fractal.png
causes the same error.
I have attached the output of env -i DISPLAY=${DISPLAY} USER=${USER} HOME=${HOME} xv -DEBUG 31 ~/xv/data/images/newtonian_fractal.png
as xv-dbg31.txt and ktrace.out(just filename txt) from ktrace xv ~/xv/data/images/newtonian_fractal.png
. I'm sorry but I don't really know how to properly read those raw(?) logs..
Do you have graphics/netpbm
installed? I see /usr/local/bin/pngtopnm
being used by xv
on my computer. If it is missing, install it to see if that fixes xv
. I get the same error if I remove that package. If that fixes your problem, it looks like the package needs a runtime (i.e., RUN_DEPENDS) dependency added to it. I only have it installed because I have xscreensaver
installed.
I should have asked you to run ktrace -id xv ~/xv/data/images/newtonian_fractal.png
to see what external programs xv
is running. To see the output of ktrace in human-ish form: run ktrace
in the same directory as the ktrace.out log. It will give you a lot of information.
I think that xv
needs a better error about the needed program not working/being found.
That package was missing on my system. Installing it did indeed solve the problem :) Shall I create a PR there?
That is good news. It would be great if you created a PR there or a bug report (https://bugs.FreeBSD.org/).
I could reproduce the problem.
xv_mgcsfx contains:
PNG:magic:0:\x89\x50\x4e\x47:.png:PNM:pngtopnm %s:PNM_RAW:pnmtopng
in this case xv_mgcsfx overwrites the libpng binding.
When this line is commented out, xv can open PNG images without netpbm
suggested patch:
--- src/xv_mgcsfx.sample.orig 2024-09-01 19:56:28.000000000 +0200
+++ src/xv_mgcsfx.sample 2024-09-05 16:52:38.510863000 +0200
@@ -82,7 +82,7 @@
CAM:magic:0:\x07\x20\x4d\x4d:.cam:PNM:camtoppm::
# /* Portable Network Graphics (PNG) format : magic is "0x89 PNG" */
-PNG:magic:0:\x89\x50\x4e\x47:.png:PNM:pngtopnm %s:PNM_RAW:pnmtopng
+#PNG:magic:0:\x89\x50\x4e\x47:.png:PNM:pngtopnm %s:PNM_RAW:pnmtopng
# /* PNG(interlace):magic:0:\x89\x50\x4e\x47:.png:PNM:pngtopnm %s:PNM_RAW:pnmtopng -interlace */
# /* DB-Z, SAURUS Freehand Memo, PV-F1 Action Board, Wiz Quick Memo format */
Hello. I'm using FreeBSD 14.1. Recently after an update (haven't done so for like 2 years haha) my xv got upgraded to this fork. Since then I'm not able to open PNG any files that previously opened without problems. It simply displays "file.png: unknown format" and "Couldn't load file '/path/to/file.png'." popups and close.
This happens on both 5.0.0-20240206 and 5.2.0-20240625 (i have two machines each on different xv version) Sorry I'm new to xv so can't dig deeper..