airbnb / lottie-web

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
MIT License
30.66k stars 2.88k forks source link

Failed to execute 'postMessage' on 'Worker': An OffscreenCanvas could not be cloned because it was not transferred. #3090

Open Madixin opened 6 months ago

Madixin commented 6 months ago

I want to test use webworker to render lottie for canvas,but got error: Failed to execute 'postMessage' on 'Worker': An OffscreenCanvas could not be cloned because it was not transferred.

I copy code from https://chromium.googlesource.com/chromium/src/+/refs/tags/78.0.3895.4/third_party/lottie/README.md

let offscreenCanvas = document.getElementById('a').transferControlToOffscreen();
let animationData = JSON_LOTTIE_ANIMATION_DATA;

let worker = new Worker('lottie_worker.min.js');
worker.postMessage({
  canvas: offscreenCanvas,
  animationData: animationData,
  drawSize: {
    width: 200,
    height: 100
  }
  params: {
    loop: true,
    autoplay: true
  }
})

Tell us about your environment lottie-web-5.12.2 lottie-web-5.10.2

Madixin commented 6 months ago

Is there any sample to show how to use lottie_worke?