Device.present causing unexplainable slowdown
Hello. I've been working on an Android game for some weeks now and i am facing the following problem. Right now the game consists of 3 scenes: Splash, Story and Game. Sometimes the game will launch just fine, achieving a smooth 60fps from the Story to the Game Scene. Other times the game will launch with a terrible 15fps, which the profiler shows is mostly due to device.present taking up to 80%. That can happen if i terminate the app completely and i also recall it happening even when the phone screen dims while on Story and i press to wake it up. The slow fps will continue through to the Game scene. I know similar questions have been asked before, but i haven't find someone else reporting such inconsistent behavior.
Unity version is 5.4.0f3 and the testing device is a Galaxy Note 5. I am using Application.targetFrameRate= 60fps. Below are 2 screenshots of the Profiler window, taken at roughly the same time into the game, showing the difference i'm talking about.
Thank you in advance
Device.present doesn't look like a function that should be called every time. Are you calling it yourself in your code? If not, maybe you can find out where it is used.
Answer by xkatrakis · Sep 16, 2016 at 11:07 PM
Turns out that even for simple scenes the standard shaders are really cutting away performance. Replaced all shaders with mobile ones, also put the default sprite material on the sprites that didn't have one (not sure if that helped at all) and i'm back at 60 fps!
Thank you! With this tip I went from 15 fps to 30 fps. Still a ways to go but that was very helpful.
Answer by IgorAherne · May 31, 2018 at 03:32 AM
Yep, also check this out (post #7) https://forum.unity.com/threads/device-present-in-profiler-what-the-deal.86312/#post-556133
Answer by tdx110 · Feb 10, 2021 at 05:26 PM
I found the solution! In Build Setting furn off: 1.Deep Profiling Support 2. Script Debugging!
I think Device.present is when compiling for preview. If you disable Developmen Build it will work normally.
PS: If you disable Autoconnect Profiler Game run faster! Much faster. If You disable Debug mode to Relase game go much better.