diff options
| author | Riddle Hsu <riddlehsu@google.com> | 2020-10-30 15:07:28 +0800 |
|---|---|---|
| committer | Riddle Hsu <riddlehsu@google.com> | 2020-11-02 16:41:14 +0800 |
| commit | 3213c9657b88e9d2d0d6f529e1a63bb30ff42cdc (patch) | |
| tree | 9521f16f51edc69772bce69e0f5671cf0f7703c2 /core/java | |
| parent | f2d1d264793831f07b689e534366fb55f12174cc (diff) | |
Reduce unnecessary invocation of setInputWindowInfo
Usually most fields of InputWindowHandle don't change frequently.
Therefore, only the changed instances need to be updated. That
reduces the overhead of JNI invocation (especially
NativeInputWindowHandle::updateInfo which may be called from
setInputWindowInfo).
There should be no behavior change.
- Add a InputWindowHandle.ChangeDetectionWrapper to wrap the original
handle. So the changes of its fields can be tracked.
- Make InputApplicationHandle java side immutable. Its content should
be rarely changed. Then it is easier to compare by instance. This
might also reduces the race condition of accessing its field from
InputDispatcher because the instance is different.
- Move some fields that won't change of InputWindowHandle to the
constructor of WindowState to reduce unnecessary updates.
- When a window cannot receive input, reuse the per-window input
window handle to populate the disabled info, so there won't be a
shared instance that its fields always need to be updated.
- Reduce unnecessary Region#translate if the offsets are zero.
- For a simple activity launch, the invocation amount of
setInputWindowInfo is reduced 90% (from 126 to 11).
- The metrics updateInputWindows_mean of WmPerfTests is reduced 50%+
(from 0.89ms to 0.38ms on an old mid-end device).
Bug: 168008622
Test: WindowStateTests#testUpdateInputWindowHandle
WindowInputTests InternalWindowOperationPerfTest
Change-Id: Ief84bbe6e6fa4da5309912059904932ccf775b75
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/InputApplicationHandle.java | 12 | ||||
| -rw-r--r-- | core/java/android/view/InputWindowHandle.java | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/core/java/android/view/InputApplicationHandle.java b/core/java/android/view/InputApplicationHandle.java index 108345e6db0e..4abffde68ffd 100644 --- a/core/java/android/view/InputApplicationHandle.java +++ b/core/java/android/view/InputApplicationHandle.java @@ -16,6 +16,7 @@ package android.view; +import android.annotation.NonNull; import android.os.IBinder; /** @@ -31,17 +32,20 @@ public final class InputApplicationHandle { private long ptr; // Application name. - public String name; + public final @NonNull String name; // Dispatching timeout. - public long dispatchingTimeoutMillis; + public final long dispatchingTimeoutMillis; - public final IBinder token; + public final @NonNull IBinder token; private native void nativeDispose(); - public InputApplicationHandle(IBinder token) { + public InputApplicationHandle(@NonNull IBinder token, @NonNull String name, + long dispatchingTimeoutMillis) { this.token = token; + this.name = name; + this.dispatchingTimeoutMillis = dispatchingTimeoutMillis; } public InputApplicationHandle(InputApplicationHandle handle) { diff --git a/core/java/android/view/InputWindowHandle.java b/core/java/android/view/InputWindowHandle.java index d1a9a05d5bf1..5a34a92a4b1a 100644 --- a/core/java/android/view/InputWindowHandle.java +++ b/core/java/android/view/InputWindowHandle.java @@ -37,7 +37,7 @@ public final class InputWindowHandle { private long ptr; // The input application handle. - public final InputApplicationHandle inputApplicationHandle; + public InputApplicationHandle inputApplicationHandle; // The token associates input data with a window and its input channel. The client input // channel and the server input channel will both contain this token. |
