{"record":{"id":"0a52c08d4dbd6ea8","repo":"Yalantis/uCrop","slug":"load-jxl-failed-to-configure-decoder-s","errorCode":null,"errorMessage":"load_jxl(): Failed to configure decoder '%s'.","messagePattern":"load_jxl\\(\\): Failed to configure decoder '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":57160,"sourceCode":"        cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_jxl(): Failed to get file size '%s'.\",\n                              cimg_instance,\n                              nfilename);\n      }\n      CImg<ucharT> buffer(dataSize);\n      cimg::fread(buffer._data,buffer._width,nfile);\n      cimg::fclose(nfile);\n\n      bool hasAlpha = false, isGray = false;\n      uint32_t nChannels = 0;\n      JxlBasicInfo jxlInfo;\n      JxlPixelFormat format = { 1,JXL_TYPE_UINT8,cimg::endianness()?JXL_BIG_ENDIAN:JXL_LITTLE_ENDIAN,0 };\n      CImg<ucharT> imgData;\n      JxlDecoder *decoder = JxlDecoderCreate(NULL);\n      if (JXL_DEC_SUCCESS!=JxlDecoderSubscribeEvents(decoder,JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE)) {\n        JxlDecoderDestroy(decoder);\n        throw CImgIOException(_cimg_instance\n                              \"load_jxl(): Failed to configure decoder '%s'.\",\n                              cimg_instance,\n                              nfilename);\n      }\n      if (JXL_DEC_SUCCESS!=JxlDecoderSetInput(decoder,buffer._data,buffer._width)) {\n        JxlDecoderDestroy(decoder);\n        throw CImgIOException(_cimg_instance\n                              \"load_jxl(): Failed to load image data '%s'.\",\n                              cimg_instance,\n                              nfilename);\n      }\n      JxlDecoderCloseInput(decoder);\n\n      while (true) {\n        JxlDecoderStatus status = JxlDecoderProcessInput(decoder);\n        if (status==JXL_DEC_SUCCESS || status==JXL_DEC_FULL_IMAGE) break;\n        else if (status==JXL_DEC_ERROR || status==JXL_DEC_NEED_MORE_INPUT) {\n          JxlDecoderDestroy(decoder);","sourceCodeStart":57142,"sourceCodeEnd":57178,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L57142-L57178","documentation":"load_jxl() creates a JxlDecoder and subscribes to JXL_DEC_BASIC_INFO and JXL_DEC_FULL_IMAGE events. If JxlDecoderSubscribeEvents does not return JXL_DEC_SUCCESS the decoder cannot be used, so CImg destroys it and throws. This is an internal libjxl setup failure, not a problem with the image data itself.","triggerScenarios":"JxlDecoderSubscribeEvents(decoder, JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE) returns anything other than JXL_DEC_SUCCESS during load_jxl(filename).","commonSituations":"Linking against an incompatible or broken libjxl build (ABI mismatch), a NULL decoder from failed JxlDecoderCreate (e.g. OOM), or a stale/mismatched jxl header/library pair in the NDK build.","solutions":["Verify the linked libjxl version matches the headers used to compile (clean rebuild of the JNI library).","Check that JxlDecoderCreate succeeded (non-NULL) before subscribing; handle allocation failure in the environment.","Upgrade to a stable libjxl release; avoid mixing jxl shared libraries of different versions at runtime."],"exampleFix":"// before\nimg.load_jxl(\"photo.jxl\"); // fails with mismatched libjxl\n// after\n// rebuild jni against a single consistent libjxl version, e.g. in Android.mk:\n// LOCAL_SHARED_LIBRARIES += jxl jxl_threads\n// then: img.load_jxl(\"photo.jxl\");","handlingStrategy":"try-catch","validationCode":"bool jxlRuntimeOk() {\n  JxlDecoder* d = JxlDecoderCreate(nullptr);\n  if (!d) return false;\n  bool ok = JXL_DEC_SUCCESS == JxlDecoderSubscribeEvents(d, JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE);\n  JxlDecoderDestroy(d);\n  return ok;\n}","typeGuard":null,"tryCatchPattern":"try { img.load_jxl(path); } catch (CImgIOException& e) { if (strstr(e.what(), \"configure decoder\")) reportLibJxlSetupProblem(); }","preventionTips":["Pin a single libjxl version for headers and runtime .so","Probe decoder availability once at startup","Clean-rebuild JNI after any libjxl upgrade"],"tags":["jxl","decoder-init","libjxl","cimg"],"backgroundTag":"module-init-failed","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}