Jump to content

FB Game crashing at start on iOS with "Object in invalid state" and "Type Error"


attilioHimeki
 Share

Recommended Posts

Hi everyone ?

I'm currently working on a game for Facebook Instant Games using Phaser CE 2.10.3

When running the game on desktop everything works well.

On the other hand, when we try to test on iOS devices via Messenger, we often get this error at startup:

The object is in an invalid state. in /instant-bundle/***/***/js/lib/phaser.js Line: 15699

Occasionally we also get this error, but I haven't been able to pinpoint a specific cause, seems to happen randomly but it's related to the same line number:

TypeError: Type Error in /instant-bundle/***/***/js/lib/phaser.js Line: 15699

I'm using Phaser.CANVAS as render mode. I'm not sure what it may cause those errors as we don't have anything platform specific.

I would appreciate if you had any suggestions to fix the problem, thanks in advance!

 

Link to comment
Share on other sites

I think I may have found the cause of this issue, or at least for the first error.

I was using a tween to change a nineSlice view object height from 0 to a target height. For some reason Phaser didn't like that the height was set to 0 initially so it crashed, even though only on iOS. On chrome Windows there was just a warning.

It may be because on Desktop we use WebGL, while on iOS we use Canvas but I'm not sure. 

It's strange also because it used to work until now, so maybe it's because of a Phaser update, or Messenger or FB IG update.

Anyway, hope that helps in case anyone has the same issue.

Link to comment
Share on other sites

3 hours ago, attilioHimeki said:

For some reason Phaser didn't like that the height was set to 0 initially so it crashed, even though only on iOS.

Any way you could find the line that causes the error?

Link to comment
Share on other sites

On 5/5/2018 at 8:52 PM, samme said:

Any way you could find the line that causes the error?

Sure, I believe the line that caused the error was the one inside the update callback. I added the Math.max to make sure it was never trying to set height to 0.

var obj = {currentHeight : prevHealth};
var target = this.health;

this.healthBarTween = game.add.tween(obj).to({ currentHeight: target }, 500, Phaser.Easing.Linear.None, true);

 this.healthBarTween.onUpdateCallback(function(){
            var height = Math.max(1, obj.currentHeight);
            this.healthBarGroup.resize(5, height);
        }, this);

this.healthBarTween.start();

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...