admin管理员组

文章数量:1323335

im trying to spawn a web worker inside a web worker but im getting this error:

mainWorker.js:92 Uncaught ReferenceError: Worker is not defined

using this code:

var worker = new Worker('subWorker.js');
worker.postMessage(......);

is this possible in some way??

im trying to spawn a web worker inside a web worker but im getting this error:

mainWorker.js:92 Uncaught ReferenceError: Worker is not defined

using this code:

var worker = new Worker('subWorker.js');
worker.postMessage(......);

is this possible in some way??

Share Improve this question asked Sep 23, 2016 at 16:32 Vanojx1Vanojx1 5,5842 gold badges24 silver badges37 bronze badges 4
  • 1 You could message the main thread to spawn another Worker thread. – Sebastian Simon Commented Sep 23, 2016 at 16:35
  • 1 oh I didn't think about it.... ill try – Vanojx1 Commented Sep 23, 2016 at 16:38
  • 2 It should actually work, but it doesn’t work in Chrome and Safari yet. You could try the “detour” over the main thread as a work-around. – Sebastian Simon Commented Sep 25, 2016 at 14:37
  • 1 @Vanojx1 It works now. – DavidsKanal Commented Jul 10, 2019 at 17:41
Add a ment  | 

1 Answer 1

Reset to default 8

For anyone who stumbles here, nested workers now have some support in Chrome at least: https://www.chromestatus./feature/6080438103703552:

Dedicated workers can create nested workers, but shared workers and service workers cannot.

Creating a nested dedicated worker from a shared worker is not yet supported.

Nested shared workers are also in the spec, but there is no plan to support them at this time.

本文标签: javascriptWeb worker inside Web worker possibleStack Overflow