web-worker

Service Worker vs Shared Worker

…衆ロ難τιáo~ 提交于 2019-12-03 06:34:36
问题 What is the difference between Service Worker and Shared Worker? When should I use Service Worker instead of Shared Worker and vice versa? 回答1: A service worker has additional functionality beyond what's available in shared workers, and once registered, they persist outside the lifespan of a given web page. Service workers can respond to message events, like shared workers, but they also have access to additional events. Handling fetch events allows service workers to intercept any network

Create a Web Worker from a Chrome Extension content script

久未见 提交于 2019-12-03 05:59:27
问题 I'm trying to create a Web Worker from my extension's content script, but it's getting blocked by a SecurityError (same origin policy). What's the best way to do this? From my content script: var workerURL = chrome.extension.getURL("js/searchWorker.js"); var lunrWorker = new Worker(workerURL); From the manifest: "content_scripts": [ { "matches": ["http://localhost:8000/*"], "js": ["js/jquery.min.js", "js/jquery.highlight.js", "js/index.js"], "css": ["css/bootstrap.css", "css/styles.css"] } ]

Using importsScripts within Blob in a karma environment

馋奶兔 提交于 2019-12-03 05:44:11
I am working on a small project of mine using karma, and jasmine. My targeted browser is chrome 32. I am trying to import scripts within a web worker whom I have instanciated through a blob as follows : describeAsyncAppliPersephone("When the application project to DOM", function() { it("it should call the function of DomProjection in the project associated with its event", function() { var eventSentBack = { eventType: 'testReceived', headers: { id: 14, version: 4 }, payLoad: { textChanged: 'newText' } }; var isRendered = false; var fnProjection = function(event, payload) { isRendered = true; }

Web Workers vs Promises

做~自己de王妃 提交于 2019-12-03 04:56:36
问题 In order to make a web app responsive you use asynchronous non-blocking requests. I can envision two ways of accomplishing this. One is to use deferreds/promises. The other is Web Workers. With Web Workers we end up introducing another process and we incur the overhead of having to marshal data back and forth. I was looking for some kind of performance metrics to help understand when to chose simple non-blocking callbacks over Web Workers. Is there some way of formulating which to use without

Javascript Web Workers File Upload

╄→гoц情女王★ 提交于 2019-12-03 04:38:40
问题 I am trying to make a html uploader for very large files using HTML5 and Web Workers. Atm it uploads slowly but consumes alot of memory. I think it is transferring the whole file to the memory when it adds it to the form. Heres the code: jswebworker.js: /*importScripts('webworkerFormData.js');*/ (function() { // Export variable to the global scope (this == undefined ? self : this)['FormData'] = FormData; var ___send$rw = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype['send'] =

Can Web Workers utilize 100% of a multi-core CPU?

与世无争的帅哥 提交于 2019-12-03 04:17:02
问题 I've been trying to find out just how capable web workers are of distributing processor load. I've yet to find any demos that seem to be able to get my quad core 2600k to even 50%, let alone 100%. Here's a web worker demo I've tried to max my CPU on: http://nerget.com/rayjs-mt/rayjs.html (If you go into the page's HTML with firebug /chrome-inspect-element and make the canvas larger, you can make it raytrace a much larger image - I set mine to 1920 x 1080) Even with 4, 8, 16 workers selected,

How to prevent HTML5 Web Workers from locking up thus correctly responding to messages from parent

∥☆過路亽.° 提交于 2019-12-03 03:13:33
I'm using web workers to do some CPU intensive work but have the requirement that the worker will respond to messages from the parent script while the worker is still processing. The worker however will not respond to messages while it is locked in a processing loop, and I have not found a way to say poll the message queue. Thus it seems like the only solution is to break processing at an interval to allow any messages in the queue to be serviced. The obvious options are to use a timer (say with setInterval) however I have read that the minimum delay between firings is quite long ( http:/

Web Worker blocked by main thread in Chrome

ⅰ亾dé卋堺 提交于 2019-12-03 02:15:17
I have a Web Worker . I wish to make periodic network requests with it. One thing I particularly want is to make these requests even if the main JS execution thread is blocked (eg by a window.alert). I'm using Chrome 38. However, when I attempt to make network requests in the worker, the requests appear to be blocked by the UI thread. Here is a contrived example to illustrate the problem: base.js: var worker = new Worker("/worker.js"); setTimeout(function() { console.log("begin blocking"); var startDt = new Date(); var blockPeriod = 5000; var a; // Obviously we'd never actually do this, but

Why was HTML5 Web Workers support removed from the Android browser in versions 2.2 and up?

假装没事ソ 提交于 2019-12-02 21:42:26
I'm trying to learn something about JavaScript threading. And from a tutorial I learned about HTML5 API web worker. This API enables JavaScript multi-threading. So I start to figure out how and where can I use this feature. Form http://caniuse.com/#search=worker I find this API is only supported in lower version of Android browser. It is unavailable in Android 2.2 and later. Is this result correct?I f it is, is it because of the performance consideration? On which version will this API be available? from config.h of Android 2.2. commit 68698168e7547cc10660828f1fb82be7a8efa845 Author: Steve

Degrading gracefully with Web Workers

天涯浪子 提交于 2019-12-02 20:36:33
So I'm starting to hear more and more about Web Workers . I think it's absolutely fantastic, but the question I haven't seen anyone really tackle so far is how to support older browsers that do not yet have support for the new technology. The only solution I've been able to come up with so far is to make some sort of wrapper around the web worker functionality that would fall back to some crazy timer based solution that would simulate multi-threaded execution. But even in that case, how does one detect whether web workers is a supported feature of the browser currently executing the javascript