From 4cdce427f9ba0339ac7c58fdb4f56ac3630abf34 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Thu, 25 Jun 2015 13:08:14 -0700 Subject: Fix janky navbar ripples -- incorrect timerslack values If a thread is created while the parent thread is "Background", then the default timerslack value gets set to the current timerslack value of the parent (40ms). The default value is used when transitioning to "Foreground" -- so the effect is that the timerslack value becomes 40ms regardless of foreground/background. This does occur intermittently for systemui when creating its render thread (pretty often on hammerhead and has been seen on shamu). If this occurs, then some systemui animations like navbar ripples can wait for up to 40ms to draw a frame when they intended to wait 3ms -- jank. This fix is to explicitly set the foreground timerslack to 50us. A consequence of setting timerslack behind the process' back is that any custom values for timerslack get lost whenever the thread has transition between fg/bg. See Bug: 19398120 Change-Id: Idc259717f62fa2255f8bafbbf88b68c0043f29cf --- libcutils/sched_policy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libcutils') diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c index a7ff85e..1ffe872 100644 --- a/libcutils/sched_policy.c +++ b/libcutils/sched_policy.c @@ -50,6 +50,7 @@ static inline SchedPolicy _policy(SchedPolicy p) // timer slack value in nS enforced when the thread moves to background #define TIMER_SLACK_BG 40000000 +#define TIMER_SLACK_FG 50000 static pthread_once_t the_once = PTHREAD_ONCE_INIT; @@ -356,7 +357,8 @@ int set_sched_policy(int tid, SchedPolicy policy) ¶m); } - prctl(PR_SET_TIMERSLACK_PID, policy == SP_BACKGROUND ? TIMER_SLACK_BG : 0, tid); + prctl(PR_SET_TIMERSLACK_PID, + policy == SP_BACKGROUND ? TIMER_SLACK_BG : TIMER_SLACK_FG, tid); return 0; } -- cgit v1.1