1j01 / jspaint

🎨 Classic MS Paint, REVIVED + ✨Extras
https://jspaint.app/about
MIT License
7.16k stars 562 forks source link

Canvases for palette colors and tool options become blank #341

Open 1j01 opened 1 month ago

1j01 commented 1 month ago

On Chrome Version 125.0.6422.60 (Official Build) (64-bit) on Windows 11, the tool options (brushes etc.) and color palette canvases are disappearing. This seems to happen when the window is minimized.

Weirdly, the image data is still there, and can be shown again with:

for (const canvas of document.querySelectorAll("canvas")) {
    const ctx = canvas.getContext("2d");
    ctx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
}

This is in contrast to the browser clearing the canvas and image data entirely as in https://github.com/1j01/jspaint/issues/24 although it may be related. I suspect both as being buggy performance optimizations in Chrome. In that case I can detect it by the image data being zeroed out, but not in this bug.

Also note how the main canvas is left in tact here:

image

Switching themes fixes it, as it causes things to re-render.