diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index cdd48f7d940..ce36a40697b 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -840,12 +840,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { await Promise.allSettled(loadPromises); - // Wait for the assets we queued to load to finish loading, then... + // This must be initiated before we queue loading, otherwise the load could have finished before + // we reach the line of code that adds the listener, causing a deadlock. + const waitOnLoadPromise = new Promise(resolve => globalScene.load.once(Phaser.Loader.Events.COMPLETE, resolve)); + if (!globalScene.load.isLoading()) { globalScene.load.start(); } + + // Wait for the assets we queued to load to finish loading, then... // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#creating_a_promise_around_an_old_callback_api - await new Promise(resolve => globalScene.load.once(Phaser.Loader.Events.COMPLETE, resolve)); + await waitOnLoadPromise; // With the sprites loaded, generate the animation frame information if (this.isPlayer()) {