{"record":{"id":"e2af56a6ef5421ac","repo":"mozilla/pdf.js","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":"Jbig2Error","httpStatus":null,"severity":"error","filePath":"src/core/jbig2_ccittFax.js","lineNumber":74,"sourceCode":"          width,\n          height,\n          CCITTOptions.K,\n          CCITTOptions.EndOfLine ? 1 : 0,\n          CCITTOptions.EncodedByteAlign ? 1 : 0,\n          CCITTOptions.BlackIs1 ? 1 : 0,\n          CCITTOptions.Columns,\n          CCITTOptions.Rows\n        );\n      } else {\n        const globalsSize = globals ? globals.length : 0;\n        if (globalsSize > 0) {\n          globalsPtr = module._malloc(globalsSize);\n          module.writeArrayToMemory(globals, globalsPtr);\n        }\n        module._jbig2_decode(ptr, size, width, height, globalsPtr, globalsSize);\n      }\n      if (!module.imageData) {\n        throw new Jbig2Error(\"Unknown error\");\n      }\n      const { imageData } = module;\n      module.imageData = null;\n\n      return imageData;\n    } finally {\n      if (ptr) {\n        module._free(ptr);\n      }\n      if (globalsPtr) {\n        module._free(globalsPtr);\n      }\n    }\n  }\n}\n\nexport { JBig2CCITTFaxImage, Jbig2Error };\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/jbig2_ccittFax.js#L56-L92","documentation":"Thrown by JBig2CCITTFaxImage.decode after _jbig2_decode/_ccitt_decode returned without populating module.imageData. The decoder ran but produced no output pixels, which the JS layer cannot interpret, so it surfaces a generic 'Unknown error'.","triggerScenarios":"The JBIG2/CCITT wasm decoder accepted the input but failed internally (corrupt stream, bad globals, mismatched width/height) without throwing, leaving module.imageData null. Reached during rendering of a JBIG2 or fax-encoded image.","commonSituations":"Damaged JBIG2 streams, mismatched /Globals, wrong width/height passed to decode (e.g. from a malformed image dict), or a wasm build bug. Hard to distinguish without the underlying wasm's own diagnostics.","solutions":["Verify the image's Width/Height and Globals are correct and match the encoded data (see errors 149/150).","Re-encode the source image to a non-JBIG2 format if the stream is irreparable.","Catch Jbig2Error at render time and skip the image while continuing the page.","Report the file to pdf.js maintainers with the PDF for decoder diagnostics."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// No reliable external pre-check; verify inputs that the wasm decoder depends on:\nfunction jbig2InputsPlausible(bytes, width, height) {\n  return bytes instanceof Uint8Array && bytes.length > 0 &&\n    Number.isInteger(width) && width > 0 &&\n    Number.isInteger(height) && height > 0;\n}","typeGuard":"function hasValidJbig2Inputs(bytes, width, height) {\n  return bytes instanceof Uint8Array && bytes.length > 0 &&\n    Number.isInteger(width) && width > 0 && Number.isInteger(height) && height > 0;\n}","tryCatchPattern":"try { await page.render({ canvasContext }).promise; }\ncatch (err) {\n  if (err?.name === 'Jbig2Error' && err.message === 'Unknown error') {\n    console.warn('JBIG2 decoder produced no output; skipping image.');\n  } else throw err;\n}","preventionTips":["Ensure image Width/Height and Globals match the encoded stream.","Re-encode irreparable JBIG2 images to a standard format.","Catch Jbig2Error and degrade per-image."],"tags":["pdf","jbig2","ccitt","decoder","malformed-pdf"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}