[SOLVED] Same version of my game got slow/laggy for no (obvious) reason - *really really* weird performance issue

Hi guys!

I’m currently (or more precisely have been for the last ~2 months) encountering a super weird issue (probably the most annoying I’ve ever encountered). It took me some time to post this message because it was a bit demoralizing so I decided to work on other stuff.

Long story short: the exact same version of my game was working fine on mobile ~2.5-3 months ago and I realized ~1-1.5 months ago that the game was MUCH slower (more details below). No change, no update. Same device, same game, same version. Nothing changed since I’ve uploaded the html5 files via the ftp client. Well, something probably changed but nothing related to the game itself…

As said above, 2-3 months ago the game was really fluid on html5 mobile, with short “black screen” loadings (like 0.5-1 second, max). Creating a smooth user experience was and still is my highest priority (because for me it’s not “for real” if I can’t share a playable version), so until now I never considered a feature completed if the added stuff was making the game laggy.

But now, on the exact same device, with the exact same version:

As you can see, the “black screen” loadings between scenes takes sooooo long (10+ sec!!!) and the gameplay elements are not simultaneously loaded… Actually, the 1st black screen takes so long that I had to trim the video almost right after it… Horrible.

A few weeks ago I tested the same version on a friend’s phone (iPhone 13 Pro): same result! Huge disappointment because I would have preferred for my iPhone to be the cause of the problem.

But but but… right after that, we tested it on his tablet (iPad Pro) and SURPRISE: super fluid, just like it used to be on my iPhone.

(the gameplay seems less intuitive than I thought :sweat_smile: but at least it’s fluid - just like on my iPhone before it got laggy for “no reason”)

It’s ok on html5 desktop too.

Iphone X (iOS 16.3.1) > slow… (previously OK)
iPhone 13 Pro (iOS 16.3.1) > slow… (“probably” previously OK)
iPad Pro (iOS 16.3.1) > OK!
Desktop (html5) > OK!
Note 1 : same results on both Chrome and Safari (doesn’t seem browser-specific)
Note 2 : super old versions are laggy as well…! Something really happened but I don’t know what.

At this point, I’m a bit desperate because as mentioned above, maintaining good performances on mobile has been my main obsession from the very beginning, and what I’m currently facing just doesn’t make sense to me. It doesn’t feel like a regular performance issue, it’s like there is something “external” I can’t control…

But I can’t imagine being unable to fix this (very) unexpected and (very) annoying issue.

Are there any possible causes that come to your mind? Could the issue be caused by an iOS update or anything OS/device-specific? Did someone else encounter something similar? How should I investigate?

Here is the latest version of the project, the result is exactly the same: slow on iPhone X/13, fast on iPad and desktop:
Feel free to give it a quick try to see if it’s laggy on your device. You don’t have to play more than 30 seconds, because you’ll know soon enough if it’s laggy or not. If the 1st black screen takes more than 1 sec, then… there is a problem.

PS: please help :pray:

1 Like

Hm - I tried on my Android devices, an older tablet and a newer phone. Same here, the loading screen takes many seconds, then many seconds the screen is black. Desktop no problems.

1 Like

If I understand correctly, it’s the same laggy experience with an older defold version? Could you share the game with me? I could take a quick look if there’s anything on our end

1 Like

Hey! Thank you for your answer :pray:Seems like it may not be iOS-specific then… (until now I was only testing on iPhone so maybe it was laggy from the start on Android, who knows)

Which device models are you using? Which browser? (Chrome I suppose)

I was about to post the message below before seeing yours, I think I’ll post it anyway.

I understand that my first message may be too long and unclear, most of you have probably nothing to say about my issue but… I don’t know how to explain the unexplainable (and how demoralizing it is - well ok at this point I realize that nobody gives a fuck about the personal stuff🤭 but I’ll provide at least a bit of context).

I’ve been working on this prototype for ~1 year, and thanks to this forum the technical performances on iPhone drastically improved from “terrible” (7-8s black screen when loading a collection) to “more than acceptable” (0.5-1s). 1.5-2 months ago I was discussing with people around me about how to complete a first version and turn it into a monetizable product, but… “just like that”, the game became unplayable on my iPhone for no reason. I mean, I know there is a reason, but the game itself has not changed.

Do you have any idea what could have caused that? I can’t imagine something else than an “external” cause since even older versions are slow now…

  • iOS update? (maybe some html5 stuff are managed differently… I don’t know. My iOS is up-to-date but unfortunately, I can’t tell precisely when I updated it for the last time… Probably in 2023 but I don’t remember when)
  • My device? (I would have preferred this option but it’s also slow on an iPhone 13 Pro… while it’s smooth on iPad Pro)
  • The server? (probably not, I changed the hosting service and the result is the same. Anyway I suppose that there is no reason for the server to cause such an issue for that kind of games)
  • The browser? (but same result on Safari and Chrome…)

What do you think? Any other possible ‘external’ cause?

And I was also wondering: leaving this unknown “external issue” aside, is it normal to have so low performances on iPhones (even pretty powerful ones like an iPhone 13 Pro) and at the same time good ones on iPad Pro? (with the same OS / version) The iPad Pro is slightly more powerful but still pretty close to the iPhone 13 Pro.


So sorry, I need to run! Will check tomorrow and tell you about the devices and the Android versions.

1 Like

Oops sorry, I didn’t see your message (hidden between my walls of text :sweat_smile:)

The latest (laggy) game version is using Defold 1.4.4.

But before that, I was using Defold 1.3.6 and this is where it suddenly got laggy for “no reason”. I updated Defold pretty recently (I was a bit desperate and hoped for a miracle), so I don’t think there is a link…

