nimiq / qr-scanner

Lightweight Javascript QR Code Scanner
https://nimiq.github.io/qr-scanner/demo
MIT License
2.35k stars 509 forks source link

Optimization - use willReadFrequently when initializing canvas #236

Open ymoran00 opened 1 year ago

ymoran00 commented 1 year ago

Chrome provides this warning:

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

So adding it may optimize the canvas for some browsers.

getify commented 4 months ago

For reference, here's the line that needs the change:

https://github.com/nimiq/qr-scanner/blob/abcfe1bce2703721408d8ce7ebde94a359998506/src/qr-scanner.ts#L980

that options object needs willReadFrequently: true added to it.