web-worker

iOS Javascript Workers High CPU after terminate()

泪湿孤枕 提交于 2020-01-11 13:55:31
问题 I have a complex javascript function which could take 1 second, or many minutes sending an answer. So I created a Worker which is working, I'm calling this function from my UIWebView in Swift (stringByEvaluatingJavaScriptFromString). I'm waiting only 5 seconds (timeout created in the same Javascript), after that I terminate the worker (job.terminate()), and I start a different one with other parameters (simplier), which takes only 1 second in show the answer. The thing is, the first worker

How to allow Web Workers to receive new data while it still performing computation?

妖精的绣舞 提交于 2020-01-11 10:44:29
问题 I want to sort an array, using Web Workers. But this array might receive new values over time, while the worker is still performing the sort function. So my question is, how can I "stop" the sorting computation on the worker after receiving the new item, so it can perform the sort on the array with that item, while still keeping the sorting that was already made? Example: let worker = new Worker('worker.js'); let list = [10,1,5,2,14,3]; worker.postMessage({ list }); setInterval(() => worker

How to allow Web Workers to receive new data while it still performing computation?

人走茶凉 提交于 2020-01-11 10:44:07
问题 I want to sort an array, using Web Workers. But this array might receive new values over time, while the worker is still performing the sort function. So my question is, how can I "stop" the sorting computation on the worker after receiving the new item, so it can perform the sort on the array with that item, while still keeping the sorting that was already made? Example: let worker = new Worker('worker.js'); let list = [10,1,5,2,14,3]; worker.postMessage({ list }); setInterval(() => worker

Improve program performance [closed]

房东的猫 提交于 2020-01-07 08:43:59
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have a javascript program which executes operations with my JSON data (200Mega) This programm search an occurences in my datas by regxp var myDatas = [ { "id" : "0000000001", "title" :"Data1", "info": { "info1": "data data data", "info2": "infoinfoiinfoinfo", "info3": "info333333333", "miscellaneous": "",

html5 chunk and webworker does not upload anything

纵饮孤独 提交于 2020-01-06 08:38:29
问题 I was working with html5 slice and webworker but when it goes to uploadFile function, nothing happened. nothing being upload <html> <head> <title>Upload Files using XMLHttpRequest</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> </head> <body> <form id="fileuploader" enctype="multipart/form-data" method="post" action="upload.php"> <label for="fileToUpload">Select Files to Upload</label><br /> <input type="file" name="fileToUpload[]" multiple="" id=

reading an object URL produced in a worker with IE

对着背影说爱祢 提交于 2020-01-05 15:36:24
问题 I have a webworker that is producing a CSV for downloading, and to conserve memory I only have it return the URL it produces from teh blob.. My worker code looks something like:: var blob = new Blob([ResultOfSomeWork()],{type:'text/csv'}); URL.createObjectURL(blob); self.postMessage({url:blob.url}); My goal is to just be able to download it in firefox and chrome this is very easy as I can just set up an invisible <a> and have it be clicked to download it. For IE10 I want to use msSaveBlob but

angular2 work in background thread with custom serializable objects

╄→гoц情女王★ 提交于 2020-01-05 04:50:33
问题 How could I achieve this: I have some potentially long computation (eg. huge JSON to parse as http resp.) and want to do it in a non-blocking way. I tried to adopt multithread.js lib to do the background work using web worker. This lib requires JSON serializable objects to pass to the execution function which is not aware of closures, DOM or any other globals. eg. MT.process(longRunningJob, doneCallback)(jsonSerializableArgForBGJob) . But this lib is rather old (3 years ago last commit). Are

Is it possible to save a file directly from a web worker?

♀尐吖头ヾ 提交于 2020-01-03 12:36:07
问题 I have an entirely browser-based (i.e. no backend) application which analyzes XML data in files which average about 250MB each. The actual parsing and analysis happens in a web worker, which is fed data in 64KB chunks by a FileReader instance, and this is all quite performant. I have a request from the client to expand this application so that it can generate a .zip file containing the original input file and the results of the analysis, and allow the user to save that file to her local

Is it possible to save a file directly from a web worker?

白昼怎懂夜的黑 提交于 2020-01-03 12:34:56
问题 I have an entirely browser-based (i.e. no backend) application which analyzes XML data in files which average about 250MB each. The actual parsing and analysis happens in a web worker, which is fed data in 64KB chunks by a FileReader instance, and this is all quite performant. I have a request from the client to expand this application so that it can generate a .zip file containing the original input file and the results of the analysis, and allow the user to save that file to her local

are messages sent via worker.postMessage() queued?

Deadly 提交于 2020-01-03 08:40:21
问题 After creating a worker, I can send messages to it via postMessage . For example: var worker = new Worker('helper.js'); worker.postMessage({...}); Inside helper.js, the worker needs to add a listener using onmessage = function (event) { ... }; My question is, if one or more messages are sent to the worker while the worker script is still loading, is it guaranteed that the messages get queued and delivered eventually, or is it possible that they may get lost? 回答1: The spec at http://www.w3.org