Hi,
So I have button for moving player. When I touched it, I got some delay response on player movement about 100 - 200 ms. I’ve tried some common possibilities to increase my game performance like using object pooling, disabling unnecessary objects when not in use, avoid calling Find functions per frame, dynamic batching.
You can have a look at this video about the slight delay at the character movement when I touched the button.
Or maybe that video is not really clear for you, I provided the .apk file here if you are willing to play it.
And this is a picture of the profiler I attached to the android device. I captured this while touching the button.
So what could be the cause of this problem ?
I really hope that it’s not the unity itself nor the device because some people said that It can’t be fixed if that’s the case.
Thanks.
Hi.
You can find detailed description here.
As I watch your video, there is a gap between android internal touch mark appearing and game character’s movement.
The touch mark is came from android system server.(InputReader)
So the gap unwillingly exists, But I am not sure this situation is best.
I measured the delay between driver event to UnityScript event. (by subtracting time between two event)
On my galaxy s6, the delay was 14 ~ 26ms.
I measured Unity script event time by this code.
static double getUptimeMillis() {
var ticks = Stopwatch.GetTimestamp();
var uptime = ((double)ticks) / Stopwatch.Frequency;
var uptimeSpan = TimeSpan.FromSeconds(uptime);
return uptimeSpan.TotalMilliseconds;
}
void Update() {
for (var i = 0; i < Input.touchCount; ++i) {
var touch = Input.GetTouch(i);
if (touch.phase == TouchPhase.Began) {
UnityEngine.Debug.Log("touch time: " + getUptimeMillis());
}
}
}
And measured driver event time using getevent -tl.
Thank you.
===== added ====
I am also finding solution for same issue.
And the touch panel lag and android event system lag seems unavoidable, I guess.
I think one of possible solution is disabling triple buffering (opened thread)
So I was right. If I read at the documentation about QualitySettings.maxQueuedFrames, the downside of setting it to 1 we will get low framerate.
And also when I did some googling, I found that there is a guy who tells that it also because the hardware.
@Kalita2127 in your profiling screenshots, did you investigate the spikes?
Yeah I did. As far as I remember, It’s not on the script problem.
You are mentioning 100ms delays, and see huge spikes in the profiler - looks like #1 to investigate for me.
So I did checking the profiler again and it seems those spikes was Gfx.WaitForPresent. What is that thing ?