An OffscreenCanvas could not be cloned because it was detached

前端 未结 1 2000
长发绾君心
长发绾君心 2021-01-24 02:29

yesterday returned to my hobby with HTML canvas and tried to do a rendering in a separate thread, just to face the following error in the console:

Uncaugh

相关标签:
1条回答
  • 2021-01-24 03:05

    You should send OffscreenCanvas to worker only once:

    worker.postMessage({canvas: offscreenCanvas}, [offscreenCanvas]);
    
    while (dTime > timeProduct) {
        worker.postMessage({ posX, posY });
        dTime -= timeProduct;
    }
    
    0 讨论(0)
提交回复
热议问题