webworker クライアントに window.alert を配置すると、バックグラウンド ワーカーが動作しなくなります。これはなぜですか?
つまり、発信者:
var worker = new Worker("worker.js");
// Watch for messages from the worker
worker.onmessage = function(e){
// The message from the client:
e.data
};
worker.postMessage("start");
クライアント (worker.js)
onmessage = function(e){
if ( e.data === "start" ) {
// Do some computation
done()
}
};
function done(){
alert('don'); // ===> This kills the worker.
// Send back the results to the parent page
postMessage("done");
}