- Home /
Performance spikes even with almost empty scene
I'm getting tired of absence of smoothness when application is playing. I've tried yet another test to check if it just me doing lame scripts.
Create new project, add one directional light and one cube in it. Scale cube 4 times big. Then create a script (one of 'JavaScript', because what if C# is the issue?) and write there:
#pragma strict
function Update () {
this.transform.Rotate(0, 0, 90 * Time.deltaTime);
}
Put it on the cube. This is it, now you could:
Run it in editor
Build an android apk and run it on a device (I'm using Tegra3-equipped one)
Build a standalone app and run it separately.
Tracking cube rotation with your eyes you will (or will not) see periodic twitching. It is not too (but still) noticeable on my i5 CPU, but very noticeable on Android. Such a simple scene, what could be wrong and make it not to run smoothly?
And in real application, when there is actually some work to doo, it became even more annoying. Small twitches but ruins all smoothness.
How could I handle it?
what about if you use fixedupdate ins$$anonymous$$d, maybe its your pc performance effecting the cube
On my PC it's taking 0.0ms to render and up to 0.3ms for main thread, resulting in about 3800 fps if not limited. No matter if I put Unity on last two cores (of 4) and set maximum priority to it. However, PC barely will affect to Android device's performance. On PC that twitches at least not too noticeable, unlike while running on Android.
What about Vsync? I'm not sure if this has anything to do with it, but throwing it out there. Because I've noticed that when I had Vsync off, things in my scene were jittery and a bit choppy. When I turned Vsync on, it smoothened things out.
Really not sure if that applies at all to you, though.
No it doesn't matters. I've played around with vsync, vsync/2, with targetFrameRate, even if I set maximum fps to 30, it doesn't feel smooth. Cube still rotates unevenly, although most of that spikes probably must have been absorbed by long sleep period between frames.
Answer by klodha83 · May 21, 2014 at 12:41 PM
Instead of scaling cube to 4 time big, have you tried using a model created of that size itself? Scaling object is sometime overkill, specially if those aren't static.
Btw, I don't think there is any issue with C# or Javascript.
Okay, I did scale down cuve to it's normal size, adjusting camera FOV to maintain cube's visible size. It didn't changed anything.
Answer by mikhail111777 · May 21, 2014 at 04:16 PM
Creating a cube from editor adds a box collider without a rigidbody. As far as I can see, you are trying to move it by modifying GameObject.transform, and you also scale the cube.
Physics on Android will randomly hiccup in any of these cases, and you have three of them at once.
I've deleted collider component from that cube. Nothing changed.
Answer by jamie lowes · Jun 25, 2014 at 09:56 PM
On the Android build, try moving your finger around the screen somewhere. My test app runs perfectly if the phone thinks the player is interacting. Let go and the stutter comes back. My example scene is drawing just 10 sprites.
Your answer
Follow this Question
Related Questions
Problem with the performance when activating gameObject 0 Answers
Performance Spikes in Unity in Profiler 0 Answers
Unity UI Slowing Down Android Phone 0 Answers
Forced FPS? 1 Answer
Is variable framerate acceptable? 1 Answer