web-worker

How to debug shared webworkers?

怎甘沉沦 提交于 2020-07-08 04:07:40
问题 I am using shared webworkers, I am not getting the errors from the worker. The worker error handler not returning any errors!. How can I Debug shared webworkers. var worker = new SharedWorker('Vult_worker.js'); worker.port.start(); worker.port.onerror = function(e) { consloe.log('ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message); } worker.port.onmessage = function(e) { console.log(e.data); }; worker.port.postmessage(); worker Code: onconnect = function(e) { var self = e.ports[0];

How to debug shared webworkers?

青春壹個敷衍的年華 提交于 2020-07-08 04:07:29
问题 I am using shared webworkers, I am not getting the errors from the worker. The worker error handler not returning any errors!. How can I Debug shared webworkers. var worker = new SharedWorker('Vult_worker.js'); worker.port.start(); worker.port.onerror = function(e) { consloe.log('ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message); } worker.port.onmessage = function(e) { console.log(e.data); }; worker.port.postmessage(); worker Code: onconnect = function(e) { var self = e.ports[0];

Does Web Worker throttles setTimeout() / setInteval()?

拟墨画扇 提交于 2020-06-29 04:28:29
问题 I have a script on foreground tab that starts (dedicated) web worker. Now I see that setTimeout(xxx, 100) in that web worker is limited to be triggered not more often than once per second instead of 10 times per second as required. I've googled such a limitation for inactive tabs but are there any docs that say the same about Web Workers? I've checked this in Chrome and Firefox. 回答1: There is no real specs about that throttling behavior, even though they do allow it: Optionally, wait a

Does Web Worker throttles setTimeout() / setInteval()?

孤街醉人 提交于 2020-06-29 04:28:07
问题 I have a script on foreground tab that starts (dedicated) web worker. Now I see that setTimeout(xxx, 100) in that web worker is limited to be triggered not more often than once per second instead of 10 times per second as required. I've googled such a limitation for inactive tabs but are there any docs that say the same about Web Workers? I've checked this in Chrome and Firefox. 回答1: There is no real specs about that throttling behavior, even though they do allow it: Optionally, wait a

Javascript Workers - why is the worker message treated so lately and can I do something against it?

可紊 提交于 2020-06-28 09:16:17
问题 I have a Worker that shares a SharedArrayBuffer with the "main thread". To work correctly, I have to make sure that the worker has access to the SAB before the main thread accesses to it. (EDIT: The code creating the worker has to be in a seperate function (EDIT2: which returns an array pointing to the SAB).) (Maybe, already this is not possible, you'll tell me). The initial code looks like this: function init() { var code = `onmessage = function(event) { console.log('starting'); var buffer

Why are cross origin workers blocked and why is the workaround ok?

你离开我真会死。 提交于 2020-06-23 03:53:11
问题 Recently I worked on a library that supports using workers for some heavy lifting. I found out that, at least on most online code editors (snippets/jsfiddle/codepen/glitch) I can't seem to load a worker from another domain. I get a security error (or in firefox silent failure) function startWorker(url) { try { const worker = new Worker(url); console.log('started worker'); worker.onmessage = e => log('black', e.data); worker.postMessage('Hi from page'); } catch (e) { console.error('could not

Why are cross origin workers blocked and why is the workaround ok?

雨燕双飞 提交于 2020-06-23 03:52:09
问题 Recently I worked on a library that supports using workers for some heavy lifting. I found out that, at least on most online code editors (snippets/jsfiddle/codepen/glitch) I can't seem to load a worker from another domain. I get a security error (or in firefox silent failure) function startWorker(url) { try { const worker = new Worker(url); console.log('started worker'); worker.onmessage = e => log('black', e.data); worker.postMessage('Hi from page'); } catch (e) { console.error('could not

Rendering Canvas context in Worker thread for smooth playback

限于喜欢 提交于 2020-06-17 05:53:36
问题 I have two videos here showing the rendering of a decoded MJPEG video sequence this one only rending one video: Video description: Left (Source), Middle (Canvas copy of stream), Right (Decoded from network). At this point the video is smooth both from source to network and back (websocket). And at least up to 5 video decoded and rendered is reasonably smooth. However if I render like 20 videos things start to lag: My question is what is the best algorithm that will allow to render (or in

Webworker OffscreenCanvas draw regular image

只谈情不闲聊 提交于 2020-05-28 04:52:56
问题 Webworkers can fetch regular images through XMLHttpRequest , right? How can the workers then draw these images to OffscreenCanvas? Probably want to use XMLHttp.responseType = 'blob' ? Another way would be to set the src of an image element and then transfer the element to worker, but my workers always reject such images. Thanks 回答1: The ImageBitmap API is here for this purpose (among others). Note: this demo will currently run only on Chrome... const offcanvas = canvas

Is there a faster way to yield to Javascript event loop than setTimeout(0)?

流过昼夜 提交于 2020-05-25 08:26:51
问题 I am trying to write a web worker that performs an interruptible computation. The only way to do that (other than Worker.terminate() ) that I know is to periodically yield to the message loop so it can check if there are any new messages. For example this web worker calculates the sum of the integers from 0 to data , but if you send it a new message while the calculation is in progress it will cancel the calculation and start a new one. let currentTask = { cancelled: false, } onmessage =