Skip to content
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

[FEATURE REQUEST] Any plan to make it work with webworker #8

Open
rakeshpolepeddi opened this issue Sep 6, 2021 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@rakeshpolepeddi
Copy link

No description provided.

@rakeshpolepeddi rakeshpolepeddi added the enhancement New feature or request label Sep 6, 2021
@tungs
Copy link
Owner

tungs commented Sep 8, 2021

It's an interesting idea technology wise, though I haven't encountered too many projects that use time-based web workers. Is there a specific site or use case that you have in mind? Without a use case, it's unclear whether a new feature would adequately support it.

Some things to consider to implement this feature:

  • requestAnimationFrame, setTimeout, setInterval, Date, and performance functions are implemented in Web Workers
  • To sync with the parent web page (running at least in a regular web browser, and not a headless one), there'd need to be some coordination. postMessage is the traditional way of doing this (with a message channel to notify the parent when it's finished), but automatically doing this may interfere with existing code. Headless browsers like puppeteer or playwright, may already have ways of evaluating code in a web worker context (puppeteer has WebWorker.evaluate, and playwright has Worker.evaluate)
  • Workers traditionally import code via the importScripts function, which may serve as the way to include timeweb into a worker. For puppeteer and playwright, while there are ways to evaluate code inside web workers, there doesn't seem to be a way to evaluate it before any other code is run (contrasted with page.evaluateOnNewDocument or page.addInitScript which runs code on web pages before any other code is run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants