[Solved] Android game freezing, if do NOT touch the screen

Hello everyone,

I discovered strange lags on the Mezu m5 Note (Android version 7.0). Unity version 2018.1.5f1. If I hold my finger on the screen, or do not touch the screen at all, then the frame rate in my game starts jumping. But as soon as I make a new touch (we can say that Touch phase == TouchPhase.Began), the FPS becomes stable for a few seconds. If I constantly tap on the screen, I will have a stable 60 frames with a large margin in the form of WaitForTargetFPS. But as soon as I do not touch the screen for a few seconds, or leave a finger on the screen, I immediately get very noticeable freezes. After reviewing the profiler, you can see that every time the lags are caused by different things. It seems to me that Android slows down my game. I looked at the CPU load, a few seconds after touching the processor load reaches 42-47%, but then the load drops to 32-36% and the freezes begin. It would not bother me if it happened only when there were no touches at all, but this happens when I hold my finger on the screen and, for example, control the on-screen joystick.

It doesn’t look like temperature throttling since the temperature of the device is lower than in some other games that give out 60 FPS. During freezes, the GPU is busy RenderForwardOpaque.Render => Clear and Device.Present

The device is at maximum performance mode. TargetFrameRate is 60. The load on the phone is minimal. DrawCalls: 9-18. Tris: 1-3k.V sync is off . Mobile shaders. Disabled all that is possible. Uses the worst picture Unity can produce. I even put a fixed dpi in the region of 80. The result does not change.

I tried various combinations of settings “other settings”, turned off and turned on dynamic and static batching, multi-threaded rendering.

I hardly found branches on forums with a similar situation, people did not help there: (

https://stackoverflow.com/questions/30817626/unity3d-android-game-when-i-dont-touch-the-screen-my-fps-are-lower-than-when?rq=1

I added “Screen.sleepTimeout = SleepTimeout.NeverSleep”. But that didn’t help either.

Help! I do not know which side to approach this problem.
Attached archive has profiler data file and profiler screenshots

Thank you in advance!

3749023–311602–Freezes_Image&Profiler.rar (1.88 MB)

UPDATE
I have made significant progress in resolving this issue. I found the option when spikes proapaday and the game becomes smooth. I made a fixed DPI and set the graphics settings in my game to high (I used to test at minimum settings) and got a smooth picture. The FPS stabilized a bit when I prioritized the graphics API (Vulcan → OpenGL3 → OpenGL2) in conjunction with multi-threaded rendering, but I am not sure how much this helped. And the increased graphics settings immediately freed me from the spikes.

The graphics settings in my game control such things as: visual and UI effects, selection of quality settings, activation and deactivation of objects, some things in scripts, and so on.
The fact that disabling various effects on the camera and on the UI, deactivating the clock system and setting the fastest quality settings, leads to friezes - at first glance it’s very strange.

The fact that I have achieved a smooth image, albeit with a DPI equal to 100, will allow us to find the root of the problem. I will try to concretize the problem.

I also found similar problems in people for requests: “gpu spikes”, “android spikes profiler”, “gpu device present”, “gpu device present”, etc.

[solved]
I have achieved stability!

Everything was simple, it was in V sync. It had to be turned on (although it is advised to turn it off in all such discussions). In my case, it seems that if the phone did not receive a frame for drawing several times, then he thought that the application consumes a large number of resources (the GPU, most likely) without doing anything, and Android allocated less resources to the application. Thanks to V sync, the phone didn’t see any reason to slow down my game and the spikes were gone. I am sure that this is not exactly what happened, but it roughly describes the essence of the problem.

Hope this helps someone!

3 Likes

I’m having this problem on a commercial stand and enabling the v-sync didn’t help me

I am also seeing this problem. Adding V Sync definitely helped, but I still see the issue after some minutes of no touching.