-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Async readPixels
and process extracted pixels in a worker
#9353
base: v7.x
Are you sure you want to change the base?
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c49558f:
|
There's isn't really any documentation on what kind of |
This is how it currently works: extract.pixels(target); // sync
extract.pixels(target, frame, false); // sync
await extract.pixels(target, frame, true); // async There are other options:
|
Maybe it is time to use Rollup plugins to build the worker code instead of hard-coding them as strings, as mentioned in #8741 (comment). I'll look into it soon. |
…geData) is not supported
Description of change
gl.readPixels
(WebGL 2 only)OffscreenCanvas
is supported).This allows extraction with minimal blocking of the main thread. For example, base64 extraction before changes could block for over 200ms (4096x4096); after the changes it may block for just ~6ms. Firefox might not perform as well though: it doesn't seem to do async
readPixels
right (getBufferSubData
blocks for about the same duration as if non-asyncreadPixels
was used) ifwebgl.out-of-process
is true (which is the default).Pre-Merge Checklist
npm run lint
)npm run test
)