Skip to content

Commit 0362ce6

Browse files
committed
perf(virtual-bg): only resize output canvas when dimensions change
- Assigning width/height clears the canvas and reallocates the buffer even if values are unchanged Assisted-by: ClaudeCode:claude-fable-5 Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent 009dc8c commit 0362ce6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/utils/media/effects/virtual-background/VideoStreamBackgroundEffect.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,12 @@ export default class VideoStreamBackgroundEffect {
457457
return
458458
}
459459

460-
this._outputCanvasElement.width = width
461-
this._outputCanvasElement.height = height
460+
// Assigning canvas dimensions clears the canvas and reallocates its
461+
// buffer even if values are unchanged, so only set them on change.
462+
if (this._outputCanvasElement.width !== width || this._outputCanvasElement.height !== height) {
463+
this._outputCanvasElement.width = width
464+
this._outputCanvasElement.height = height
465+
}
462466

463467
if (this._useWebGL) {
464468
if (!this._glFx) {

0 commit comments

Comments
 (0)