- Home /
Massive performance decrease in 3.4 / Device.Present taking large amounts of time
We have been working on a game over the past few months in unity 3.3 Recently we updated to 3.4, and XCode4, to take advantage of the updates to Unity 3.4. Fortunately, the game runs the same as it did before in terms of functionality, so nothing appears to have broken there. Unfortunately, our performance on the iPhone 4 has gone from around 30fps to around 3fps.
When running the profilers, the best result we can come up with is that Device.Present looks a little odd. Here are its stats:
Device.Present Total: 82.1% Self: 82.1% Calls: 1 Memory: 0B Time ms: 37.94 Self ms: 37.94
Reading through other profilers and reviewing code, everything else looks good. Since we've made no code changes - outside of updating the Prime31 plugins we use, SocialNetworking and GameCenter, to their latest versions, we're rather stumped on what could have broken in the product. We have reviewed things like the Quality and made sure its settings were the same as before. We are willing to bet a property or setting somewhere is new or changed from what we had it set to in 3.3 which is now causing this huge performance drop, we're just a bit stumped now on where to look.
Any suggestions, recommendations or support we could get on this matter would be wonderful. Thank you in advance!
Answer by RedVonix · Aug 17, 2011 at 07:32 PM
As it turns out, we hade to modify our shader code. The same shaders that had very little performance impact in 3.3 had massive performance impact on iOS in 3.4. So if you are stuck, check there. Also, in AppController.mm, change this:
define USE_OPENGLES20_IF_AVAILABLE 1
To this:
define USE_OPENGLES20_IF_AVAILABLE 0
Which we found also gave us a significant FPS increase (nearly doubled our framerate on iOS).
WOW! I just found this and flipping this flag got us like a 10x perf increase. THAN$$anonymous$$S for posting this.
I was dealing with the same DEVICE_PRESENT stuff.
Thanks for sharing this. Please be kind and mark your answer as the accepted solution, so that the question can be found as solved!
Hi I got this problem and it is still there and its driving us crazy after setting that flag and replacing it with custom shaders. I was wondering as well what type of shader are you using ? is it custom or the unity mobile ? Because apparently some places they say that shaders could be culprit. If you have any other suggestions any help would be great !
Answer by mastermax001 · Apr 11, 2013 at 04:02 PM
big thanks to DCalabrese, you saved my work!
BTW, just a little note about Unity4: now AppController doesnt have anymore "define USE_OPENGLES20_IF_AVAILABLE 1" but for fixing the device.present problem you can just change the Graphics Level on Player Settings from OpenGLES 2.0 to OpenGLES 1.0.
Enjoy!
Answer by Leon700 · Oct 06, 2016 at 07:02 PM
In 5.4 uncheking the "Auto Graphics API " ( in player settings) and deleting GLES3 Gave me back a few FPS
Answer by roamcel · Aug 05, 2011 at 09:53 AM
I have noticed that 3.4 adds some pragmas to certain scripts when you upgrade a 3.3 or older project, to avoid unsafe code in javascript. The only thing I can think off is that you might have developed using 'unsafe' (by 3.4's new standard) variable declaring, and that maybe unity is just trying hard to avoid crashes and such, since your scripts might not be headed with the new required pragmas. I suggest you dig into the new pragma statemens introduced in 3.4, and deduce if they might be the cause. Hopefully you'd just need add those lines to fix the performance drop.
Another thing you can try: compare your scripts (pain in the ass, but could be worth it) from a backup of your 3.3 project version, and from a 3.4 fresh import version.
We have a project which is scripted in C# only. But because of Device.Present we have only 5 fps on iPad. And it is and Unity 3.3 project, not 3.4
Sorry but it seems I misunderstood the situation. Good luck in finding a solution.