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

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.

2 Likes

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

2 Likes

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.

2 Likes

Ok, I’ll try to create a minimal version that still slows down and would be easier to investigate. This would ensure that the problem doesn’t come from a specific feature but something deeper.

However:
1/ Just in case => Is there a way to build directly on iPhone when using Windows 11? (looks like I need a Mac to do so)
2/ In addition to the initial loading (which is just the first manifestation of the problem), there are also elements that appear one after the other (not all at once), and a decrease in FPS when clicking on elements (characters, buttons). It’s a general slowdown, even with almost nothing on the screen.

Thanks :pray: but it was on mobile (iOS) that I didn’t know where to find the developer tools :grin:

Well, I wasn’t too optimistic about the iPhone 6, even though I initially wanted the game to run on it. But now I feel like even with the most powerful device in the world, it would still be laggy.

2 Likes

As discussed in this thread (Framerate dropping when altering the view matrix) regarding profiling, have you tried with a release build of the game? I noticed a bunch of spikes when testing the game, so you might be running into similar issues.

1 Like

Hey!

Sorry for the delayed response, but this issue has been severely affecting my motivation, so… I did not have the heart to work on it. I focused on cross-cutting features, such as a localization system, to continue adding useful stuff to the project.

Now my game still takes a long time to load but in 8 languages. :sunglasses: (🥲)

Anyway, let’s get back to the issue…

1/ I’m not sure if there’s a connection with the problem mentioned in this thread (in my case, the framerate isn’t the main issue), but what do you mean by the “release build of the game”? Is it this?
image
If so, then yes, I always use this parameter value (and have always used it… as far as I remember).

2/ Currently, I’m removing elements from the project (I’ll share it once I’ve reached the minimal version), reducing the scope, and adding numerous “performance checkpoints.” However…

3/ …for some reason, the game still runs perfectly smoothly on HTML5 desktop (the loadings are instant), but it takes much longer on mobile.

4/ Just as a reminder (because it’s been a while), the game was working flawlessly on mobile in January. Then, without any apparent reason, with the exact same build, it started lagging in March. This is where things get really strange because a laggy game itself isn’t unusual.

Note: at the moment, I have around 30 loading checkpoints in the scripts (using os.clock), and I noticed something weird: the os.clock values (stored in a table and displayed via print() + debug draw on mobile) are the same on both mobile and desktop, while the scene loadings are much longer on mobile.

It seems like something unusual is happening before everything is fully loaded… but I need to confirm this. I’ll get back to you and share the minimal version once it’s done.

2 Likes

Yes, that’s what we refer to as the “Release” build. We use that setting to turn off some debug functionalities, which is recommended when shipping a game.

Thanks :pray: but it was on mobile (iOS) that I didn’t know where to find the developer tools

You can use your local Safari on the mac, to debug the web page on your connected iOS device, using Web Inspector. (e.g.: How to Debug Websites on iPhone Safari | BrowserStack)

Also, as a reminder for (e.g. me) reading this thread: the same build, i.e. same game version and same Defold version (1.3.6) started to suddenly load much slower. So it’s not believed to be a Defold specific issue per se.

Have you tried hosting the game somewhere else? To compare the performance?

Have you tried using an older version of the browser?
Or reading about what changes has happened for that browser?

Perhaps it’s JavaScript vs WebAssembly related?
You could try bundling two separate versions: One with only JavaScript, and one with only WebAssembly.
I see now that the bundle dialog doesn’t expose this functionality, so you’d have to modify your dmloader.js a bit to disable wasm loading (i.e. make isWASMSupported
return false).

1 Like

We have an active PR for this which I expect to merge next week.

3 Likes

Hello!

Indeed, that’s what I’ve been thinking from the beginning. Although Defold could/should take certain external changes into account… as mentioned below.

Yes, I’ve tried hosting the game somewhere else, but there was no difference.




Simplified project version
I’ve simplified the project as much as I could.
https://github.com/Ragetto/Ragetto-20230420_SHARED_Laggy_Project_Minimal_Version
Added @Mathias_Westerdahl, @britzl and @jhonny.goransson in case they might take a look. But at this point it may not necessary because the problem may be of a different nature, cf below.

Yesterday, the project was reduced to a single scene with empty scripts.

Overall performance issue
Despite having almost nothing in the project, it still took 4-5 seconds to load on mobile.

I eventually removed the last “advanced” element, aka collection loading via Monarch.

And boom, instant launch.

However, I don’t think Monarch itself is to blame. It seems to be a broader performance issue that affects Monarch in particular, but it’s just a consequence.

I wanted to make sure by displaying some elements frame by frame right after loading (on mobile), but… that’s no longer “possible”, as mentioned below.

Latest iOS update
This morning, after several days/weeks of harassment from my phone, I finally installed the iOS 16.4.1 update (from iOS 16.3.1).

And… and…

The game is smooth again. For real.

