{"record":{"id":"ff65642bb99699fe","repo":"airbnb/lottie-web","slug":"cannot-set-data-on-wrapper-for-canvas-worker-rende","errorCode":null,"errorMessage":"Cannot set data on wrapper for canvas worker renderer","messagePattern":"Cannot set data on wrapper for canvas worker renderer","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"player/js/animation/AnimationItemWorkerOverride.js","lineNumber":53,"sourceCode":"  } else {\n    this.loop = parseInt(params.loop, 10);\n  }\n  this.autoplay = 'autoplay' in params ? params.autoplay : true;\n  this.name = params.name ? params.name : '';\n  this.autoloadSegments = Object.prototype.hasOwnProperty.call(params, 'autoloadSegments') ? params.autoloadSegments : true;\n  this.assetsPath = null;\n  if (params.animationData) {\n    dataManager.completeAnimation(\n      params.animationData,\n      this.configAnimation\n    );\n  } else if (params.path) {\n    throw new Error('Canvas worker renderer cannot load animation from url');\n  }\n};\n\nAnimationItem.prototype.setData = function () {\n  throw new Error('Cannot set data on wrapper for canvas worker renderer');\n};\n\nAnimationItem.prototype.includeLayers = function (data) {\n  if (data.op > this.animationData.op) {\n    this.animationData.op = data.op;\n    this.totalFrames = Math.floor(data.op - this.animationData.ip);\n  }\n  var layers = this.animationData.layers;\n  var i;\n  var len = layers.length;\n  var newLayers = data.layers;\n  var j;\n  var jLen = newLayers.length;\n  for (j = 0; j < jLen; j += 1) {\n    i = 0;\n    while (i < len) {\n      if (layers[i].id === newLayers[j].id) {\n        layers[i] = newLayers[j];","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/airbnb/lottie-web/blob/bede03d25d232826e0c9dca1733d542d8a7754fb/player/js/animation/AnimationItemWorkerOverride.js#L35-L71","documentation":"The worker build overrides AnimationItem.prototype.setData to always throw. setData normally binds a DOM element (scanning it for data attributes / embedded JSON), which is meaningless in a worker where no document exists. registerAnimation() and searchAnimations() both end up calling setData, so any DOM-driven registration path is disabled by design.","triggerScenarios":"Calling lottie.registerAnimation(element, animationData) with the worker build; calling lottie.searchAnimations() (which internally registers elements); any internal code path that reaches setData. These are main-thread/DOM APIs that have no worker equivalent.","commonSituations":"Using the worker build but keeping a main-thread-style call (registerAnimation/searchAnimations) in shared code; auto-search logic running in a worker; copy-pasting an integration that relies on data-anim-type attributes in markup.","solutions":["Use lottie.loadAnimation({ renderer: 'canvas', animationData }) inside the worker instead of registerAnimation/searchAnimations.","Keep registerAnimation and searchAnimations on the main thread and only delegate rendering to the worker via the worker bridge.","Remove or feature-gate any searchAnimations/registerAnimation calls when running inside a Worker (typeof document === 'undefined')."],"exampleFix":"// before (worker build)\nlottie.registerAnimation(myDomElement, animationData);\n// after\nlottie.loadAnimation({ renderer: 'canvas', animationData, loop: true, autoplay: true });","handlingStrategy":"validation","validationCode":"function safeLottieCall(lottie, isWorker) {\n  if (isWorker) {\n    return function (params) { return lottie.loadAnimation(params); }; // loadAnimation only\n  }\n  return null; // registerAnimation/searchAnimations are fine on main thread\n}\n// guard call sites\nif (!isWorker) { lottie.registerAnimation(el, animationData); }\nelse { lottie.loadAnimation({ renderer: 'canvas', animationData }); }","typeGuard":"function canUseDomRegistration() {\n  return typeof document !== 'undefined' && typeof document.getElementsByTagName === 'function';\n}","tryCatchPattern":null,"preventionTips":["Branch integration code on typeof document !== 'undefined' before calling registerAnimation/searchAnimations.","Keep DOM-based auto-discovery on the main thread only.","Document that the worker build exposes only the loadAnimation API surface."],"tags":["lottie","web-worker","dom","configuration"],"backgroundTag":null,"analyzedSha":"bede03d25d232826e0c9dca1733d542d8a7754fb","analyzedAt":"2026-08-13T05:40:22.197Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}