Skip to content

Game postBoot is never getting called in 3.54.0 #5689

@tsafs

Description

@tsafs

Version

  • Phaser Version: 3.54.0
  • Operating system: Ubuntu 20.04
  • Browser: None, HEADLESS

Description

Running phaser-on-nodejs (Headless Phaser running on Node.js) I stumbled upon a problem. I am not able to get into the Phaser.Game postBoot() callback. Back on version 3.24.0 it was working.

I looked into the source code and found out a difference between version 3.24.0 and 3.54.0 within the TextureManager.boot() function.

Excerpt from TextureManager.boot() on version 3.24.0

    /**
     * The Boot Handler called by Phaser.Game when it first starts up.
     *
     * @method Phaser.Textures.TextureManager#boot
     * @private
     * @since 3.0.0
     */
    boot: function ()
    {
        this._pending = 2;

        this.on(Events.LOAD, this.updatePending, this);
        this.on(Events.ERROR, this.updatePending, this);

        this.addBase64('__DEFAULT', this.game.config.defaultImage);
        this.addBase64('__MISSING', this.game.config.missingImage);

        this.game.events.once(GameEvents.DESTROY, this.destroy, this);
    },

Excerpt from TextureManager.boot() on version 3.54.0

   /**
     * The Boot Handler called by Phaser.Game when it first starts up.
     *
     * @method Phaser.Textures.TextureManager#boot
     * @private
     * @since 3.0.0
     */
    boot: function ()
    {
        this.on(Events.LOAD, this.updatePending, this);
        this.on(Events.ERROR, this.updatePending, this);

        var config = this.game.config;

        this.addBase64('__DEFAULT', config.defaultImage);
        this.addBase64('__MISSING', config.missingImage);
        this.addBase64('__WHITE', config.whiteImage);

        this._pending = 3;

        this.game.events.once(GameEvents.DESTROY, this.destroy, this);
    },

I believe the line with this._pending = 3 in the 3.54.0-file belongs above the lines where BASE64 images are added to the manager. Otherwise TextureManager.updatePending() will count downwards starting from 0 and ending at -2, never emitting Events.READY, and thus Game.boot() will never trigger the callback Game.texturesReady() which eventually calls the postBoot() callback.

Example Test Code

No test code, this seems to be obvious.

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions