Skip to content

Phaser on iOS (sometimes) stay paused #668

@SBCGames

Description

@SBCGames

This issue may be similar to #663.

Problem is, that when you click icon for browsing tabs (top right corner - see image below) and immediately click on tab with game, then game stays paused=true and looks like frozen. All buttons work, but game stays paused. It looks like resume is not called.
BrowseTabs

It does not happen always. Usually, it happens when you just opend browser and loaded game. I shot video of what happens and it is in .zip below (my iOS version is 12.4.6, I also tried Phaser engine version you attached to case #665, but without success):
paused.zip

As a fix I subscribed to onPause signal in Boot state:

game.onPause.add(this.onPauseHandler, this);

onPauseHandler() looks like this:

    onPauseHandler: function() {
        if (game.device.iOS) {
            this.addMyCanvasListener();
        }
    },

and finally addMyCanvasListener() like this:

    addMyCanvasListener: function() {
        var can = document.getElementById('game-container');
        can.addEventListener('touchstart', function _listener() {
            game.paused = false;
            can.removeEventListener('touchstart', _listener, false);
        }, false);
    },

With this setup I can unpause game if it is still paused after selecting tab.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions