I want to be able to send my canvas offscreen to a webworker more than once.
Here's an example code:
render() {
const worker = new Worker("some url");
const offscreen = this.canvasRef.current.transferControlToOffscreen();
this.worker.postMessage({
offscreen
}, [offscreen]);
return (
<canvas ref={this.canvasRef} height="800" width="1000" />
);
}
The idea is to be able to kill the web worker if user decides to cancel the drawing. Put when I repost the message to a new web worker, I get the following error:
DataCloneError: Failed to execute 'postMessage' on 'Worker':
An OffscreenCanvas could not be cloned because it was detached.