Add traces to aid onScreenTuringOn latency debugging

Those traces are useful to debug what happens in the unfold scenario: we discovered that recent changes added a lot of delay in systemui receiving onScreenTuringOn, and onDisplayChanged callbacks.

Bug: 197515205
Test: recorded a perfetto trace and made sure those are there
Change-Id: Iec9f2261dd63d414e1e5387933b7374a5f003e11
This commit is contained in:
Nicolo' Mazzucato
2022-02-24 16:01:58 +01:00
parent a52caf0317
commit 72655bf492
3 changed files with 29 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
package com.android.server.display;
import android.annotation.NonNull;
import android.os.Trace;
import android.util.Slog;
import android.view.Display;
import android.view.DisplayAddress;
@@ -38,6 +39,7 @@ import java.util.function.Consumer;
*/
class DisplayDeviceRepository implements DisplayAdapter.Listener {
private static final String TAG = "DisplayDeviceRepository";
private static final Boolean DEBUG = false;
public static final int DISPLAY_DEVICE_EVENT_ADDED = 1;
public static final int DISPLAY_DEVICE_EVENT_CHANGED = 2;
@@ -75,6 +77,11 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {
@Override
public void onDisplayDeviceEvent(DisplayDevice device, int event) {
String tag = null;
if (DEBUG) {
tag = "DisplayDeviceRepository#onDisplayDeviceEvent (event=" + event + ")";
Trace.beginAsyncSection(tag, 0);
}
switch (event) {
case DISPLAY_DEVICE_EVENT_ADDED:
handleDisplayDeviceAdded(device);
@@ -88,6 +95,9 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {
handleDisplayDeviceRemoved(device);
break;
}
if (DEBUG) {
Trace.endAsyncSection(tag, 0);
}
}
@Override
@@ -156,7 +166,9 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {
Slog.w(TAG, "Attempted to change non-existent display device: " + info);
return;
}
if (DEBUG) {
Trace.beginSection("handleDisplayDeviceChanged");
}
int diff = device.mDebugLastLoggedDeviceInfo.diff(info);
if (diff == DisplayDeviceInfo.DIFF_STATE) {
Slog.i(TAG, "Display device changed state: \"" + info.name
@@ -176,6 +188,9 @@ class DisplayDeviceRepository implements DisplayAdapter.Listener {
device.applyPendingDisplayDeviceInfoChangesLocked();
sendEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
if (DEBUG) {
Trace.endSection();
}
}
}

View File

@@ -781,7 +781,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mDisplayStatsId = mUniqueDisplayId.hashCode();
mDisplayDeviceConfig = config;
loadFromDisplayDeviceConfig(token, info);
if (DEBUG) {
Trace.beginAsyncSection("DisplayPowerController#updatePowerState", 0);
}
updatePowerState();
if (DEBUG) {
Trace.endAsyncSection("DisplayPowerController#updatePowerState", 0);
}
}
});
}

View File

@@ -16,6 +16,7 @@
package com.android.server.display;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.Mode.INVALID_MODE_ID;
import android.app.ActivityThread;
@@ -1391,7 +1392,12 @@ final class LocalDisplayAdapter extends DisplayAdapter {
}
public boolean getBootDisplayModeSupport() {
return SurfaceControl.getBootDisplayModeSupport();
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "getBootDisplayModeSupport");
try {
return SurfaceControl.getBootDisplayModeSupport();
} finally {
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
}
public void setBootDisplayMode(IBinder displayToken, int modeId) {