Facebook instant game (HTML5 iOS) problem (SOLVED)

We are develop a game for Facebook instant games platform.

Instances on PC, Mac and Android have no problems.

Instance on iOS have a problem: game objects do not releases it`s resources after destroying.

Watch the video…

It’s starting to lag right?

Are you deleting game objects that goes off screen? Check profile to confirm instance count.

Is the gun moving vertically or the coins etc? Ie is gun y position constantly increasing or staying around 0?

It’s starting to lag right?

Yes.

Are you deleting game objects that goes off screen?

Yes.

Is the gun moving vertically or the coins etc?

The gun moving vertically, the gun y position constantly increasing.

Check profile to confirm instance count.

We recorded a video with profiler…

In general, the further you get away from origin (0,0,0), due to floating point precision you’ll lose accuracy. Check this post for more info: Floating point precision

So, for infinite runners it’s a good idea to make the character “stand still” and instead let the objects animate towards the character.

Also, for the same reason, you might lose precision in rendering too, so you might need to use midp, or even highp precision in the shaders.

By looking at the profiler video, nothing really stands out. The numbers seem to remain constant.

Q: At what coordinate is the gun at the end of the video?

The lag is most definitely due to the loss of precision. I’ve seen it multiple times before. Changing to highp in the shadr will help, but a more permanent solution is to let the gun stay still and move everything else.

Parent everything in the world to a root object, then move it downward. Chunk world segments like this with each segment parented to its own root GO.

Keep the gun vertically stationary more or less.

1 Like

Looks like you are right. Is is a precision problem.

But why this problem is only on iOS devices? Is this problem of iOS Safari?

Different devices have different ways of handling the rendering. You would see similar issues with other game engines most likely.

You will eventually see similar issues on other devices the further objects are away from world origin. Nearly all modern big games have the world moving around the player rather than the player moving around the world.

2 Likes