phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Sprites Flash Momentarily after upgrade from 2.4.4 to 2.6.2

Open Ludomancer opened this issue 10 years ago • 13 comments

We are loading bunch of sprites via game.load.image and instantiating them using game.add.sprite. After I've upgraded from 2.4.4 to 2.6.2. Sprites are now flashing for a split second at the top left of the screen than appear at their intended position.

Loading is done with preload method with an initial state that starts the actual game state. Nothing is created during that time. no game.add.sprite is called. All sprites are created in create method of the actual game state using game.add.sprite.

As I've said the issues started to happen after the upgrade. So I'm guessing something has changed that I'm not aware of. I would be glad if you could point me in the right direction to look at. Maybe I've missed an upgrade instruction? Some underlying system has been changed? (I've read the changelogs from 2.4.4 to 2.6.2 but I've either missed or couldn't find any info about the issue that I'm having.)

Thanks.

Ludomancer avatar Oct 16 '16 19:10 Ludomancer

The reason you can't find anything in the change log, is because nothing related to this has changed at all. I had the exact same issue recently. It only manifested on Chrome on Windows, and in the end was caused by a monitor / GPU setting on my PC. I literally spent a week trying to debug it, tracing things out, stepping through the render process, etc. But to no avail, the issue ended up being a clash with FreeSync in my monitor, an NVIDIA GPU and Chrome.

It doesn't mean it's the same issue you've got, but it's highly suspect, as it's the exact same symptoms. You could try downgrading to 2.4.4 again, but first I'd check it out on a range of different browsers and platforms. If everyone see's it happen, then it's likely a Phaser issue. If it only manifests on a select environment, it's a platform issue.

photonstorm avatar Oct 16 '16 21:10 photonstorm

@photonstorm

Hmm interesting. I'm not sure if it is the same issue tho. We've tried this on a couple of different computers all having different GPUs. All Nvidia, All Windows 10, Different monitors; laptops with secondary monitors connected via HDMI. Also the hardware and OS versions was the same on both 2.4.4 and 2.6.2

Also had this both on Firefox and Chrome. The interesting thing is the problem disappeared when we have rolled back to 2.4.4 from 2.6.2. Re-appeared when we re-upgrade to 2.6.2. We've rolled back to 2.4.4 a few days ago due to this issue.

Since the issue only appears if we upgrade to 2.6.2 (disappears when we roll back), I suspect something that has been changed between 2.4.4 and 2.6.2 is causing this. Haven't tried any other versions in between.

edit. Added some extra info

Ludomancer avatar Oct 16 '16 21:10 Ludomancer

Post a link? If it's a genuine issue with something that changed between 2.4.4 and 2.6.2 it should happen for everyone, regardless of platform or device.

It should also happen with the simplest of scenes: just a single sprite, loaded and displayed. Does it?

I'd also expect the GitHub issues and forum to be absolutely full of people reporting the same thing, as it's quite a fundamental problem, no? Yet other than what I personally experienced a few weeks ago, this is the first one. Which still leads me to believe this is more isolated than it may appear on the surface (and consequently, a pain in the arse to track down).

photonstorm avatar Oct 16 '16 22:10 photonstorm

@photonstorm

I can't post a link of the project since it is not yet released and would break my NDA.

I'm not sure why there aren't more issues like this. But since downgrading seems to make the problem disappear and upgrading makes it appear again; my bet is that is has something to with what happened between those versions. Even if it is a platform, gpu or browser related issue, it does not happen with 2.4.4. This dependency issue seems to happen only with 2.6.2, at least in my case.

You are sure right it sounds like a hard one to tackle. Hopefully knowing it might be related to somewhere between those versions would help.

This is the all the information that I've on the issue. If I can spare some free time to reproduce the issue on a simple project I will. But I don't think that's gonna happen any time soon.

Just wanted to report the issue and my findings on it.

Ludomancer avatar Oct 16 '16 23:10 Ludomancer

I can see the same problem. I have the sprites in the group on the stage and I add them with visible false. When I set the visible to true, it flashes first and then it shows correctly. Also the scale in the first frame is incorrect - it shows in original size and then goes to the right size.

