summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/systemui/UiOffloadThread.java
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2017-05-15 02:40:05 +0200
committerJorim Jaggi <jjaggi@google.com>2017-05-18 00:06:34 +0200
commitfabc743bcf6e6623e530545c4b31285ea642f087 (patch)
treef321cf173d3e457a4cc8e4e42bf96a485afc7c4f /packages/SystemUI/src/com/android/systemui/UiOffloadThread.java
parent64766b86ab42d7e4da876dbaacf8d8eeb66b1cb3 (diff)
Optimize latency when unlocking phone
Latency when unlocking the phone regressed a bit for two reasons: - For lockscreen -> app we now have to create a full starting window containing the snapshot, while previously this was just showing a surface. - For lockscreen -> home, we can't use the saved surface anymore because currently we don't support snapshotting translucent activities. However, in the long term, we want home screen to be more involved into transitions anyways, so we'll have to wait for the first frame draw anyways. However, crystal ball trainee developer Jorim added some artificial latency in this transition 3 years ago, because he knew that it is going to be an issue at some point so we have some headroom to improve! Genius! On a more serious note, it was because he didn't understand how to read systraces with binders involved (to be fair, there was also no binder tracing). Now, we can completely fix the introduces latencies above by removing this latency of 100ms, and we are 30-70ms better than before! However, this requires a lot of discipline in SystemUI. Currently, the callback to dismiss Keyguard takes around 30ms. By moving all non-essential binder calls of the main thread or to the next frame, we bring this down to 5ms, such that window animation and Keyguard animation starts about at the same time. Test: Take systrace, unlock phone...profit! Change-Id: I3ea672bc2eca47221bc6c9f3d7c56b6899df207d Fixes: 38294347
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/UiOffloadThread.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/UiOffloadThread.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/UiOffloadThread.java b/packages/SystemUI/src/com/android/systemui/UiOffloadThread.java
new file mode 100644
index 000000000000..82fd9b304195
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/UiOffloadThread.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.systemui;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/**
+ * Thread that offloads work from the UI thread but that is still perceptible to the user, so the
+ * priority is the same as the main thread.
+ */
+public class UiOffloadThread {
+
+ private final ExecutorService mExecutorService = Executors.newSingleThreadExecutor();
+
+ public Future<?> submit(Runnable runnable) {
+ return mExecutorService.submit(runnable);
+ }
+}