When resize canvas , there is a white background flickering
See original GitHub issueI resize canvas with a simple standalone function , like this :
function resizeCanvas(width, height) {
game.canvas.width = width;
game.canvas.height = height;
game.canvas.style.width = width / game.resolution + 'px';
game.canvas.style.height = height / game.resolution + 'px';
}
And when game bootup , I do something like this :
game.renderer = new PIXI.WebGLRenderer(
game.canvas.width,
game.canvas.height,
{
view: game.canvas,
backgroundColor: 0x000000,
}
);
// recompute viewport size & canvas size with browser window size
game.scaler.update();
// resize renderer with new size.
game.renderer.resize(game.viewportWidth, game.viewportHeight);
the test case is very simple : draw a small png image.
Browser: Chrome 55 for macOS 10.12
Safari is OK.
I know maybe this is a issues of Chrome , but I hop there is a hack way for fix it.
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Flickering during resizing of HTML5 canvas
When you set canvas.width or canvas.height it clears the canvas, combined with the redrawing this causes the flicker you see.
Read more >When resize canvas , there is a white background flickering
I resize canvas with a simple standalone function , like this : function resizeCanvas(width, height) { game.canvas.width = width; game.canvas.height ...
Read more >Help! Photoshop Ver 21.1.0 has Annoying Flickering...
Hi there,. We are sorry about the experience with Photoshop due to the flickering issue. Please go to the Preferences for Photoshop, then...
Read more >How can I minimize flickering when drawing a control
Double buffering is a technique that attempts to reduce flicker by doing all the drawing operations on an off-screen canvas, ...
Read more >Photoshop 2020 - Fix Flickering Screen - YouTube
Photoshop 2020 - Fix Flickering ScreenIf you find your screen flashes black and white when you open a file in the new Photoshop...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Aw, thanks! @mickdekkers that’s awesome, calling render immediately makes it work with the
ResizeObservercallbacks.@inukshuk in my case the solution turned out to be really simple: just call
renderafter resizing.This fixed the flickering issue for me. Keep in mind that if you have animations running, it will just display the last frame until your next update loop and this might give a “freezing” effect. If you want to keep it running smoothly, you’ll want to call your update function before calling render.