Merge "Add traces for waitForAllWindowsDrawn logic" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fc9878c103
@@ -329,6 +329,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
static public final String SYSTEM_DIALOG_REASON_SCREENSHOT = "screenshot";
|
static public final String SYSTEM_DIALOG_REASON_SCREENSHOT = "screenshot";
|
||||||
static public final String SYSTEM_DIALOG_REASON_GESTURE_NAV = "gestureNav";
|
static public final String SYSTEM_DIALOG_REASON_GESTURE_NAV = "gestureNav";
|
||||||
|
|
||||||
|
public static final String TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD = "waitForAllWindowsDrawn";
|
||||||
|
|
||||||
private static final String TALKBACK_LABEL = "TalkBack";
|
private static final String TALKBACK_LABEL = "TalkBack";
|
||||||
|
|
||||||
private static final int POWER_BUTTON_SUPPRESSION_DELAY_DEFAULT_MILLIS = 800;
|
private static final int POWER_BUTTON_SUPPRESSION_DELAY_DEFAULT_MILLIS = 800;
|
||||||
@@ -4724,10 +4726,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
|
|
||||||
// ... eventually calls finishWindowsDrawn which will finalize our screen turn on
|
// ... eventually calls finishWindowsDrawn which will finalize our screen turn on
|
||||||
// as well as enabling the orientation change logic/sensor.
|
// as well as enabling the orientation change logic/sensor.
|
||||||
|
Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER,
|
||||||
|
TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD, /* cookie= */ 0);
|
||||||
mWindowManagerInternal.waitForAllWindowsDrawn(() -> {
|
mWindowManagerInternal.waitForAllWindowsDrawn(() -> {
|
||||||
if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for every display");
|
if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for every display");
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE,
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE,
|
||||||
INVALID_DISPLAY, 0));
|
INVALID_DISPLAY, 0));
|
||||||
|
|
||||||
|
Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER,
|
||||||
|
TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD, /* cookie= */ 0);
|
||||||
}, WAITING_FOR_DRAWN_TIMEOUT, INVALID_DISPLAY);
|
}, WAITING_FOR_DRAWN_TIMEOUT, INVALID_DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4783,10 +4790,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mScreenOnListeners.put(displayId, screenOnListener);
|
mScreenOnListeners.put(displayId, screenOnListener);
|
||||||
|
|
||||||
|
Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER,
|
||||||
|
TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD, /* cookie= */ 0);
|
||||||
mWindowManagerInternal.waitForAllWindowsDrawn(() -> {
|
mWindowManagerInternal.waitForAllWindowsDrawn(() -> {
|
||||||
if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display: " + displayId);
|
if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display: " + displayId);
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE,
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE,
|
||||||
displayId, 0));
|
displayId, 0));
|
||||||
|
|
||||||
|
Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER,
|
||||||
|
TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD, /* cookie= */ 0);
|
||||||
}, WAITING_FOR_DRAWN_TIMEOUT, displayId);
|
}, WAITING_FOR_DRAWN_TIMEOUT, displayId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ import static com.android.internal.protolog.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
|
|||||||
import static com.android.internal.util.LatencyTracker.ACTION_ROTATE_SCREEN;
|
import static com.android.internal.util.LatencyTracker.ACTION_ROTATE_SCREEN;
|
||||||
import static com.android.server.LockGuard.INDEX_WINDOW;
|
import static com.android.server.LockGuard.INDEX_WINDOW;
|
||||||
import static com.android.server.LockGuard.installLock;
|
import static com.android.server.LockGuard.installLock;
|
||||||
|
import static com.android.server.policy.PhoneWindowManager.TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD;
|
||||||
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
|
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
|
||||||
import static com.android.server.wm.ActivityTaskManagerService.POWER_MODE_REASON_CHANGE_DISPLAY;
|
import static com.android.server.wm.ActivityTaskManagerService.POWER_MODE_REASON_CHANGE_DISPLAY;
|
||||||
import static com.android.server.wm.DisplayContent.IME_TARGET_CONTROL;
|
import static com.android.server.wm.DisplayContent.IME_TARGET_CONTROL;
|
||||||
@@ -355,6 +356,7 @@ import java.util.function.Supplier;
|
|||||||
public class WindowManagerService extends IWindowManager.Stub
|
public class WindowManagerService extends IWindowManager.Stub
|
||||||
implements Watchdog.Monitor, WindowManagerPolicy.WindowManagerFuncs {
|
implements Watchdog.Monitor, WindowManagerPolicy.WindowManagerFuncs {
|
||||||
private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowManagerService" : TAG_WM;
|
private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowManagerService" : TAG_WM;
|
||||||
|
private static final int TRACE_MAX_SECTION_NAME_LENGTH = 127;
|
||||||
|
|
||||||
static final int LAYOUT_REPEAT_THRESHOLD = 4;
|
static final int LAYOUT_REPEAT_THRESHOLD = 4;
|
||||||
|
|
||||||
@@ -5442,10 +5444,15 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
case WAITING_FOR_DRAWN_TIMEOUT: {
|
case WAITING_FOR_DRAWN_TIMEOUT: {
|
||||||
Runnable callback = null;
|
Runnable callback = null;
|
||||||
final WindowContainer container = (WindowContainer) msg.obj;
|
final WindowContainer<?> container = (WindowContainer<?>) msg.obj;
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
ProtoLog.w(WM_ERROR, "Timeout waiting for drawn: undrawn=%s",
|
ProtoLog.w(WM_ERROR, "Timeout waiting for drawn: undrawn=%s",
|
||||||
container.mWaitingForDrawn);
|
container.mWaitingForDrawn);
|
||||||
|
if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
|
||||||
|
for (int i = 0; i < container.mWaitingForDrawn.size(); i++) {
|
||||||
|
traceEndWaitingForWindowDrawn(container.mWaitingForDrawn.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
container.mWaitingForDrawn.clear();
|
container.mWaitingForDrawn.clear();
|
||||||
callback = mWaitingForDrawnCallbacks.remove(container);
|
callback = mWaitingForDrawnCallbacks.remove(container);
|
||||||
}
|
}
|
||||||
@@ -6052,10 +6059,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
// Window has been removed or hidden; no draw will now happen, so stop waiting.
|
// Window has been removed or hidden; no draw will now happen, so stop waiting.
|
||||||
ProtoLog.w(WM_DEBUG_SCREEN_ON, "Aborted waiting for drawn: %s", win);
|
ProtoLog.w(WM_DEBUG_SCREEN_ON, "Aborted waiting for drawn: %s", win);
|
||||||
container.mWaitingForDrawn.remove(win);
|
container.mWaitingForDrawn.remove(win);
|
||||||
|
if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
|
||||||
|
traceEndWaitingForWindowDrawn(win);
|
||||||
|
}
|
||||||
} else if (win.hasDrawn()) {
|
} else if (win.hasDrawn()) {
|
||||||
// Window is now drawn (and shown).
|
// Window is now drawn (and shown).
|
||||||
ProtoLog.d(WM_DEBUG_SCREEN_ON, "Window drawn win=%s", win);
|
ProtoLog.d(WM_DEBUG_SCREEN_ON, "Window drawn win=%s", win);
|
||||||
container.mWaitingForDrawn.remove(win);
|
container.mWaitingForDrawn.remove(win);
|
||||||
|
if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
|
||||||
|
traceEndWaitingForWindowDrawn(win);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (container.mWaitingForDrawn.isEmpty()) {
|
if (container.mWaitingForDrawn.isEmpty()) {
|
||||||
@@ -6066,6 +6079,22 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void traceStartWaitingForWindowDrawn(WindowState window) {
|
||||||
|
final String traceName = TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD + "#"
|
||||||
|
+ window.getWindowTag();
|
||||||
|
final String shortenedTraceName = traceName.substring(0, Math.min(
|
||||||
|
TRACE_MAX_SECTION_NAME_LENGTH, traceName.length()));
|
||||||
|
Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, shortenedTraceName, /* cookie= */ 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void traceEndWaitingForWindowDrawn(WindowState window) {
|
||||||
|
final String traceName = TRACE_WAIT_FOR_ALL_WINDOWS_DRAWN_METHOD + "#"
|
||||||
|
+ window.getWindowTag();
|
||||||
|
final String shortenedTraceName = traceName.substring(0, Math.min(
|
||||||
|
TRACE_MAX_SECTION_NAME_LENGTH, traceName.length()));
|
||||||
|
Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, shortenedTraceName, /* cookie= */ 0);
|
||||||
|
}
|
||||||
|
|
||||||
void requestTraversal() {
|
void requestTraversal() {
|
||||||
mWindowPlacerLocked.requestTraversal();
|
mWindowPlacerLocked.requestTraversal();
|
||||||
}
|
}
|
||||||
@@ -7800,7 +7829,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void waitForAllWindowsDrawn(Runnable callback, long timeout, int displayId) {
|
public void waitForAllWindowsDrawn(Runnable callback, long timeout, int displayId) {
|
||||||
final WindowContainer container = displayId == INVALID_DISPLAY
|
final WindowContainer<?> container = displayId == INVALID_DISPLAY
|
||||||
? mRoot : mRoot.getDisplayContent(displayId);
|
? mRoot : mRoot.getDisplayContent(displayId);
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
// The waiting container doesn't exist, no need to wait to run the callback. Run and
|
// The waiting container doesn't exist, no need to wait to run the callback. Run and
|
||||||
@@ -7816,6 +7845,12 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
if (container.mWaitingForDrawn.isEmpty()) {
|
if (container.mWaitingForDrawn.isEmpty()) {
|
||||||
allWindowsDrawn = true;
|
allWindowsDrawn = true;
|
||||||
} else {
|
} else {
|
||||||
|
if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
|
||||||
|
for (int i = 0; i < container.mWaitingForDrawn.size(); i++) {
|
||||||
|
traceStartWaitingForWindowDrawn(container.mWaitingForDrawn.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mWaitingForDrawnCallbacks.put(container, callback);
|
mWaitingForDrawnCallbacks.put(container, callback);
|
||||||
mH.sendNewMessageDelayed(H.WAITING_FOR_DRAWN_TIMEOUT, container, timeout);
|
mH.sendNewMessageDelayed(H.WAITING_FOR_DRAWN_TIMEOUT, container, timeout);
|
||||||
checkDrawnWindowsLocked();
|
checkDrawnWindowsLocked();
|
||||||
|
|||||||
Reference in New Issue
Block a user