javascript - Life-time of obect urls with web-workers -
say start worker , creates object url blob:
//running in page window var worker = new worker(workerscripturl); //running in worker var u = rootscope.url || rootscope.webkiturl; var objurl = u.createobjecturl(blob);
...now (because we're lazy) don't ever call:
u.revokeobjecturl(objurl);
and instead in code started worker, call:
worker.terminate();
will kill object url, or remain duration of original page window?
ok, in absence of answer, decided test myself:
var u = window.url || window.webkiturl; var f='('+ function(rootscope){ var u = rootscope.url || rootscope.webkiturl; var blob=new blob([ "hello world!" ], { type: 'text/plain' } ); var bloburl = u.createobjecturl( blob) ; rootscope.postmessage(bloburl); }.tostring()+ ')(this)'; console.log(f); // build worker anonymous function body var bloburl = u.createobjecturl( new blob([ f ], { type: 'application/javascript' } ) ); var worker = new worker( bloburl ); worker.onmessage=function(e){ worker.terminate(); settimeout(function(){ var xhr = new xmlhttprequest(); xhr.open('get', e.data, false); xhr.send(null); console.log( xhr.responsetext ); //prints "hello world!" },5000); }; // won't needing anymore u.revokeobjecturl( bloburl );
as can seen, 5 seconds after terminate web-worker, can still read object url created.
Comments
Post a Comment