Low frame rate issue

Hi. Im making a game using cocos2dx 3.17.2 (on android)

The game is not running smoothly, fps is low. Especially on some devices.

There is too much code inside schedule( … ) functions but i doubt its the reason of low fps.Im running game in debug mode and all sprites have separate texture files, if it matters. Please help me to find a solution

Profile your code… see which functions and sub functions are consuming the most time… generally this either falls on the side of the GPU not being able to draw an inefficient set of instructions fast enough, or on the CPU side trying to compute too much (inefficiently/sequentially) inside the update time step…

this could be a false doubt… profile before assuming anything.

Also how many draw calls are you sending?

Are you doing anything to break auto-batching?

I cant profile native code in android studio. is there a way to do that

No. i dont think so

Try this: https://developer.android.com/studio/profile

If you have an nVidia GPU and use Windows, then build a Win32 version of your application, and use nsight-graphics to profile it. You can see what is being sent to the GPU every single draw call (among other useful bits of information).

Separate files leads to no autobatching, and increased drawcall count. How many sprite files do you have?

I have 62 files

I cant see which c++ functions cause the lag. Android studio doesnt let me use advanced profiling

62 draw calls is not so much to cause slowdowns. If you can open your project in xcode, run it o iphone, then you can get full graphics profile. Anyway, just try to put your sprites in one-two big textures and see if slowdowns are gone…

If Android Studio isn’t enough to help you track down your issues, and you are using Windows, then try Visual Studio 2019. Create a Visual Studio solution for your application using cmake, then open up the solution in Visual Studio, then use the profiling functionality in it (menu ANALYZE->Performance Profiler).

I tried a lot of things (sprite sheet, disabling sounds…) but nothing worked. Fps is around 58-60 but its lagging, not running seamlessly. I couldnt find the problem with profiling tool either

You might want to analyze the same code on Windows as many people are suggesting. Most importantly, DON’T profile performance with debug builds!

Also, when you see the game “lagging”, are there actions that are being triggered irregularly. I’d consider hacking away at code and functionality to remove as much as possible to get the FPS that you desire, then adding things back slowly to see what introduces the lag.

Good luck!