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

LoaderPlugin XHR timeout is not handled #6472

Closed
343dev opened this issue Apr 14, 2023 · 1 comment
Closed

LoaderPlugin XHR timeout is not handled #6472

343dev opened this issue Apr 14, 2023 · 1 comment

Comments

@343dev
Copy link

343dev commented Apr 14, 2023

Version

  • Phaser Version: 3.55.2
  • Operating system: macOS
  • Browser: any

Description

Hey there!

I’ve noticed that LoaderPlugin doesn’t handle errors related to XHR timeout. If one of the requests times out in the preload state, the scene never transitions from the preload state to the create state.

How should we handle such errors in this case?

Example Test Code

Demo: https://codepen.io/343dev/pen/VwEaYLQ

class GameScene extends Phaser.Scene {
  constructor() {
    super('Game');
  }

  preload() {
    this.load.image('test', 'https://slowfil.es/file?type=png&delay=6000', { timeout: 1000, responseType: 'blob' });
  }

  create() {
    this.add.text(0,0,'loaded', { color: 'red' });
  }
}

const config = {
  transparent: true,
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  scene: [GameScene],
};

const game = new Phaser.Game(config);

Additional Information

  1. LoaderPlugin passes the mentioned parameters (responseType and timeout) to File: loader/filetypes/ImageFile.js#L70.
  2. File then uses these parameters to initiate an XHRLoader internally: loader/File.js#L297.
  3. And XHRLoader opens a connection with the specified timeout: loader/XHRLoader.js#L31.
  4. If a timeout occurs, the timeout event is triggered in XHR: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout_event.
  5. However, there seems to be no handling of this event in XHRLoader: loader/XHRLoader.js#L63-L65.
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants