novomesk/qt-jpegxl-image-plugin

Qt/C++: crash during encode/write jxl image

dbermond opened this issue · 2 comments

After installing the plugin, this Qt/C++ code crashes:

// grab a screenshot (X11) and save it to jxl format
QPixmap pixmap(qApp->primaryScreen()->grabWindow(0).copy());
pixmap.save("screenshot.jxl", "JXL");

Console output:

/build/libjxl/src/libjxl/lib/jxl/enc_ac_strategy.h:52: JXL_DASSERT: masking_field_row[by * masking_field_stride + bx] > 0
Illegal instruction (core dumped)

But this code works fine and correctly writes a jxl image:

// load existing png file into a QPixmap and save it as a new jxl file
QPixmap pixmap("myimage.png");
pixmap.save("myimage.jxl", "JXL");

Tested with both Qt5 and Qt6, with the same result.

System information:
OS: Arch Linux x86_64
Qt5: 5.15.2+kde+r211
Qt6: 6.1.2
libjxl: 0.5
Compiler: gcc 11.1.0

I believe this a bug in libjxl.

Try to save the screenshot as PNG and then to convert the PNG to JXL using cjxl.

Thank you for the reply.

Yes, saving a png file that was taken with qApp->primaryScreen()->grabWindow(0).copy() and then converting it to jxl through the cjxl command gives the same error of the crash in Qt/C++. So, looks like a libjxl bug.