Would you need me to share the whole project repository so you can access the older versions too?

Oof yes it’s a bit of a leap probably between those two versions. Yes, please share the project with me, my github handle is jhonnyg (Jhonnyg (Jhonny Göransson) · GitHub)

1 Like

Done! Thank you :pray:

2 attention points:

  • The gamesave format are different between new and older game versions, there is no retrocompatibility for now… (you need to manually delete your gamesave if for some reason you switch from new to old etc. But it shouldn’t be necessary to check the initial “black screen” alone)
  • If you want some info about the versions (both game & defold), you can open the constants.lua file

Anyway, feel free to ask any info/action that would make your investigation easier!! Thank you

Do you have a timestamp or a hash or something when it didn’t lag? There’s like 1200 commits, so if I were to backtrack I’d have no idea where to start :slight_smile:

Hey! When you say “timestamp/hash” do you mean generated info in a specific format? (if so, I don’t know how to get it - feel free to explain, I’ll gladly provide what’s needed!)

Not sure if this is was the kind of info you were expecting, but here are some dates:

This version was working fine (January 9th) and using Defold 1.3.6:

I tested the game on mobile 2 months later and realized that the game had become (ultra) laggy on mobile in the meantime (March 1st) - also using Defold 1.3.6:

At this moment, all the previous live builds (including the January one) were like… “corrupted”.
=> This is where this is weird… I could have accepted that a new version was laggy, but… ALL the previous ones (that were working fine until now)??? Doesn’t make sense to me.

I updated to 1.4.4 pretty recently (end of March - version 0.15.4). It didn’t change anything.

With timestamp, he means, do you have an example of a date and time, when you know it worked and similarly when you first noticed it didn’t work. That way he can checkout the versions of your project in between those dates+times.

With “hash” he means the commit id (e.g. the sha1 from git). This also allows him to bisect the issue by testing the versions from when it worked to when it stopped working.

1 Like

Yes exactly what mathias said. The reason is that we need to narrow it down to “something”, as it’s a quite big project and there’s nothing special that stands out by just looking at the code. So as a first step it would be great to find out if it’s the project code or Defold itself that has changed and caused the issue. Ideally if we could compare a non-laggy snapshot of the game with an old version of the engine and the latest we could perhaps figure out if it’s an engine issue or not.

In any case, I did profile a little bit with the web profiler and there were definitely lag spikes for doing specific things like opening up popups and such. And I would recommend to use culling in the render script to at least save some draw calls. Next thing I would look at is the amount of messages being passed around

1 Like

Ok thanks!

I don’t know if this is secure or not to copy/paste the full SHA on a forum (?), but I quickly checked and got this:

Pretty sure it was working at this point (because there is a commit called “powers gameplay validated on mobile”, meaning the game was working fine at this time)

Unfortunately, I didn’t work “seriously” on the game for several weeks, nor tested it on mobile… (since I had no reason to be suspicious). I tested it again when the feature was completed in March (and this is when I realized…):

I’m not an expert at all so I can’t say for sure, but I don’t think it comes from the project itself (even though I know it can be optimized in many aspects), because I really didn’t make core changes between January and March (nothing that would suddenly make the black screens longer and the game laggy… and would impact older live versions too => this is the main point that makes it feel really weird).

Did something “fundamental” related to Defold change between January and March ? (something that could apply hum… “remotely” to live html5 builds)

SInce you’ve tested an already bundled version of your game and that one has degraded in performance, I’d say that something external to Defold has changed.
However, it may still be that it’s something we could/should handle.
First step is to figure out where that extra loading time comes from.

1 Like

Maybe something changed with WebKit in the meanwhile? I’m unsure how to test with older Safari versions as on iOS Safari is bound to the version of iOS and downgrades are impossible.

1 Like

Note that, as mentioned above:

1/ The game runs smoothly on my friend’s iPad Pro (not much more powerful than his iPhone 13 Pro, in any case not enough to justify loadings 10 times shorter).

2/ The game runs smoothly on HTML5 desktop (even in ‘low power’ mode).

I will borrow the iPad Pro in question, if it can help…

Have you enabled some kind of developer settings in Safari on your phone (check in Settings > Safari > Developer)?

What if you connect the phone to your computer and check in the macOS Console app? Is there any output from the phone that could explain it?

Or in the Safari Debug Console (Settings > Safari > Developer > Debug Console)?

Or in the Web Inspector in Safari on your computer? Enable the Develop menu in Safari on desktop, then select your connected device from the new Develop menu option.


Unfortunately, I don’t have a Mac :see_no_evil: I work on Windows 11, so I don’t have a macOS console. I don’t think I’ve activated any developer settings, but just in case, I checked:

Safari => couldn’t find them where tutorials say they should be (maybe because I don’t have a Mac)
Chrome (my default browser) => couldn’t find them, if there is an equivalent.

Note that the game performs poorly on raetia’s Android devices too…
Samsung Galaxy Tab S on Android 6
LG K41 phone on Android 10
Maybe it was already the case before, but I doubt it. Anyway, we’ll never know about those.

Next week, I will have access again to the iPad Pro mentioned earlier (on which the game runs “perfectly”…). Are there any things to check?

I wonder if I should go to an Apple Store and test my game on all available devices, hehe…

If you don’t I would approach it by disabling features until you see any difference and take it from there, it’s very hard to debug as an outsider in such a large project


Hi Ragetto, here are the Developer tools on Chrome:
Screenshot 2023-04-20 at 20.10.56

I did check on an iphone 6 (vintage, I know :laughing:), running IOS 12.5.5. Same slow loading.