-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
Description
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
- LoaderPlugin passes the mentioned parameters (responseType and timeout) to File: loader/filetypes/ImageFile.js#L70.
- File then uses these parameters to initiate an XHRLoader internally: loader/File.js#L297.
- And XHRLoader opens a connection with the specified timeout: loader/XHRLoader.js#L31.
- If a timeout occurs, the timeout event is triggered in XHR: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout_event.
- However, there seems to be no handling of this event in XHRLoader: loader/XHRLoader.js#L63-L65.