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] Add optional ImageData argument to getImageData #4748

Closed
wants to merge 1 commit into from

Conversation

dsanders11
Copy link

@dsanders11 dsanders11 commented Jul 1, 2019

Optional argument, if provided, will be used instead of creating a new ImageData object. This avoids creating a large amount of unnecessary garbage when getting image data from a canvas at a high frequency.

See #3802 for original discussion and my comment #3802 (comment) for more in-depth discussion on why this change is beneficial. The TL;DR is simple: using getImageData to process video data being written to a canvas creates a large amount of garbage when trying to process at any reasonable FPS, and garbage collection does not handle this well, instead lots of CPU is burned and memory usage is highly variable. Reusing a single ImageData for frame data eliminates this issue. It's an easy performance win.

Creating a PR for this for higher visibility, because the issue wasn't going anywhere and wasn't going to be getting a response.

  • At least two implementers are interested (and none opposed):
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chrome: …
    • Firefox: …
    • Safari: …

(See WHATWG Working Mode: Changes for more details.)


/canvas.html ( diff )

Optional argument, if provided, will be used instead of creating a new ImageData object. This avoids creating a large amount of unnecessary garbage when getting image data from a canvas at a high frequency.
@dsanders11 dsanders11 changed the title Add optional ImageData argument to getImageData [WIP] Add optional ImageData argument to getImageData Jul 1, 2019
@domenic domenic added topic: canvas needs implementer interest Moving the issue forward requires implementers to express interest labels Jul 2, 2019
@dsanders11
Copy link
Author

Closing in favor of #4785.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs implementer interest Moving the issue forward requires implementers to express interest topic: canvas
Development

Successfully merging this pull request may close these issues.

None yet

2 participants