- From: Ivan Kozik <ivan@ludios.org>
- Date: Thu, 23 Sep 2010 09:06:20 +0000
What should happen when instantiating a Worker that cannot be started because of the limit on the number of workers? Chrome 6 and Chromium 7.0.532.0 (60255) put the 17th worker in a queue, to be created when some existing worker terminates. This queue seems to be limitless in size (or at least it is large). In Opera 10.70 (9049), instantiating the 17th Worker throws "Error: QUOTA_EXCEEDED_ERR". I'd much prefer that it failed immediately, rather than being put in a queue. I use a SharedWorker as an enhancement, and I don't want to implement a timeout for the Worker spawning (I'd rather have it fail, so that I can immediately do something else). I can avoid spawning more than 16 workers, but I never know if another tab has already created enough workers to exhaust the global worker limit (64 in Chrome, ~118 in Opera). And if I really want to spawn the worker, I can always try spawning it again soon. This message describes why Chromium queues up excessive workers: http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-July/020865.html I'm not sure that making it work like a "sea of XHRs" is the right thing, for two reasons: 1) Workers often stay running for a long time; XHRs are usually short-lived. 2) Most web applications don't expect to definitely have access to a Worker, so they work around it by running code in the page instead of the worker. This same code path could be used when the worker limit is exhausted. With XHRs, there's generally no workaround: you need the data, no matter what. Here's a crude test page that instantiates 17 workers: <!doctype html> <div id="log"></div> <script> var workers = []; for(var i=0; i < 17; i++) { try { workers.push(new Worker('empty.js')); document.getElementById('log').innerHTML += 'Worker #' + i + ' instantiated.<br>'; } catch(e) { document.getElementById('log').innerHTML += e.toString() + '<br>'; } } </script> Any thoughts would be appreciated. Thanks, Ivan
Received on Thursday, 23 September 2010 02:06:20 UTC