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

[WIP] Support worker contexts capturing #298

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

junyuecao
Copy link

@junyuecao junyuecao commented Jan 11, 2024

This PR tries to support webgl contexts in worker as this issue described: #149

I added a headless spector(no ui) as the BaseSpector and a Spector is the same as the original one.
For worker capturing, the developer should create a BaseSpector in the worker and use a RemoteSpector to communication with the worker in the main thread.

Usage is like:

  1. import the BaseSpector in the worker and wait for canvas, once the rendering worker created, set the window.__SPECTOR_worker = worker in main thread. And send the element id to the worker OffscreenCanvas.__SPECTOR_id=[canvasElement.id] (we use the id to identify target context)
  2. import the RemoteSpector in main thread
  3. Use RemoteSpector.captureCanvas(canvas) as normal

The demo shows how to capture in a worker with a url param worker=1

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

Successfully merging this pull request may close these issues.

None yet

1 participant