Created attachment 190448 [details] Example HEIF that doesn't load SUMMARY Regression(s) from the libheif update. Unsure if related to each other. Exporting as HEIF crashes, loading some HEIF files shows "unsupported features" error. Thread: https://krita-artists.org/t/issue-opening-heic-files/167082 STEPS TO REPRODUCE A. Export a file as HEIF. B. Attempt to load attached HEIF file saved by GIMP (loading a file from a previous version of Krita works for some reason). OBSERVED RESULT Export a file as HEIF: > krita.file: Starting "image/heic" encoding. > krita.file: saving as 8bit rgba segmentation fault > Thread 24 Crashed:: Thread (pooled) > 0 libsystem_platform.dylib 0x19932d05c _platform_memset + 108 > 1 libx265.215.dylib 0x11c2e2250 x265::Lowres::init(x265::PicYuv*, int) + 1400 > 2 libx265.215.dylib 0x11c213cd4 x265::PreLookaheadGroup::processTasks(int) + 180 > 3 libx265.215.dylib 0x11c210a98 x265::Lookahead::slicetypeDecide() + 692 > 4 libx265.215.dylib 0x11c210788 x265::Lookahead::findJob(int) + 80 > 5 libx265.215.dylib 0x11c21291c x265::Lookahead::getDecidedPicture() + 144 > 6 libx265.215.dylib 0x11c2466dc x265::Encoder::encode(x265_picture const*, x265_picture*) + 6704 > 7 libx265.215.dylib 0x11c25372c x265_encoder_encode + 88 > 8 libheif.1.20.2.dylib 0x11cfe73f0 0x11cf18000 + 848880 > 9 libheif.1.20.2.dylib 0x11cf881d4 0x11cf18000 + 459220 > 10 libheif.1.20.2.dylib 0x11cf9e244 0x11cf18000 + 549444 > 11 libheif.1.20.2.dylib 0x11cf9c1ac 0x11cf18000 + 541100 > 12 libheif.1.20.2.dylib 0x11cf9d5b8 0x11cf18000 + 546232 > 13 libheif.1.20.2.dylib 0x11cf4a280 0x11cf18000 + 205440 > 14 libheif.1.20.2.dylib 0x11cf7b848 heif_context_encode_image + 520 > 15 kritaheifexport.so 0x10d16ce80 heif::Context::encode_image(heif::Image const&, heif::Encoder&, heif::Context::EncodingOptions const&) + 40 > 16 kritaheifexport.so 0x10d16b704 HeifExport::convert(KisDocument*, QIODevice*, KisPinnedSharedPtr<KisPropertiesConfiguration>) + 7624 > 17 libkritaui.21.0.0.dylib 0x103472354 KisImportExportManager::doExportImpl(QString const&, QSharedPointer<KisImportExportFilter>, KisPinnedSharedPtr<KisPropertiesConfiguration>) + 312 > 18 libkritaui.21.0.0.dylib 0x10347129c KisImportExportManager::doExport(QString const&, QSharedPointer<KisImportExportFilter>, KisPinnedSharedPtr<KisPropertiesConfiguration>, QString) + 112 Attempt to load attached HEIF file: > krita.file: loading heif 0 1 8 > krita.file: profile type is icc profile Error occurs. > The file format contains unsupported features. Note: Before the libheif update, loading the file shows > loading heif 1 3 8 > profile type is icc profile > planar heif file, bits: 8 Note2: On 6.0.0/5.3.0 -beta1, this file loads but is blank (transparent). EXPECTED RESULT File exports / loads correctly. SOFTWARE/OS VERSIONS Krita 6.0.0/5.3.0 -beta3
Git commit 0b852994866c82ca4bd59bdc3901570aa8cddb1c by Dmitry Kazakov. Committed on 09/03/2026 at 14:51. Pushed by dkazakov into branch 'master'. Explicitly request libheif about the chroma of the RGB space M +1 -1 plugins/impex/heif/HeifImport.cpp https://invent.kde.org/graphics/krita/-/commit/0b852994866c82ca4bd59bdc3901570aa8cddb1c
Git commit 46e062b2563e422ecf6c2fee579537fcb5553ee3 by Dmitry Kazakov. Committed on 09/03/2026 at 14:51. Pushed by dkazakov into branch 'krita/6.0'. Explicitly request libheif about the chroma of the RGB space M +1 -1 plugins/impex/heif/HeifImport.cpp https://invent.kde.org/graphics/krita/-/commit/46e062b2563e422ecf6c2fee579537fcb5553ee3
The import part is fixed, export still crashes unchanged.
Of note, it only crashes when "lossless" is checked upon export.
Ok, this is the point where libheif calls x265 in the version of the code of 1.20.2: https://github.com/strukturag/libheif/blob/fcb709105feab147c31ba24aca4cc5be23c1f27e/libheif/plugins/encoder_x265.cc#L913 This code seems pretty different looking in master, but that's also because libheif now supports exporting image sequences (read: animation) to heif: https://github.com/strukturag/libheif/blob/22b6266bf03a9f016f84a9b57b80e1dd7c79d64a/libheif/plugins/encoder_x265.cc#L1108 Then there's the place where it crashes in x265: https://bitbucket.org/multicoreware/x265_git/src/8be7dbf8159ddfceea4115675a6d48e1611b8baa/source/common/lowres.cpp#lines-347 I'm having a really hard time navigating bitbucket, so I cannot find the precise code version we're using in the appimages.
Git commit 8b23a3de2c7f3c01697a9de3beaf7b9e1729fe42 by Dmitry Kazakov. Committed on 17/03/2026 at 13:05. Pushed by dkazakov into branch 'transition.now/qt6'. Fix a crash when trying to export a lossless HEIF image The custom patch from Handbrake is broken and tries to memset on an unused and non-allocated buffer. This is the patch to blame: A08-Fix-inconsistent-bitrate-in-second-pass.patch M +1 -0 ext_libx265/CMakeLists.txt A +41 -0 ext_libx265/patches/0003-Fix-a-crash-when-trying-to-export-a-lossless-image.patch https://invent.kde.org/packaging/krita-deps-management/-/commit/8b23a3de2c7f3c01697a9de3beaf7b9e1729fe42
Git commit 983c361988ac7a64d53a5022cc5af88eae52f570 by Dmitry Kazakov. Committed on 17/03/2026 at 13:11. Pushed by dkazakov into branch 'master'. Fix a crash when trying to export a lossless HEIF image The custom patch from Handbrake is broken and tries to memset on an unused and non-allocated buffer. This is the patch to blame: A08-Fix-inconsistent-bitrate-in-second-pass.patch M +1 -0 ext_libx265/CMakeLists.txt A +41 -0 ext_libx265/patches/0003-Fix-a-crash-when-trying-to-export-a-lossless-image.patch https://invent.kde.org/packaging/krita-deps-management/-/commit/983c361988ac7a64d53a5022cc5af88eae52f570
Git commit 77eb510366a26afed6a24a20554959d66f2e83c2 by Dmitry Kazakov. Committed on 31/03/2026 at 11:45. Pushed by dkazakov into branch 'transition.now/win-clang21'. Fix a crash when trying to export a lossless HEIF image The custom patch from Handbrake is broken and tries to memset on an unused and non-allocated buffer. This is the patch to blame: A08-Fix-inconsistent-bitrate-in-second-pass.patch M +1 -0 ext_libx265/CMakeLists.txt A +41 -0 ext_libx265/patches/0003-Fix-a-crash-when-trying-to-export-a-lossless-image.patch https://invent.kde.org/packaging/krita-deps-management/-/commit/77eb510366a26afed6a24a20554959d66f2e83c2