As I suspected (with no way to be sure back then), the issue occurred between January and March, which is when I must have updated to iOS 16.3.1 (this update was available at the end of January, I probably updated in February… so it makes sense).

Performance recap
1/ On iPhone X (probably pre-16.3.1, 95% sure): the game runs fine.
2/ On iPhone X (16.3.1): the game has performance issues.
3/ iPhone X (iOS 16.4.1): the game runs fine.
4/ iPad Pro (iOS 16.3.1 to be confirmed!!!): the game runs fine.
=> I’ll ask my friend to confirm if the tablet is indeed on iOS 16.3.1… because that’s strange.
5/ On @anon95708182 's Android devices, the game has performance issues.
Samsung Galaxy Tab S on Android 6, an LG K41 phone on Android 10.
(but I have no idea about the power of these devices - are they recent?).

Conclusion
In short, the issue is not fixed, but…I don’t know what the issue really is. It seems there’s something beyond Defold, but I think that’s still something Defold could/should deal with.

I’ll mention it in the survey, but personally, “performance consistency” is my number one concern by far, even more than features and advanced stuff.

Not to mention Android (I think I’ll need to buy at least one Android device), just the thought that two people (one on iOS 16.3.1 and the other on iOS 16.4.1) would have completely different experiences… it’s discouraging. And the fact that I was the only one experiencing this issue, sometimes wondering if I was going crazy, makes it even more discouraging.

Thank you for your answers though! :pray:

I would be happy to help identify the issue if I can.

The problem is that I don’t know how to downgrade to iOS 16.3.1, so I won’t be able to run any more performance tests in the very short term (but I will have the opportunity to use the iPad Pro mentioned earlier, which, from what I understand, is still running on iOS 16.3.1… And the game was running perfectly. It’s hard to understand).

I finally installed the iOS 16.1.4 update (from iOS 16.1.3).

Are we talking about iOS 16.4.1 and 16.3.1?

I don’t know what the issue really is. It seems there’s something beyond Defold, but I think that’s still something Defold could/should deal with.

I mean, sure we want to help and if there is anything we can do, we should.
But please be aware it is an uphill battle to anticipate and work with any future changes to the OS’es (both features and bugs) that they can introduce at any point in time.
We will still need the community to help pinpoint any edge cases that we’ve missed.

I know it’s frustrating, but we’ll continue to investigate to see if we can figure something out.

1 Like

Yes, sorry, I made the confusion several times in my message. Just edited it.

Yes, I understand. Especially since that one was quite sneaky…

I think that as the community grows larger, it will be easier to identify these kinds of issues and react quickly. On this occasion, it was just me (in panic mode) and my unclear explanations.

Anyway, as mentioned above I remain available to help identify the problem (within the limits of my abilities :monkey:).

Question: should I tag this topic as ‘SOLVED’?

The Samsung is very old, the LG 2020.
Have you got a friend with a recent iphone and a mac you could ask to debug the web page for you (you run Windows, don’t you)?

1 Like

When I test on my device (iOS 16.3.1), I get a black screen for 3 seconds. Some loading time is expected ofc, but question is where it’s spent.
I also see an extra stall for ~1.2 seconds, where the page isn’t updating, so perhaps there’s a function somewhere that actually takes that amount of time? (If I read the web inspector properly)
I added some prints in the init() functions of the loaded collections, and they arrive at ~2s into the loading, and then there’s another 1s before the loaded collection renders.

I’ll see if I can pinpoint where this time is spent.

Expanding the callstack for that frame in the Web Inspector, it seems there is a call to texSubImage2D that takes ~1.2s.

Aside from uploading less data (e.g. compressing images), there is little one can do to improve the speed of the graphics drivers.
That said, I still feel like the rest of the time: 1.8s is quite long for loading this small scene :thinking:

2 Likes

Yes, as mentioned above, I have a friend who has an iPhone 13, iPad Pro and a Mac

On his iPhone 13 (iOS 16.3.1), the game was slow.

On his iPad Pro (also iOS 16.3.1… but I asked for confirmation to be 101% sure), the game runs smooth.

Both devices are equally powerful, so… well, it’s puzzling.

The guy in question has a Mac, so if there are any stuff to check from the debugger, I will be able to do it at his place.

1 Like

Indeed :sweat_smile:
All the scripts are cleared or deleted, there is really (almost) nothing in the sandbox collection.

Note that the “black screen” is instant when you remove the collection loading via Monarch. That could be a lead, I don’t know…

But as mentioned above, I have the intuition that the loading related to Monarch is more a consequence of a broader performance issue rather than Monarch itself.

Note that they are running different OS’es though.

1 Like

Oh… iOS 16.3.1 iPhone is different from iOS 16.3.1 iPad?

Didn’t know that.

It’s actually iPadOS:

1 Like

And when I updated to iOS 16.4.1, the issue is gone, with the same build. Just as you experienced.

Personally, I think this is due to some issue in that browser version with regards to WebGL or similar. It isn’t something we can affect I’m afraid.

(unless someone has any other ideas to try out)

2 Likes