Lags: game on iPhone XR shows worse performance than on iPhone 7

Hi, I’m seeing really weird behaviour - my game obviously lags on iPhone XR and works smoother on iPhone 7. Moreover, I see the same behaviour both on native app and on HTML5 build. How is this possible? See the videos attached:

Native app:

HTML5 build:

Do you see the obvious freeze before showing a pop-up message in the end of the level on the left (bigger one, XR) screen? Character lands, bounces, [LAG], popup is shown. On the right sсreen there is no lag.

Defold 1.2.163.
iOS 13.2 on iPhone XR
iOS 12.3 on iPhone 7

How is the popup message created? Are you loading some content perhaps?

hidden gui node with text. there are some routines during showing it - hiding some parts, enabling others, switching textures regarding the type of the popup, setting text, changing position and scale. no networking or downloads.

BUT even if there were heavy operations or networking - how it’s possible to be smoother on 2 years older device?

and yes, without showing the popup at all it’s smooth on both devices, but I did not figured out what exact part in popup-showing causes freezes. I’ve split initialisation and animation into two separate frames but this did not help. will dig deeper later tonight

aaand of course it should be „do you see the freeze … on the left screen”, sorry

In the older build available in the appstore, made with older Defold version, there is no such lag on the same device. But can’t say right now if it’s due to my changes in code or to engine changes. In my opinion my changes were not so heavy around the popup, but need to check.

It seems it’s a font related issue. Try to remove all text and test them with just the popup image. Drawing text is done with sprite in Defold engine though, there are bunch of operation to put it on screen. Definitely XR is having better gpu which is embedded as the A12 System on Chip while 7 is using PowerVR GT7600 gpu, but there could be a hw accelerator issue.

1 Like

How do you figure?

Drawing text is done with sprite in Defold engine though

These are only two triangles with a texture, nothing has changed here. Defold is quite performant when showing sprites. And there’s no reason this should be slower than the rest of the game.

2 Likes

Guessing. That’s why I suggested to try to test without text so that we can know the part of the reason at least. D&C approach.

That’s why I also mentioned about the hardwares.

Since it’s on both Native+HTML5 but only on the XR, I too suspect HW.

Only thing I can think of is uploading textures. Unpacking is done on the CPU using NEON (if you’ve chosen WEBP compression). Uploading the texture to GPU is done on a thread (not on HTML5).

Next clue is that the glyph cache texture might not be “warmed up”? For each new character, we decompress it (WEBP compressed), update the subimage texture, upload the subimage texture.

You can try to set the needed text onto a text node (outside of view), at some earlier point in the game (e.g one character at a time), and then (if this was the issue), the stall would be removed from the popup.

2 Likes

Thanks for the comments! At first I’ll try to avoid loading/changing textures at runtime, and then if it’ll not help try to “warm up” texts. I’ll put an update here.

One change I’ve made recently - added outline in my main font (outline alpha is 0 in 99% of text nodes, actually used only in one screen) - can this cause a slow down in text rendering, even if outline is not rendered? Maybe it affects “warming up” processes as well?

2 Likes

No, the extra outline doesn’t cost extra, you already “pay for it” (see font-df.fp).

And, this is about the initial lag, not the general frame time, which excludes the actual (font) rendering.

2 Likes

Just a suggestion. Check if you have any power saving feature enabled on the XR and also try with both connected to power rather than on battery. I had some weird things happening in my case.

Also a difference could be the fact that XR is running iOS13 and the 7 is on iOS12.

4 Likes

Ok, I found how to fix it, but I still don’t really understand the cause.

So:

  1. tried to build in previous engine versions back to 1.2.160 and tried to disable textures changing in runtime - did not help
  2. if text is not changing, then there is no freeze, the same for repeated texts - freeze appears only at first “unique” text render. so “warm up” thing sounds reasonable
  3. if there is no outline in the font, then there is no freeze (either outline == 0 or outline_alpha == 0)
  4. if set output format to “Distance filed”, then there is no freeze even with non zero outline (it was “Bitmap” previously); changing render mode between single and multi layer does not affect the bug.

So, finally I’ve just changed output format to “Distance field” and everything looks ok (but need to test on all platforms and devices).

And it’s not really clear why it was freezing specificially for the Bitmap output + non zero outline and only on iPhone XR…

3 Likes