From 66079ede285f91e8face74df022adbcb812c4be3 Mon Sep 17 00:00:00 2001 From: Eris Lund <38136789+0x5066@users.noreply.github.com> Date: Mon, 23 Dec 2024 20:33:36 +0100 Subject: [PATCH] Call ``painter.prepare()`` only when doublesize is engaged/disengaged --- packages/webamp/js/components/Vis.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/webamp/js/components/Vis.tsx b/packages/webamp/js/components/Vis.tsx index 13fc0bff8..c1c62d489 100644 --- a/packages/webamp/js/components/Vis.tsx +++ b/packages/webamp/js/components/Vis.tsx @@ -136,10 +136,12 @@ export default function Vis({ analyser }: Props) { isMWOpen, ]); + // reacts to changes in doublesize mode useEffect(() => { if (canvas && painter) { const canvasCtx = canvas.getContext("2d"); if (canvasCtx) { + painter.prepare(); // wipes the canvas clean if playback is paused and doubled is changing if (audioStatus === MEDIA_STATUS.PAUSED) { canvasCtx.clearRect(0, 0, canvas.width, canvas.height); @@ -163,7 +165,6 @@ export default function Vis({ analyser }: Props) { const loop = () => { canvasCtx.drawImage(bgCanvas, 0, 0); - painter.prepare(); painter.paintFrame(); animationRequest = window.requestAnimationFrame(loop); };