web-worker

Is there a way to create out of DOM elements in Web Worker?

半世苍凉 提交于 2019-11-26 10:56:05
问题 Context: I have a web application that processes and shows huge log files. They\'re usually only about 100k lines long, but it can be up to 4 million lines or more. To be able to scroll through that log file (both user initiated and via JavaScript) and filter the lines with decent performance I create a DOM element for each line as soon as the data arrives (in JSON via ajax). I found this better for performance then constructing the HTML at the back-end. Afterwards I save the elements in an

Passing objects to a web worker

此生再无相见时 提交于 2019-11-26 09:25:30
问题 I\'m trying to pass an object to a web worker through the postMessage function. This object is a square that has a couple of functions to draw himself on a canvas and some other things. The web worker must return an array of this objects. The problem is that when I call the postMessage function with this object, I get an this error: Uncaught Error: DATA_CLONE_ERR: DOM Exception 25 I get this both sending the object to the worker and the other way around. I think the error is because

Web Workers and Canvas

给你一囗甜甜゛ 提交于 2019-11-26 09:19:39
问题 Are web workers allowed to access a canvas object? 回答1: Small update, as the question is now more than half a year old: In Chrome/Chromium 6 you can now send a canvas' ImageData object to a web worker, let the web worker make changes to the object and then write it back to the canvas using putImageData(..) . Google's Chromabrush does it this way, the source-code can be found here: Main thread Web worker Update: The latest development snapshots of Opera (10.70) and Firefox (4.0b1) also support

Web workers without a separate Javascript file?

拟墨画扇 提交于 2019-11-26 09:17:28
As far as I can tell, web workers need to be written in a separate JavaScript file, and called like this: new Worker('longrunning.js') I'm using the closure compiler to combine and minify all my JavaScript source code, and I'd rather not have to have my workers in separate files for distribution. Is there some way to do this? new Worker(function() { //Long-running work here }); Given that first-class functions are so crucial to JavaScript, why does the standard way to do background work have to load a whole 'nother JavaScript file from the server? vsync http://www.html5rocks.com/en/tutorials

Making WebWorkers a safe environment

我只是一个虾纸丫 提交于 2019-11-26 07:24:26
问题 In a quest to have an interface capable of running arbitrary javascript code inside the browser, without having a security hole the size of a typical yo-mama joke, Esailija proposed using Web Workers. They run in a semi-sandboxed environment (no DOM access and already inside the browser) and can be killed so the user can\'t put them in an infinite loop. Here\'s the example he brought up: http://tuohiniemi.fi/~runeli/petka/workertest.html (open your console) jsfiddle (Google chrome only) Now,

Chrome can't load web worker

依然范特西╮ 提交于 2019-11-26 07:19:16
问题 I am working on a project that uses a web worker. In my head section I have this code: var worker = new Worker(\"worker.js\"); // More code This works fine in Safari, but Chrome reports the following error: Uncaught SecurityError: Failed to create a worker: script at \'(path)/worker.js\' cannot be accessed from origin \'null\'. Why does this work perfectly in Safari but not Chrome? How do I fix this? Thank you. 回答1: Chrome doesn't let you load web workers when running scripts from a local

How to create a Web Worker from a string

邮差的信 提交于 2019-11-26 04:59:10
问题 How can I use create a Web worker from a string (which is supplied via a POST request)? One way I can think of, but I\'m not sure how to implement it, is by creating a data-URI from the server response, and passing that to the Worker constructor, but I\'ve heard that some browsers don\'t allow this, because of the same origin policy. MDN states the uncertainty about the origin policy around data URI\'s: Note: The URI passed as parameter of the Worker constructor must obey the same-origin

Which would be better for concurrent tasks on node.js? Fibers? Web-workers? or Threads?

Deadly 提交于 2019-11-26 04:56:48
问题 I stumbled over node.js sometime ago and like it a lot. But soon I found out that it lacked badly the ability to perform CPU-intensive tasks. So, I started googling and got these answers to solve the problem: Fibers, Webworkers and Threads (thread-a-gogo). Now which one to use is a confusion and one of them definitely needs to be used - afterall what\'s the purpose of having a server which is just good at IO and nothing else? Suggestions needed! UPDATE: I was thinking of a way off-late; just

Web workers without a separate Javascript file?

我们两清 提交于 2019-11-26 02:04:42
问题 As far as I can tell, web workers need to be written in a separate JavaScript file, and called like this: new Worker(\'longrunning.js\') I\'m using the closure compiler to combine and minify all my JavaScript source code, and I\'d rather not have to have my workers in separate files for distribution. Is there some way to do this? new Worker(function() { //Long-running work here }); Given that first-class functions are so crucial to JavaScript, why does the standard way to do background work