Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing frame on initial load #1

Closed
PaulB-H opened this issue Apr 27, 2023 · 15 comments
Closed

Missing frame on initial load #1

PaulB-H opened this issue Apr 27, 2023 · 15 comments
Assignees

Comments

@PaulB-H
Copy link
Owner

PaulB-H commented Apr 27, 2023

Sometimes, only on live server, even though the "tiles" spritesheet loads, we get a texture error.

Mashing reload / ctrl+shift r (to force reload without cache) can sometimes reproduce it.

Only happens on live server, cannot duplicate on development

image

@PaulB-H PaulB-H self-assigned this Apr 27, 2023
@PaulB-H
Copy link
Owner Author

PaulB-H commented Apr 28, 2023

When logging the total number of frames for the sprite sheet, it can occasionally only list 1.

The issue was NOT resolved by re-running the preload scene, currently doing a full page reload when this is detected, not optimal but at least detectable now...

image

@PaulB-H
Copy link
Owner Author

PaulB-H commented Apr 28, 2023

Implemented page-reload workaround with commit 9f711ed

Leaving the issue open, hoping to find a proper fix...

PaulB-H added a commit that referenced this issue May 1, 2023
... sadly does not resolve issue #1 ..... =(
@PaulB-H
Copy link
Owner Author

PaulB-H commented May 2, 2023

Seems to be resolved by bypassing Cloudflare's cache by putting the site into development mode... Confused to why this resolved the issue, since it appears the image appears to have been sent/received OKAY even with Cloudflare's cache enabled...

image

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 2, 2023

Created page rule on cloudflare to bypass cache for paulbh.com/breakout, since development mode only lasts for 3 hours.

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 2, 2023

Not resolved, have been able to replicate this since enabling development mode and or the page rule... 😩

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 2, 2023

Disabling cache in NGINX not resolved

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 3, 2023

Not resolved by pausing Cloudflare on site all-together...

image

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 4, 2023

Updated PM2 on VPS - Not resolved

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 4, 2023

After more testing tonight, disabling Cloudflare on the site all-together does in fact seem to resolve the issue.

Not wanting to do this, I enabled "Optimized Delivery" and "Rocket Loader™" from Cloudflare under "Speed → Optimizations", and it seems to happen significantly less.... but maybe not totally resolved.

Edit: after more testing, issue still rarely reproduceable. Disabling CloudFlare may have helped because the assets were served just a bit faster than with it, avoiding the bug mentioned lower down 👇

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 4, 2023

Still definitely able to replicate in Firefox at least... Texture asserts true, image loads, but treated as having one frame...

Will try loading normal map as image / removing normal map tomorrow...

image

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 4, 2023

Have not been able to replicate on mobile Firefox OR Chrome since changes, so that's nice at least...

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 5, 2023

Issue in phaser with loading normal map with spritesheets.

After speaking to others in Discord, it turned into:

phaserjs/phaser#6491

@PaulB-H
Copy link
Owner Author

PaulB-H commented May 6, 2023

Work-around from samme:

this.load.image('face-normalMap', 'assets/sprites/metalface78x92-n.png');
this.load.spritesheet('face', 'assets/sprites/metalface78x92.png', { frameWidth: 78, frameHeight: 92 });
this.load.once('complete', function (loader) {
    const sheet = loader.textureManager.get('face');
    const normalMap = loader.textureManager.get('face-normalMap');

    sheet.setDataSource(normalMap.getSourceImage());
});

PaulB-H added a commit that referenced this issue Jul 24, 2023
Load normal & spritesheet separately, then add the normal as a dataSource to the spritesheet
@PaulB-H
Copy link
Owner Author

PaulB-H commented Aug 1, 2023

Work-around from samme:

this.load.image('face-normalMap', 'assets/sprites/metalface78x92-n.png');
this.load.spritesheet('face', 'assets/sprites/metalface78x92.png', { frameWidth: 78, frameHeight: 92 });
this.load.once('complete', function (loader) {
    const sheet = loader.textureManager.get('face');
    const normalMap = loader.textureManager.get('face-normalMap');

    sheet.setDataSource(normalMap.getSourceImage());
});

So this worked "mostly", except would occasionally result in the normal map being loaded as the image for the spritesheet... Resulting in a psychedelic adventure:

image

This was seemingly resolved by updating from Phaser 3.55 to Phaser 3.6

HOWEVER

The issue with missing frames still exists when trying to load the normal map the "new" way, even on 3.6:

this.load.spritesheet({
  key: SHEETS.Tiles,
  url: "assets/main-tileset/breakout-extruded.png",
  normalMap: "assets/main-tileset/breakout-extruded_n.png",
  frameConfig: {
    frameWidth: 16,
    frameHeight: 16,
    spacing: 2,
    margin: 1,
    startFrame: 0,
    endFrame: 99,
  },
});

So issue phaserjs/phaser#6491 in Phaser still stands, but I am closing this as my workarounds are working.

edit.
I thought I was still on 3.55, but checking commits it seems I updated to phaser 3.6 in commit fa691ca, did I manually update package.json and not actually update phaser? Regardless, even after this change (or reinstall) the issue trying to load normal map with spritesheet still exists.

@PaulB-H PaulB-H closed this as completed Aug 1, 2023
@PaulB-H
Copy link
Owner Author

PaulB-H commented Dec 3, 2023

This has been fixed in Phaser 3.70.0

phaserjs/phaser#6665

phaserjs/phaser#6491 (comment)

We can go back to the modern way of loading normal maps with spritesheets:

this.load.spritesheet({
   key: SHEETS.Tiles,
   url: "assets/main-tileset/breakout-extruded.png",
   normalMap: "assets/main-tileset/breakout-extruded_n.png",
   frameConfig: {
      frameWidth: 16,
      frameHeight: 16,
      ...
   },
});

PaulB-H added a commit that referenced this issue Dec 5, 2023
We can now load spritesheets and their associated normal maps together call thanks to fix in phaser 3.7.0
PaulB-H added a commit that referenced this issue Dec 5, 2023
We can load spritesheets and their normal maps at once again thanks to fix in phaser 3.70.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant