Bug 463914 - Unexpected error when loading unusual jxl file
Summary: Unexpected error when loading unusual jxl file
Status: RESOLVED NOT A BUG
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 5.1.5
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: amyspark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-06 08:34 UTC by CandyCorvid+kde
Modified: 2023-01-09 10:50 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
exceptional JXL file (81 bytes, image/jxl)
2023-01-06 08:34 UTC, CandyCorvid+kde
Details

Note You need to log in before you can comment on or make changes to this bug.
Description CandyCorvid+kde 2023-01-06 08:34:40 UTC
Created attachment 155067 [details]
exceptional JXL file

SUMMARY
A particular jxl file (attached) causes an unexpected error when loading in Krita. Krita opens other JXL files with no issue, and this image does not display in firefox nightly with JXL support, so I suspect that this file is an unusual edge case of the format.

The particular image is one of a collection of intentionally-small jxl files. Quoting the JXL Art Gallery page (https://jpegxl.info/art/)
> JXL art is a form of procedural image generation that exploits the powerful meta-adaptive context model (and other fancy coding tools) of JXL to produce interesting-looking images that are tiny jxl files.

STEPS TO REPRODUCE
1. download the jxl file attached to the issue (originally downloaded from the JXL Art Gallery https://jpegxl.info/art/2021-08_totocaca.jxl)
2. Open the file in Krita, e.g.
  a. Select File -> Open
  b. Select the file in the file browser

OBSERVED RESULT
Krita displays the following error:
> Could not open <Path to file>.
> Reason: Unexpected error. Please contact developers.

EXPECTED RESULT
Krita loads and renders the image.

SOFTWARE/OS VERSIONS
Windows: Windows 10 Home, version 21H2, build 19044.2364

ADDITIONAL INFORMATION
I also posted this issue to the krita-artists discourse server before being redirected to the KDE bug tracker. Original post: https://krita-artists.org/t/unexpected-error-please-contact-developers-when-loading-jxl-file/55294
Comment 1 Halla Rempt 2023-01-06 10:43:20 UTC
Amyspark, can you take a look?
Comment 2 Kampidh 2023-01-06 11:43:10 UTC
Seems like an upstream issue. I can reproduce it with libjxl's decode / djxl as well, both on v0.7.0 release used by Krita, and on libjxl latest master (git ee70a3ff) produces a same error:

> JPEG XL decoder v0.8.0 ee70a3ff [AVX2,SSE4,SSSE3,Unknown]
> Read 81 compressed bytes.
> Failed to decode image
> DecompressJxlToPackedPixelFile failed
Comment 3 amyspark 2023-01-06 20:02:40 UTC
Found it. It's "Rubin golden vase 1" from https://jpegxl.info/art/ and it doesn't render on Firefox. It does have a source linked from which I can render it, so I'll take a look after the Qt 5.15 mopping.

Assigning to myself.
Comment 4 Kampidh 2023-01-07 20:32:41 UTC
Some additional info from libjxl group:
It is indeed an upstream patch that go way back to December 2021 that prevents usage of unusual / outrageous splines for safety reasons: https://github.com/libjxl/libjxl/commit/198d5f33cfaab1ccbda83c8d36bbff99ca092600

As for why the linked source from https://jpegxl.info/art/ can still render it, possibly because it used an old version of jxl.js / WASM..
Comment 5 amyspark 2023-01-08 21:24:17 UTC
Ok, then closing as intended by upstream.
Comment 6 CandyCorvid+kde 2023-01-09 10:31:48 UTC
Could the error message be improved beyond "unexpected error"? As it is, anyone loading a file like this (malicious, contrived or otherwise) will be instructed to contact the developers
Comment 7 Halla Rempt 2023-01-09 10:50:06 UTC
Yes, that needs to be investigated. I've removed the remark about contacting developers, though -- it was both ungrammatical and unhelpful.