offscreen-canvas

Send offscreencanvas to webworker more than once

梦想的初衷 提交于 2020-07-22 08:33:48
问题 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

An OffscreenCanvas could not be cloned because it was detached

为君一笑 提交于 2020-07-16 06:30:54
问题 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: Uncaught DOMException: Failed to execute 'postMessage' on 'Worker': An OffscreenCanvas could not be cloned because it was detached. at main (http://localhost:8000/responsivetemplate/:47:14) [index.html] <!DOCTYPE HTML> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta http-equiv="cache-control" content="max-age=0"

An OffscreenCanvas could not be cloned because it was detached

我与影子孤独终老i 提交于 2020-07-16 06:30:32
问题 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: Uncaught DOMException: Failed to execute 'postMessage' on 'Worker': An OffscreenCanvas could not be cloned because it was detached. at main (http://localhost:8000/responsivetemplate/:47:14) [index.html] <!DOCTYPE HTML> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta http-equiv="cache-control" content="max-age=0"