Hello forum, get ready for a bunch of new newbie questions here
While creating my game i thought , -“Its time to optimize performance for everybody who may be wanna play this” . So i decided to do all i could to give my game good fps and low memory usage. My target platform is Android, game use 3d “Crossy road” like graphic
What i did:
I did object pooling and this definately gave me 15-20 fps and less lags while playing
Did set as much object as can be to “static mode” which honestly didnt give me a lot, but still some +
Checked scripts for update calls and set target fps limit to 60, to avoid overusing cpu - that gave me a lot, phone stopped use so much energy, still its big enough but playable
Removed real-time lights to baked - good improvement but still i have one serious issue…
As you can see i have spikes in GPU in “Other line” as well as in Memory in “Mesh Memory line” and only this cause mini lags to my game. For example, while playing, you have 60 fps and then suddenly its dropping in these very spikes like twitching or something, exept that, game run smoothly.
So only this performance problem left for me to be solved and im asking for help, how i can solve this? Or at least what possibly can be solved to get rid of this twitches?
Check out the CPU as well as a script there is probably triggering the drawing load update that you’re seeing on the GPU, best to use Deep profiling to help find these issues.
It looks like something is updating regularly, are you updating a graphical or UI element at intervals e.g. via a timer or invokeRepeat?
“It looks like something is updating regularly” - thats what i was thinking, but its seems not, after i did below thats not the problem
First, i checked all srpts for updates, only 2 have such calls, so i turned them off that didnt help so i decided to do this in a hard way)) I removed all objects(canvas including) except camera(turned off all camera scripts ofcourse) and still have such spikes, and then i noticed somethnig like this(look at mesh count):
If anybody very interested in this i can give link to dropbox for project files (its about 30 mb, not too much), may be someone else can figure out whats happening here, anyway i want to post this game as example to new ones here, how game must not be done
OK there is the halving rule for searching for something.
You disable half the things in the scene test and see if the hiccup is there:
Yes - Half again and repeat.
No - Enable the disabled half, disable the enabled half and repeat.
After just a few tests even with thousands of things you will find the culprit.
e.g. 1028 things
Test 1 - 512
Test 2 - 256
Test 3 - 128
Test 4 - 64
Test 5 - 32
Test 6 - 16
Test 7 - 8
Test 8 - 4
test 9 - 2
Test 10 - 1 - Found it.
Isnt this wrong?>>>
I created new project from scratch, and i have exct same thing with only camera and light there. Can these hiccups be from profiler itself? But then why this lag still appears on the phone? Spooky things going on as for me…(and yeah meshes still spiking in empty scene, why so?)
Is it a good suggestion to try my project on another computer and see whts what? or it doesnt matter at all? - this did nothing
Sad update
I asked my friend to install unity on his new laptop and check everything. Guess what, that lag still exist even on new freshly installed unity client, there is still that spike in gpu and memory causing .ms to rise up from 7-9 to 30-50 ms on spikes(just empty scene on simple quality graphic settings). May be i did something terribly wrong during my gamemaking idnt honestly i cant even imagine how i can fix that
May be one thing left to try, find previous version of unity 4.x and try my best on that version?*
Update*
After some searching i found GFX.Waitforpresent call which it seems causing my spike and as i see its REALLY a bug, but the worst thing…get ready… this bug known since 2013 year!! This is absolutely ridiculious how it can be so?
Someone in an older thread mentioned it wasn’t present in Unity 4.2. Just keep in mind that Unity 5.x is when they started giving full engine features for free. Unity 4.x will still be very restrictive.
That said what you’re encountering isn’t technically a bug. The GFX.WaitForPresent function basically halts the main thread until the GPU has finished processing the current frame. It appears to be a part of the vsync process.
I’d start by trying to disable vsync and possibly setting the application expected framerate to 60.
Alternatively you can reduce the load you’re putting on the graphics hardware as this seems to be an indication that an application is too graphically heavy for the GPU to keep up with the CPU.
Yeah all this i already saw in this thread (firstly i tried to disable vsync but that gave nothing)http://forum.unity3d.com/threads/gfx-waitforpresent.211166/page-4 and even get lag less noticable and i do understand its not really a bug cause its all about waiting cpu and working gpu but if i cant somehow solve this i must choose version where this wasnt a problem
You willnot believe)) I already did that and even disabled vsync thru script, nothing of that helps to remove this, but slightly improve stability, only 1 thing left to try on scene side, its to combine meshes, but as i already mentioned even in empty scenes i have such spikes, so i assume this willnot really help
UPDATE***!
I just get unity4.6 version and there is no spike at least in empty scene, will give update after migrate my project there*
Halleluya! After i downloaded 4.6.1 version of Unity and loaded my project, i get sweet average 0.67ms and max 2ms on spikes , but thats only in editor itself, will update how game playing on my android device soon.
So yeah… this bug sucks and kill all game entirely no matter how much u trying to optimize it.
Now interesting side, what im curious about is, why there is mesh spike that causing these hiccups and what unity devs possibly did to cause this mesh spike in unity5.x versions? Discuss?
After tested 4.6 version build on android phone hiccups still appears, but most intersting thing, profiler dont show any fps spikes at all. Is this real life? What i did wrong cant get an idea even…
Is it possible to find any kind developer, without such problem who can build apk file to see if this problem still appears?
Didnt find solution of this problem, so everything i can do now is only vote for this ticket below and delete Unity. Best luck to all others in avoiding this issue, goodbye unity forum:
I’ve been working on Android too, and I noticed some performance issues that seemed to show up after adding Unity Ads.
Also, you might want to be sure your Android isn’t doing some other weird stuff while your game is running (i.e. running Trivia Crack or Candy Crush or trying to find aliens for NASA)
No, no any ads, all problems coming from unity itself i tested framework on 4 (CARL, FOUR!) different machines(nvidia or radeon included) and in all scenes from scratch on fastest quality settings i keep getting these spikes on android and in the editor itself (only 1 time i terminated this but only in profiler, that he shows absolutely no spike and smooth ms, but on android there is still this lag( tested on 3 various phones HTC,Samsung and some tablet))
As i said previously only thing left is find anybody with machine without such bug and ask him for build apk file, thats all.