'Uncaught Error: DATA_CLONE_ERR: DOM Exception 25' thrown by web worker

后端 未结 2 933
星月不相逢
星月不相逢 2020-12-17 10:54

So I\'m creating a web worker:

var arrayit = function(obj) {
  return Array.prototype.slice.call(obj);
};
work = arrayit(images);
console.log(work);
//work =         


        
相关标签:
2条回答
  • 2020-12-17 11:18

    The original exception was most likely thrown because you tried passing a host object to the web worker (most likely a dom element). Your subsequent attempts don't throw the same error. Remember two key points: there isn't shared memory between the different threads, and the web workers can't manipulate the DOM.

    postMessage supports passing structured data to threads, and will internally serialise (or in some other way copy the value of the data recursively) the data. Serialising DOM elements often results in circular reference errors, so your best bet is to map the object you want serialised and extract relevant data to be rebuilt in the web worker.

    0 讨论(0)
  • 2020-12-17 11:24

    Uncaught DataCloneError: An object could not be cloned was reproduced when tried save to indexeddb function as object's key. Need double recheck that saved object is serializable

    0 讨论(0)
提交回复
热议问题