I have a web worker who constantly calculates large amounts of data, which at the end of the round is a js object, which then processes the ArrayBuffer and then sends it to the main stream.
There is not much that can be done to calculate, and passing an ArrayBuffer is fast. But parsing this object, however, slows down the process. Because the object itself contains arrays of more objects.
In Firefox, I get the following warning:
A script on this page may be busy, or it may have stopped responding.
You can stop the script now, open the script in the debugger,
or let the script continue.
Script: http://localhost/js/util/DataViewSerializer.js:435
Line 435 refers to the function in which I serialize the array. This line declares a for loop.
DataViewSerializer.prototype.setArray = function (array, serializer) {
var i,
l = JSUtil.hasValue(array) ? array.length : 0;
this.setUint32(l);
console.log(array, serializer);
for (i = 0; i < l; i += 1) {
if (serializer !== undefined) {
serializer.serializeTo(array[i], this);
} else {
array[i].serializeTo(this);
}
}
};
I am reading about a Transferable Object between the webmaster and the main thread. Sending ArrayBuffers seems to be the only way.
, , js ArrayBuffer? , ?