niklasvh / html2canvas

Screenshots with JavaScript
https://html2canvas.hertzen.com/
MIT License
30.48k stars 4.8k forks source link

Fix for #2986 #3084

Open vishwas-r opened 1 year ago

vishwas-r commented 1 year ago

Fix for "Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true" warning in chrome browser

Summary

This PR fixes/implements the following bugs/features

Closing issues Fixes #2986

Sharcoux commented 1 year ago

Can be tested in @cantoo/html2canvas

maurice-ellis commented 8 months ago

@vishwas-r , believe this willReadFrequently has to be set on the line above because the context is used below on line 22.

const ctx = canvas.getContext('2d');
const clonedCtx = clonedCanvas.getContext('2d', { willReadFrequently: true });
clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);

@Sharcoux , not sure if you can update yours, I would like to use it.