question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When resize canvas , there is a white background flickering

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
inukshukcommented, Sep 11, 2017

Aw, thanks! @mickdekkers that’s awesome, calling render immediately makes it work with the ResizeObserver callbacks.

3reactions
mickdekkerscommented, Sep 11, 2017

@inukshuk in my case the solution turned out to be really simple: just call render after resizing.

app.renderer.resize(width, height)
// Immediately render because resizing clears the canvas
app.render()

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found