Web worker working with imageData working with Firefox but not Chrome

When I run the code that accesses the imageData passed to the web worker and then back, Firefox works fine, but Chrome gives the message "Uncaught Error: DATA_CLONE_ERR: DOM Exception 25"

Does google search suggest older versions of Chrome worked?

I checked a few more, and it seemed to me that I need to run JSON.stringify and JSON.parse in imagedata before sending it, but then it stops working everywhere. Code that works in FF 9:

image.js:

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
    });
}

worker.js:

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'});
    }

What method should I use to send this imagedata back and forth to the application and web worker?

Thank!

EDIT:

If I copy to a regular array, then Chrome starts working ...

var newImageData = [];
for (var i=0,len=myImageData.length;i<len;++i) newImageData[i] = myImageData[i];

, CanvasPixelArray , . firefox .

+5
3

. , - ( , ). Chromium, , , . WebWorkers. , - .

http://jsfiddle.net/gGFSJ/9/

Chrome ( ):

window.URL does not exist
window.WebKitURL does not exist
using window.webkitURL for URL
window.BlobBuilder does not exist
using window.WebKitBlobBuilder for BlobBuilder
***Uncaught Error: DATA_CLONE_ERR: DOM Exception 25***
data=send back.
data=to worker.
data=send back.
data=0.

Firefox:

using window.URL for URL
window.BlobBuilder does not exist
window.WebKitBlobBuilder does not exist
window.webkitBlobBuilder does not exist
using window.MozBlobBuilder for BlobBuilder
data=send back.
data=to worker.
data=send back.
data=0.
data=send back.
data=[object Uint8ClampedArray].
+3

, imagedata , :

var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);

// This works beautifully
worker.postMessage({imgData:imgData});

// But this throws the exception
worker.postMessage({imgData:imgData.data});

( , ), , , , .

+5

If I copy the getimagedata.data strong> array to a regular array and then pass the array to a web worker, then Chrome will start working.

var newImageData = [];
for (var i=0,len=myImageData.length;i<len;++i) newImageData[i] = myImageData[i];

Thus, chrome cannot pass CanvasPixelArray to the worker, but it can pass a regular array. But Firefox can pass imagedata.data strong> directly.

+1
source

All Articles