I've only seen this recently, because I didn't use Canvas mode before and I don't remember seeing it on WebGL. People are probably not reporting it, because I guess most of them use Auto mode, which usually goes to WebGL. But this one happens in Canvas mode (tested on iPad and Chrome on Windows). By trying older versions I saw that 2.4.8 is still fine and the problem appears in 2.4.9.

I also have a quite complex project that I am not allowed to publish. I'll see if I can make a simple project with the same issue.

TadejZupancic avatar Oct 20 '16 10:10 TadejZupancic

When making the example, I found out that if I remove the game.time.desiredFps setting, the problem goes away. The example creates some hidden sprites and when you click on the game, the sprite near that position becomes visible.

If desiredFps is set to 30, sometimes the sprite is first drawn in original size and then resized.

I believe this is the same problem as Nidre is having because in another place in my game when moving the sprite and setting it visible after the move it shows first on the previous location and then on the new location.

var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create });

function preload() {

    game.load.baseURL = 'http://examples.phaser.io/assets/';
    game.load.crossOrigin = 'anonymous';

    game.load.image('phaser', 'sprites/phaser-dude.png');
}

var playfield;
var sprites = [];
function create() {
    game.time.desiredFps = 30;

    playfield = new Phaser.Group(this.game);
    var s = new Phaser.Sprite(game, 0, 0, 'phaser');
    s.width = 800;
    s.height = 600;
    s.inputEnabled = true;
    s.events.onInputDown.add(onClick, this);
    playfield.addChild(s);
    for (var j=0; j<10; j++)
      for (var i=0; i<18; i++)
      {
          s = new Phaser.Sprite(game, i * 800/18, j * 600/10, 'phaser');
          s.width = 10;
          s.height = 20;
          s.visible = false;
          sprites.push(s);
          playfield.addChild(s);
      }
}

function onClick() {
    var i = Math.floor(game.input.x * 18/800);
    var j = Math.floor(game.input.y * 10/600);
    sprites[j*18 + i].visible = true;
}

TadejZupancic avatar Oct 20 '16 12:10 TadejZupancic

@TadejZupancic You might be right. I'm also using Canvas and 30 fps limit.

Ludomancer avatar Oct 20 '16 19:10 Ludomancer

Also get this issue with the fps limit.

davidbuttar avatar Oct 29 '16 13:10 davidbuttar

Did anyone ever solve this issue? I'm having the same thing happen on Windows in Chrome and Edge, while in both Canvas and WebGL mode.

NeoHoffa avatar Mar 15 '17 21:03 NeoHoffa

I've also been struggling with this issue for the past week or so, and it's scrambling my brain!

I'm primarily developing the game using an Nvidia GPU, Windows 10, freesync monitor and Chrome. And i've just checked and the error doesn't occur when testing on my laptop!

fshenton avatar Mar 17 '17 13:03 fshenton

I wonder if it has anything to do with how it is nested within the display list. Depending on if it's nested within a group, sprite, nested sprites, or directly on the stage. Hmmm.

NeoHoffa avatar Mar 17 '17 13:03 NeoHoffa

I think the flashing results from the fact that the matrices of the sprites are not updated before they are drawn. I had a similar issue while I created a game. I realised that in the first render session, their matrices were still identities.

johnafolayan avatar Mar 27 '17 10:03 johnafolayan

Thank you for taking the time to open this issue. However, official support for Phaser 2 has now ended as we focus on preparing Phaser 3 for beta release. In a bid to keep the project tidy, and avoid confusion, we are closing all v2 related issues.

This does not mean your issue won't be looked-at. In November 2016 the Phaser CE (Community Edition) project began. The aim of Phaser CE was to allow the community to continue v2 development. Since then it has gained significant traction, with many updates and releases.

If you are still interested in having your issue investigated we strongly recommend testing the latest Phaser CE release. And only if the problem persists, opening an issue on the Phaser CE repo.

photonstorm avatar Apr 20 '17 12:04 photonstorm