Button on click not triggering on some iOS devices

We are working on a game targeting phones and we’ve found on click event handlers are not firing as expected on some iOS devices. The button visually appears to be clicked but the handler does not appear to call the handler at all. Unfortunately this has only appeared on some user devices and not on our own devices and haven’t been able to capture the console. I’ve attached the handler which is setup in initialize on a script attached to the button itself. It has worked on 100% of windows and android devices but only on about 50% of iOS devices.

One device we saw this error on was an iPhone 12 running iOS 15.4.1.

Here is a link to our game Teach Quest

// initialize code called once per entity
StartButton.prototype.initialize = function() {
    if (this.entity.button != undefined && this.sceneManager != undefined && this.sceneManager.script != undefined && this.sceneManager.script.sceneManager != undefined)
    {
        let self = this;

        this.entity.button.on('click', () =>
        {
            self.entity.button.active = false;
            self.startUI.enabled = false;

            self.sceneManager.script.sceneManager.loadScene('Game');
        }, this);
    }
};

Does this happen on an empty project with a single screen button element?

We got one of the users who experienced the problem to try this. I made this basic button project. This seemed to work for them.

We tested this using an iOS 15 simulator and see the same behaviour. Only error in the console seems to be:

 [Error] SyntaxError: Invalid regular expression: invalid group specifier name
	(anonymous function) (__game-scripts.js:1)

var Utils = pc.createScript("utils");

Could be a regex bug in Safari javascript - Works in Chrome, but breaks in Safari: Invalid regular expression: invalid group specifier name /(?<=\/)([^#]+)(?=#*)/ - Stack Overflow

Worth getting an account on something like Browser stack and check through the iOS versions

2 Likes

Thank you! It seems this was exactly the cause of the problem. iOS is such a pain for web games! Thanks for making playcanvas so good for most situations. I’m using Unity WebGL for another project and it has a bug which means their UI toolkit buttons crash the browser on certain ipad versions. I filed a bug report and they said they confirmed it but won’t fix it for now.

2 Likes