{"record":{"id":"88c01a52866fca83","repo":"mozilla/pdf.js","slug":"no-icc-color-space-support","errorCode":null,"errorMessage":"No ICC color space support","messagePattern":"No ICC color space support","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/icc_colorspace.js","lineNumber":55,"sourceCode":"  xhr.responseType = \"arraybuffer\";\n  xhr.send(null);\n  return xhr.response;\n}\n\nclass IccColorSpace extends ColorSpace {\n  #transformer;\n\n  #convertPixel;\n\n  static #useWasm = true;\n\n  static #wasmUrl = null;\n\n  static #finalizer = null;\n\n  constructor(iccProfile, name, numComps) {\n    if (!IccColorSpace.isUsable) {\n      throw new Error(\"No ICC color space support\");\n    }\n\n    super(name, numComps);\n\n    let inType;\n    switch (numComps) {\n      case 1:\n        inType = DataType.Gray8;\n        this.#convertPixel = (src, srcOffset) =>\n          qcms_convert_one(this.#transformer, src[srcOffset] * 255);\n        break;\n      case 3:\n        inType = DataType.RGB8;\n        this.#convertPixel = (src, srcOffset) =>\n          qcms_convert_three(\n            this.#transformer,\n            src[srcOffset] * 255,\n            src[srcOffset + 1] * 255,","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/icc_colorspace.js#L37-L73","documentation":"Thrown by the IccColorSpace constructor when IccColorSpace.isUsable is false. isUsable returns false when wasm-based QCMS support is disabled (useWasm=false, useWorkerFetch=false) or when the qcms_bg.wasm module fails to load from the configured wasmUrl. ICC color space conversion is entirely wasm-backed, so without it the constructor refuses to create an instance.","triggerScenarios":"Constructing an ICCBased color space while (a) getDocument was called without useWorkerFetch:true, (b) wasmUrl was not provided, (c) the synchronous XHR for qcms_bg.wasm failed, or (d) useWasm:false was set via IccColorSpace.setOptions. Triggered by any PDF using an ICCBased color space under those conditions.","commonSituations":"Default deployments that omit the new wasm/iccUrl API options introduced for ICC support; CSP that blocks the wasm fetch; misconfigured worker URL; environments without SharedArrayBuffer/fetch where the sync XHR cannot retrieve the module.","solutions":["Call getDocument with { useWorkerFetch:true, wasmUrl:'<url-to-qcms-dir>/', isEvalSupported:true } so the worker can fetch qcms_bg.wasm.","Ensure wasmUrl points to the directory containing qcms_bg.wasm (trailing slash) from pdfjs-dist's cmaps/standard asset location.","If your environment cannot use wasm, pre-convert ICC-based PDFs to sRGB before rendering.","Verify CSP allows worker-src and the wasm destination, and that the server serves .wasm with application/wasm."],"exampleFix":"// before\ngetDocument({ url });\n\n// after\ngetDocument({\n  url,\n  useWorkerFetch: true,\n  wasmUrl: '/pdfjs-dist/web/',  // directory containing qcms_bg.wasm\n});","handlingStrategy":"validation","validationCode":"// Validate API options before loading the document.\nfunction iccOptionsAreUsable(opts) {\n  return !!(opts && opts.useWorkerFetch && opts.wasmUrl);\n}\n// Usage:\n// if (!iccOptionsAreUsable({ useWorkerFetch, wasmUrl })) console.warn('ICC will be unavailable');","typeGuard":"function hasIccWasmConfig(opts) {\n  return opts != null &&\n    typeof opts.useWorkerFetch === 'boolean' && opts.useWorkerFetch === true &&\n    typeof opts.wasmUrl === 'string' && opts.wasmUrl.length > 0;\n}","tryCatchPattern":"try {\n  await getDocument({ url, useWorkerFetch: true, wasmUrl }).promise;\n} catch (err) {\n  if (err?.message === 'No ICC color space support') {\n    console.warn('ICC disabled; provide useWorkerFetch + wasmUrl for ICC PDFs.');\n  } else throw err;\n}","preventionTips":["Always pass useWorkerFetch:true and a correct wasmUrl when ICC PDFs may be rendered.","Serve qcms_bg.wasm with content-type application/wasm and a permissive CSP.","Verify the wasm URL resolves (trailing slash, correct directory) in DevTools."],"tags":["pdf","icc","color-space","wasm","config","qcms"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}