This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
19 changed files
with
233 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/SystemUI/src/com/android/systemui/UiOffloadThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.