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

Optimize image rasterization with willReadFrequently hints #12397

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

mourner
Copy link
Member

@mourner mourner commented Nov 18, 2022

When using getImageData (e.g. for DEM tiles), we reuse the same canvas object and then read it repeatedly for different images. Recent versions of Chrome started throwing this warning in the console:

Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently

This PR adds willReadFrequently hints in two places where it's needed to make sure that getting data out of loaded images is as fast as possible.

Launch Checklist

  • briefly describe the changes in this PR
  • post benchmark scores
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Improve performance of loading terrain data</changelog>

@mourner mourner added the performance ⚡ Speed, stability, CPU usage, memory usage, or power usage label Nov 18, 2022
@mourner mourner requested a review from a team as a code owner November 18, 2022 11:42
Copy link
Contributor

@stepankuzmin stepankuzmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mourner mourner merged commit b107bd7 into main Nov 18, 2022
@mourner mourner deleted the optimize-rasterization branch November 18, 2022 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡ Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants