Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb worker dealing with imageData working with Firefox but not Chrome
    primarykey
    data
    text
    <p>When I run code that deals with imageData being passed to a web worker and then back, then Firefox works great but Chrome gives "Uncaught Error: DATA_CLONE_ERR: DOM Exception 25"</p> <p>Searching google suggests that older versions of Chrome used to work? </p> <p>I checked some more and it seemed as if I needed to run JSON.stringify and JSON.parse on the imagedata before sending it but then it stops working everywhere. The code that works in FF 9 is:</p> <p>image.js:</p> <pre><code>var myImageData = context.getImageData(0, 0, canvas.width, canvas.height).data; var worker = new Worker("http://direct.link/helpers/worker.js"); worker.postMessage(myImageData); worker.onmessage = function(event) { var value = event.data; switch (value.cmd){ case 'last': //doing stuff break; default: //doing stuff }); } </code></pre> <p>worker.js:</p> <pre><code>addEventListener('message', function(event) { var myImageData = event.data; // doing stuff. sendItBack(colors); }); }; function sendItBack(colors){ each(colors, function(index, value){ self.postMessage(value); }); self.postMessage({'cmd': 'last'}); } </code></pre> <p>What method should I use in order to send this imagedata back and forth the app and the web worker?</p> <p>Thanks!</p> <p>EDIT: </p> <p>If I copy to a regular array then Chrome starts working...</p> <pre><code>var newImageData = []; for (var i=0,len=myImageData.length;i&lt;len;++i) newImageData[i] = myImageData[i]; </code></pre> <p>So chrome can't pass a CanvasPixelArray to a worker but it can pass a regular Array. But firefox can.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload