-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for SharedWorker #458
base: master
Are you sure you want to change the base?
Conversation
Have another commit coming up. It almost works now. I can't seem to get the shared worker to run at all in the puppeteer tests but it maybe kinda does in the webpack tests. The only thing missing now is the SharedWorker AbstractedWorkerAPI and handling expose. It'll go roughly like this: If it's a SharedWorker, only register connect and re-run most of expose for every client (master) connecting. Or something close to it. |
It does prove somewhat difficult due to all the outdated dependencies. @andywer What's the status of threads.js and related dependencies? It feels a little discontinued. :) |
needed to add a context to AbstractedWorkerAPI
This should be the bulk of it. Needed to add a Feedback welcome. It might already work, but it's difficult to test, since I can't get SharedWorker to work at all in the puppeteer tests (it just does nothing). |
Another issue is that it seems to be difficult (if not impossible) to detect if a client closed the port to the SharedWorker. Maybe I'm missing something. I suppose the master could send a disconnect message before closing the port, then the SharedWorker can remove listeners and close the port to the disconnecting master. |
Well, whatever I try, I can't seem to get a SharedWorker to run any code. So I don't think I can finish this. To anyone who may be looking into this in the future: it's pretty much done,iIt might even already work (if SharedWorkers work for you at all), maybe needs to handle master disconnects. |
Alright, figured out why shared workers won't work: Browsers do not like SharedWorker to be subclassed. Not sure how to proceed from here. |
To add to the annoyance, at least chrome does not allow SharedWorkers to have nested Workers. Which kinda was what I needed from this. |
Even not extending and exposing the SharedWorker implementation like it's done for Worker and BlobWorker, I can't get it to work with threads.js. I'm out of ideas. |
The master side of things should be pretty much done - I hope.
Not too happy about the use of
in
as a would-be type guard, but what can you do.... Feedback welcome.Closes #401.