{"record":{"id":"e66ace290375cfee","repo":"airbnb/lottie-web","slug":"cannot-load-multiple-segments-in-worker","errorCode":null,"errorMessage":"Cannot load multiple segments in worker.","messagePattern":"Cannot load multiple segments in worker\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"player/js/animation/AnimationItemWorkerOverride.js","lineNumber":93,"sourceCode":"    }\n  }\n  this.animationData.__complete = false;\n  dataManager.completeAnimation(this.animationData);\n  this.renderer.includeLayers(data.layers);\n  var expressionsPlugin = getExpressionsPlugin();\n  if (expressionsPlugin) {\n    expressionsPlugin.initExpressions(this);\n  }\n  this.loadNextSegment();\n};\n\nAnimationItem.prototype.loadNextSegment = function () {\n  var segments = this.animationData.segments;\n  if (!segments || segments.length === 0 || !this.autoloadSegments) {\n    this.timeCompleted = this.totalFrames;\n    return;\n  }\n  throw new Error('Cannot load multiple segments in worker.');\n};\n\nAnimationItem.prototype.loadSegments = function () {\n  var segments = this.animationData.segments;\n  if (!segments) {\n    this.timeCompleted = this.totalFrames;\n  }\n  this.loadNextSegment();\n};\n\nAnimationItem.prototype.imagesLoaded = null;\n\nAnimationItem.prototype.preloadImages = null;\n\nAnimationItem.prototype.configAnimation = function (animData) {\n  if (!this.renderer) {\n    return;\n  }","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/airbnb/lottie-web/blob/bede03d25d232826e0c9dca1733d542d8a7754fb/player/js/animation/AnimationItemWorkerOverride.js#L75-L111","documentation":"The worker override of loadNextSegment throws when animationData.segments is a non-empty array AND autoloadSegments is true. The worker build does not implement progressive/multi-segment loading (fetching additional segment files on demand), so segmented assets are rejected rather than loaded incorrectly. The guard at the top of the method returns early (no throw) when segments are absent, empty, or when autoloadSegments is false.","triggerScenarios":"Loading animationData that contains a `segments` array (e.g. exported from After Effects with segmenting enabled) with the default autoloadSegments: true, using the worker build. The throw fires during configAnimation -> loadSegments -> loadNextSegment.","commonSituations":"Large/progressive Lottie exports split into segments; switching a segmented animation to the worker build for performance; receiving third-party JSON that happens to include segments.","solutions":["Set autoloadSegments: false in loadAnimation params so loadNextSegment returns early instead of throwing.","Strip the `segments` field from animationData before passing it to the worker build.","Fall back to the non-worker canvas build (lottie_canvas.js), which supports segment loading."],"exampleFix":"// before (worker build, segmented data)\nlottie.loadAnimation({ renderer: 'canvas', animationData });\n// after\nlottie.loadAnimation({ renderer: 'canvas', animationData, autoloadSegments: false });","handlingStrategy":"validation","validationCode":"function prepareWorkerAnimationData(animationData) {\n  const isWorker = (typeof WorkerGlobalScope !== 'undefined') || (typeof document === 'undefined');\n  if (isWorker && animationData.segments && animationData.segments.length) {\n    // worker build cannot load multiple segments; drop them or disable autoload\n    const clone = Object.assign({}, animationData, { segments: undefined });\n    return clone;\n  }\n  return animationData;\n}\nlottie.loadAnimation({ renderer: 'canvas', animationData: prepareWorkerAnimationData(data), autoloadSegments: false });","typeGuard":"function isWorkerSegmentSafe(animationData) {\n  const isWorker = (typeof WorkerGlobalScope !== 'undefined') || (typeof document === 'undefined');\n  return !isWorker || !animationData.segments || animationData.segments.length === 0;\n}","tryCatchPattern":null,"preventionTips":["Inspect animationData.segments before loading in the worker build.","Default to autoloadSegments:false when you only need the main segment.","Prefer the non-worker canvas build for segmented/progressive assets."],"tags":["lottie","web-worker","segments","configuration","animation-data"],"backgroundTag":null,"analyzedSha":"bede03d25d232826e0c9dca1733d542d8a7754fb","analyzedAt":"2026-08-13T05:40:22.197Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}