twilio / twilio-video-processors.js

Twilio Video Processors is a collection of video processing tools which can be used with Twilio Video JavaScript SDK to apply transformations and filters to a video track.
Other
33 stars 21 forks source link

Fix the warning: "Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true" #55

Open pzubar opened 1 year ago

pzubar commented 1 year ago

This is not actually a bug, but fixing the warning would be useful (and may optimize the canvas for readback operations)

Code to reproduce the issue:

let [{ VirtualBackgroundProcessor }, image] = await Promise.all([
  import('@twilio/video-processors'),
  loadImage(src),
]);
let virtualBackgroundProcessor = new VirtualBackgroundProcessor({
  ...DEFAULT_VIRTUAL_PROCESSOR_OPTIONS,
  backgroundImage: image,
});

videoTrack.addProcessor(virtualBackgroundProcessor);

Expected behavior:

No warning is logged to console.

Actual behavior:

Warning: BackgroundProcessor.js:21 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 (caused by BackgroundProcessor.js:21) is logged to the console.

Software versions: