-
Notifications
You must be signed in to change notification settings - Fork 83
CoreGraphics loader #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoreGraphics loader #307
Conversation
1e9e76d to
b1c932f
Compare
enabled with ./configure option --with-coregraphics (default: auto, macOS only) Signed-off-by: Hayaki Saito <[email protected]>
b1c932f to
0a6796f
Compare
|
This looks very good. Thank you! I'm a little time challenged today, but will finish the review in the evening. I'll suggest a few small changes. I think this loader can come before libheif. libheif is itself a fallback for AVIF and a couple of other formats, but CoreGraphics works better for these cases. One question: Are you able to do a quick run in AFL or a similar fuzzer on MacOS to look for issues? |
|
I’m a beginner when it comes to fuzzing tools, but I’ve decided to start testing while consulting ChatGPT along the way. |
|
Made a fuzzer-driven test (see below). I'll run it for roughly some hours to collect coverage and stability data. |
|
Nice work on the fuzzing. If you want to re-run it in the future, you can compile chafa as normal and run it under AFL with something like this: MY_CC=afl-clang-fast
MY_CXX=afl-clang-fast++
CC=${MY_CC} CXX=${MY_CXX} LD=${MY_CC} ./configure --enable-static --disable-shared
make clean
make -j4 CFLAGS='-Og -g'
mkdir -p fuzz/in fuzz/out
cp -a tests/data/good/* tests/data/bad/* fuzz/in/
afl-fuzz -p fast -i fuzz/in -o fuzz/out -- tools/chafa/chafa --fuzz-options --threads 1 --speed max -d 0 @@Check before fuzzing that |
- Remove unnecessary line break in tools/chafa/Makefile.am - Add author name to header comment - Raise CoreGraphics loader priority to prevent AVIF animations from being treated as static images by the HEIF loader
|
I ran my custom fuzz test (
I also tried running the method you suggested using the
|
|
As a side note, when |
|
Looks good now! I'll merge it in a minute.
This happens because the signal handler doesn't print the sequence to re-enable the cursor itself. It just sets a global flag that's checked periodically in application loops. I did it that way because POSIX limits what a signal handler can do (e.g. no malloc()). The second ctrl-c hard interrupts the program. Now that I think about it, though, we may be able to pregenerate the CSI sequence and issue a quick write() in the signal handler itself. I'll make an issue for it. In the meantime, I've generally ignored the hangs because I haven't been able to reproduce the ones I've found outside AFL (usually it's just something that runs very slowly when instrumented). But crashes are always serious. I'll look at the cases you found. |


Opened a PR for Issue #301.
What this adds
./configure --without-coregraphics.By default the behavior is auto: if the flag isn’t provided, we probe the system and enable CoreGraphics when available so users don’t need to think about it. Verified on macOS (Sequoia), Linux (Debian) and MinGW: it builds cleanly and make check completes.
How it’s wired
CoreGraphicsloader is appended to the end of thechicleloader chain and used strictly as a fallback when earlier loaders can’t decode a file.Testing status
CoreGraphicsentry to the first enum value in thechicleloader list, rebuilt, and confirmed it can read:png,jpg,tiff,heif,dds,avif,pict,tga,pic,ico,bmp,jxl, animatedgif, and animatedavif.Notes & known issues
The following issues occurred only when building with the
CoreGraphicsloader temporarily set as the highest-priority loader for testing purposes.I ran into an issue where APNG animations flicker and fail to render correctly, likely due to incorrect frame disposal or blending behavior. As a workaround, APNG files are now loaded as static images. This shouldn’t be a problem when CoreGraphics is only used as a fallback.
WebP and GIF animations do play correctly, though the frame delay values reported by CoreGraphics seem slightly slower.
chafa’s current frame timing matchesChromeand other browsers, so ideally we’d align the delays to that. However, since this loader is only meant as a fallback, I decided not to dig deeper into that difference.** Priority corner case**:
with the AVIF loader disabled, animated AVIFs are currently picked up by the HEIF loader and render as a static image. Placing CoreGraphics above HEIF fixes it, but a more flexible loader‑priority mechanism would be preferable long‑term.
UTTypes available on my macOS
Maintenance