Big performance issue on Android

Hello everyone :slight_smile:

I was testing my Android project using MonoGame and Xamarin when I noticed that I had a big performance issue when I deploy my game on a real device.

I’ve spent many times trying to figure out from where comes the problem, but even removing the most CPU time consuming tasks, I’ve not been able to get more than 50 FPS.

So I create a new MonoGame Android project in which I just display the FPS + the update/draw times, the performance issue is the same on my device, I can’t get above 50 FPS. I pushed the code on a Github repository: https://github.com/Noxalus/MonoGameAndroidPerformance

From what I saw, the draw time on my device (HTC One M9) is really high, around 16ms, and it seems that it’s the time to perform a GraphicsDevice.Clear().

Until now, I did my tests with a VM (thanks to Genymotion), and the problem doesn’t appear in this case.

Do you know what happens? Do you encounter the same performance issue on a real Android device?

Hi !
Are you using MG 3.5 or the dev branch ?

Hi and thank you for your answer Alkher :slight_smile:

I’m using MG 3.5, I didn’t try to use the dev branch yet.

I had the time to test with the develop branch of MonoGame, and the performance issue is the same on my device.

I cannot try your code because i only have visual 2013. (It says i can’t open the project.)

Nonetheless, do you have the possibility to try the deployment on another device ?
Try playing with resolutions, customize the update time, etc ?
I don’t have a great experience with android:, I used to make apps with UE.

More experimented devs would help you far more than I can. (cf @KonajuGames among them ?)

I don’t have any other device to test unfortunatly, but I can provide a APK if you want to test.

I’ve tried to change the resolution and to unlock the FPS, but it doesn’t change anything… :’(

I maitain the fact that the GraphicsDevice.Clear() take too much time, here are the log with only the clear call:

Update time: 0,0642 ms
Draw time: 17,8817 ms
01-14 17:50:37.109 I/mono-stdout(29658): FPS: 49
01-14 17:50:37.109 I/mono-stdout(29658): Update time: 0,0642 ms
01-14 17:50:37.110 I/mono-stdout(29658): Draw time: 17,8817 ms
FPS: 49
Update time: 0,0623 ms
Draw time: 11,5024 ms
01-14 17:50:37.127 I/mono-stdout(29658): FPS: 49
01-14 17:50:37.128 I/mono-stdout(29658): Update time: 0,0623 ms
01-14 17:50:37.128 I/mono-stdout(29658): Draw time: 11,5024 ms
FPS: 49
Update time: 0,0616 ms
Draw time: 16,7472 ms
01-14 17:50:37.148 I/mono-stdout(29658): FPS: 49
01-14 17:50:37.149 I/mono-stdout(29658): Update time: 0,0616 ms
01-14 17:50:37.149 I/mono-stdout(29658): Draw time: 16,7472 ms
FPS: 49

I would have to give it a test at home. I don’t have access to a HTC One M9, but I haven’t seen this kind of performance issue on other Android devices I have.

The timing does look roughly like it is being locked to 60fps though (16ms per frame).

That’s what I thought initially, but the “draw time” that I displayed here is only for the GraphicsDevice.Clear() function. If the call of the clear function exceed 16ms (so doing nothing), I can’t expect running my entire game at 60FPS… :’(

Hello again everyone.

I had access to some Android devices, so I’ve been able to do some tests with the simple application that I posted in my original post (I’ve also posted an APK file on the repo => here) and here is what I got:

HTC One M9 (Android 7.0)

  • Average FPS: 49
  • Average update time: 0.03ms
  • Average draw time: 13ms

Samsung Galaxy S7 (Android 6.0.1)

  • Average FPS: 59
  • Average update time: 0.03ms
  • Average draw time: 10ms

Samsung Galaxy S6 (Android 6.0.1)

  • Average FPS: 59
  • Average update time: 0.03ms
  • Average draw time: 8ms

Samsung Galaxy S5 (Android 6.0.1)

  • Average FPS: 59
  • Average update time: 0.01ms
  • Average draw time: 0.1ms

Samsung Galaxy S4 (Android 4.4.4)

  • Average FPS: 60
  • Average update time: 0.03ms
  • Average draw time: 0.1ms

Nexus 4 (Android 4.4.3)

  • Average FPS: 60
  • Average update time: 0.03ms
  • Average draw time: 0.1ms

My device has definitely a problem, but I’m also surprised about how high is the average draw time for recent devices like the Samsung Galaxy S6 or S7 :open_mouth:

hey, try this out

public Game1()
        {
          _graphics = new GraphicsDeviceManager(this);
            _graphics.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = true;

[...]

}

Don’t you mean IsFixedTimeStep = false?

Don’t you mean IsFixedTimeStep = false?

no. In my experience even if the game would run with 2000 fps it will not give me consistent 60 Hz with VerticalRetrace, which is ridiculous, since I can prove that none of the 2000 frames took longer than 16.66ms. FixedTimeStep does this a little better.

1 Like

Thanks for your answers.

I didn’t specify it, but I had these line uncommented in the tests above:

IsFixedTimeStep = false;
graphics.SynchronizeWithVerticalRetrace = false;

Using:

IsFixedTimeStep = true;
graphics.SynchronizeWithVerticalRetrace = false;

Seems to lead to the same situation, at least on my HTC One M9. :’(