# Canvas2D: Multiple readback operations

**URL:** <https://discourse.processing.org/t/canvas2d-multiple-readback-operations/39804>\
**Category:** Beginners\
**Created:** [November 20, 2022, 6:25pm UTC](https://discourse.processing.org/t/canvas2d-multiple-readback-operations/39804 "2022-11-20T18:25:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattobject](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@mattobject](https://discourse.processing.org/u/mattobject)\
**Post date:** [November 20, 2022, 6:25pm UTC](https://discourse.processing.org/t/canvas2d-multiple-readback-operations/39804/1 "2022-11-20T18:25:26Z")

</div>

I’ve noticed in the past few months a new warning in the console when a sketch loads image files: **p5.js:80807 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: [HTML Standard](https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently)**

And I wonder if anyone has found or knows a way to set the **willReadFrequently** attribute on the canvas to true?

THANK!

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [November 20, 2022, 10:06pm UTC](https://discourse.processing.org/t/canvas2d-multiple-readback-operations/39804/2 "2022-11-20T22:06:18Z")

</div>

Hi @mattobject,

This is maybe of interest for you…

> <https://github.com/processing/p5.js/issues/5840>
>
> \### Increasing Access
> 
> Making canvas operations more performant would make ske…tches run better on mobile and lower-end hardware.
> 
> \### Most appropriate sub-area of p5.js?
> 
> \- \[\] Accessibility
> \- \[\] Color
> \- \[X\] Core/Environment/Rendering
> \- \[\] Data
> \- \[\] DOM
> \- \[\] Events
> \- \[\] Image
> \- \[\] IO
> \- \[\] Math
> \- \[\] Typography
> \- \[\] Utilities
> \- \[\] WebGL
> \- \[\] Build Process
> \- \[\] Unit Testing
> \- \[\] Internalization
> \- \[\] Friendly Errors
> \- \[\] Other (specify if possible)
> 
> \### Feature enhancement details
> 
> When using \`tint()\` I get a canvas2d warning that says:
> 
> \`Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true.\`
> 
> The \[canvas specs say\](https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently) that passing \`{ willReadFrequently: true }\` to \`getContext()\` will disable hardware acceleration on the canvas, making it perform better with \`getImageData()\`. This looks like a recent addition for Chrome at least? \[It's discussed in a blog post here\](https://developer.chrome.com/blog/canvas2d/#will-read-frequently)
> 
> Would this be something that would be helpful to add wherever \`getImageData()\` is called?
> 
> Below is an example that triggers this warning. In this case it's the \`Filters.\_toPixels()\` call in \`p5.Renderer2D.prototype.\_getTintedImageCanvas\`.
> 
> \`\`\`
> let pg0;
> 
> function setup() {
> createCanvas(400, 400);
>   
> pg0 = createGraphics(400,400);
> 
> }
> 
> function draw() {
> background(220);
>   
> tint(255, 100);
> image(pg0,0,0);
> }
> \`\`\`

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![mattobject](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@mattobject](https://discourse.processing.org/u/mattobject)\
**Post date:** [November 20, 2022, 10:53pm UTC](https://discourse.processing.org/t/canvas2d-multiple-readback-operations/39804/3 "2022-11-20T22:53:20Z")

</div>

Hi mnse

Thanks for the link. Looks like I can ignore for now.
