Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Finding possible performance bottleneck  (Read 1886 times)
0 Members and 1 Guest are viewing this topic.
Offline NuclearPixels
« Posted 2018-02-17 20:53:00 »

Hey, recently I have been trying to play the game I am developing on the phone and I have noticed that at some point the FPS start to drop (the game itself is being made in LibGDX and currently with all assets is around 25MB). On the desktop version I do not see that it drop FPS... In order to start finding the source of the problem I enabled GLProfiler and started to collect Heap and Native memory data. The memory does not seem to grow (which I believe is already a good sign). However the GLProfiler reports different things on Desktop and Android application versions. On Desktop version I can see that number of calls, draw calls and texture bindings remains constant while I am playing the game. On Android, on another hand, I see the same metrics increasing very fast... I would like to know is that is anyhow the indicator that I have some problem with the Android version? What else I can use to determine the possible source of the downgrading performance? Any feedback is highly appreciated Smiley.

Learning and having fun developing games. Twitter: https://twitter.com/NuclearPixels
Offline NuclearPixels
« Reply #1 - Posted 2018-02-18 09:25:48 »

After not being able to sleep a night I managed to solve some performance issues with culling (I was imagining the existence of such feature but did not even bother to search and experiment before I hit some performance issues..). Nevertheless the question on GLProfiler still remains open..

Learning and having fun developing games. Twitter: https://twitter.com/NuclearPixels
Offline VaTTeRGeR
« Reply #2 - Posted 2018-02-18 10:30:08 »

Quote
What else I can use to determine the possible source
Shave off stuff stuff until the problem stops, then you know what to examine further.
You can't debug if there's to much going on at once.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline NuclearPixels
« Reply #3 - Posted 2018-02-18 14:37:51 »

Quote
What else I can use to determine the possible source
Shave off stuff stuff until the problem stops, then you know what to examine further.
You can't debug if there's to much going on at once.

Following your advice I think I found the reason. I have basically the archers shooting the arrows and I calculate the rotation angle every frame (the respective image actor is rotated also every frame). I will try to cut the number of rotation, not like every frame but every N frames.

Learning and having fun developing games. Twitter: https://twitter.com/NuclearPixels
Offline VaTTeRGeR
« Reply #4 - Posted 2018-02-18 18:08:21 »

That doesn't sound like you found the real reason, are you sure that the problem you encountered is really linked to rotating actors?
Rotating actors/sprites should not use any extra gl calls, since it's done on the CPU if you use the spritebatch.

Are you sure you aren't just spawning stuff somewhere? Maybe duplicates of the arrows, etc?
Offline NuclearPixels
« Reply #5 - Posted 2018-02-18 23:45:49 »

I have been around performance issues the whole day... Several things which I believe I made which improved the situation:
1) I merged several texture atlases into the same one, so the application is using a single atlas with multiple pages now
2) I reduced the number of collision detection calculations (by a lot) with a simple condition (this was actually a huge improvement)
3) In some places I was creating a new font instead of reusing the pre-defined one

Finally, I still was not happy with performance so I did a simple benchmark. I have quite crappy Android phone (one of the cheapest Samsung ones, simply because I have not been using phone for the last three years, I just bought something to test the game). So I basically created a screen with a stage and added to it 150 Image objects in the visible screen (something which the game was struggling with)... Well, the simple benchmark application was also struggling with this number of actors on the screen (running at aprox 20 FPS)... The benchmarks with SpriteBatch instead of Stage has shown similar results.. On one side I am happy because I observe very similar performance limitation, on another hand I am not, because it means that I will need to thing about game mechanics which will prevent the user from maintaining that many actors in the same location. On PC I observed the same performance drop at around 500 actors on the same screen, which makes sense, because the hardware of the phone is much less powerful..

Do these conclusions make any sense now Tongue? Or I am still missing something?

Learning and having fun developing games. Twitter: https://twitter.com/NuclearPixels
Offline VaTTeRGeR
« Reply #6 - Posted 2018-02-19 09:30:37 »

Didn't you say the number of gl calls were constanty increasing on android while they were stable on pc?

Is this still occuring or did you mean something else with that?
Offline NuclearPixels
« Reply #7 - Posted 2018-02-19 10:46:00 »

Ahh yeah I forgot about that.. I was going to post but decided to do more test instead of constantly bothering... This is still something I do not understand.. The simple code as the following:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
public class BenchmarkScreen implements Screen, InputProcessor {

   private BitmapFont font;
   private SpriteBatch spriteBatch;
   
   public BenchmarkScreen() {
      font = new BitmapFont();
      spriteBatch = new SpriteBatch();
     
      GLProfiler.enable();
   }

   @Override
   public void render(float delta) {
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
     
      spriteBatch.begin();
      font.draw(spriteBatch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 20, Gdx.graphics.getHeight() - 20);
      font.draw(spriteBatch, "Objects: " + count, 20, Gdx.graphics.getHeight() - 40);
      font.draw(spriteBatch, "Calls: " + GLProfiler.calls, 20, Gdx.graphics.getHeight() - 60);
      font.draw(spriteBatch, "Draw calls: " + GLProfiler.drawCalls, 20, Gdx.graphics.getHeight() - 80);
      font.draw(spriteBatch, "Texture bindings: " + GLProfiler.textureBindings, 20, Gdx.graphics.getHeight() - 100);
      spriteBatch.end();
   }
}


On the PC shows 22 calls, 1 draw call and 1 texture binding, while on Android all of those are constantly increasing...
The main class is:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public class Main extends Game {
   @Override
   public void create() {
      setScreen(new BenchmarkScreen());
   }
   
   @Override
   public void render() {
      super.render();
   }
}


And the Android launcher as simple as:
1  
2  
3  
4  
5  
6  
7  
8  
public class AndroidLauncher extends AndroidApplication {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
      initialize(new Main(), config);
   }
}


I have no idea what can cause such a difference if GLProfiler behavior..

Learning and having fun developing games. Twitter: https://twitter.com/NuclearPixels
Offline VaTTeRGeR
« Reply #8 - Posted 2018-02-19 14:53:45 »

Maybe the gl profiler just doesn't get reset on android Grin
If the gl calls would really increase constantly you would always see a slowdown after a certain time, no matter how little or much you draw each frame.
Offline ClaasJG

JGO Coder


Medals: 43



« Reply #9 - Posted 2018-02-19 16:14:48 »

From what I see you never call GLProfiler.reset().

-ClaasJG

My english has to be tweaked. Please show me my mistakes.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline NuclearPixels
« Reply #10 - Posted 2018-02-19 16:49:50 »

Yes I never do, but in this case shouldn't it also accumulate the counts on the PC? Because on PC the counts remain constant after I start the application..

Learning and having fun developing games. Twitter: https://twitter.com/NuclearPixels
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (272 views)
2018-11-16 13:46:03

hadezbladez (150 views)
2018-11-16 13:41:33

hadezbladez (282 views)
2018-11-16 13:35:35

hadezbladez (66 views)
2018-11-16 13:32:03

EgonOlsen (2121 views)
2018-06-10 19:43:48

EgonOlsen (2145 views)
2018-06-10 19:43:44

EgonOlsen (1357 views)
2018-06-10 19:43:20

DesertCoockie (1953 views)
2018-05-13 18:23:11

nelsongames (1596 views)
2018-04-24 18:15:36

nelsongames (2243 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!