From 06a596be4dad7a9bccddcbc84cfe9bd0a64d5956 Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Fri, 23 Apr 2021 12:04:19 +0200 Subject: [PATCH] 3/ Simplify WM parsing on Winscope - Use flicker class type as object type - Use name from flicker - Use stableID from flicker - Refactor element visibility - Rename `childrenWindows` to children to avoid creating a new property Bug: 185516271 Test: build winscope and open WM traces Change-Id: I582c0fe4ac48f8a503d1dccfbce437d489a50ca7 --- tools/winscope/src/WindowManagerTraceView.vue | 8 +++++++- tools/winscope/src/flickerlib/WindowManagerState.ts | 4 ++-- tools/winscope/src/flickerlib/windows/Activity.ts | 2 +- tools/winscope/src/flickerlib/windows/ActivityTask.ts | 2 +- tools/winscope/src/flickerlib/windows/DisplayArea.ts | 2 +- tools/winscope/src/flickerlib/windows/DisplayContent.ts | 2 +- tools/winscope/src/flickerlib/windows/WindowContainer.ts | 2 +- tools/winscope/src/flickerlib/windows/WindowState.ts | 9 ++++----- tools/winscope/src/flickerlib/windows/WindowToken.ts | 2 +- 9 files changed, 19 insertions(+), 14 deletions(-) diff --git a/tools/winscope/src/WindowManagerTraceView.vue b/tools/winscope/src/WindowManagerTraceView.vue index a03a95f2d..1c9264cdf 100644 --- a/tools/winscope/src/WindowManagerTraceView.vue +++ b/tools/winscope/src/WindowManagerTraceView.vue @@ -28,7 +28,13 @@ export default { }, methods: { summarizer(item) { - return null; + const summary = []; + + if (item.obj.isIncompleteReason) { + summary.push({key: 'Incomplete state reason', value: item.obj.isIncompleteReason}); + } + + return summary; }, } } diff --git a/tools/winscope/src/flickerlib/WindowManagerState.ts b/tools/winscope/src/flickerlib/WindowManagerState.ts index 2cb9ab3be..429f10db7 100644 --- a/tools/winscope/src/flickerlib/WindowManagerState.ts +++ b/tools/winscope/src/flickerlib/WindowManagerState.ts @@ -50,14 +50,14 @@ WindowManagerState.fromProto = function ({proto, timestamp = 0, where = ""}): Wi timestamp = timestamp ) + entry.kind = entry.constructor.name + entry.rects = entry.windowStates.reverse().map(it => it.rect) entry.obj = getWMPropertiesForDisplay(proto) entry.obj["isComplete"] = entry.isComplete() if (!entry.obj.isComplete) { entry.obj["isIncompleteReason"] = entry.getIsIncompleteReason() } - entry.name = nanosToString(entry.timestamp, TimeUnits.MILLI_SECONDS) entry.shortName = entry.name - entry.children = entry.root.childrenWindows.reverse() entry.chips = [] entry.visible = true entry.rawTreeViewObject = asRawTreeViewObject(entry) diff --git a/tools/winscope/src/flickerlib/windows/Activity.ts b/tools/winscope/src/flickerlib/windows/Activity.ts index 0b8eb06b5..01cf7aec9 100644 --- a/tools/winscope/src/flickerlib/windows/Activity.ts +++ b/tools/winscope/src/flickerlib/windows/Activity.ts @@ -42,8 +42,8 @@ Activity.fromProto = function (proto): Activity { ) entry.obj = getWMPropertiesForDisplay(proto) + entry.kind = entry.constructor.name entry.shortName = shortenName(entry.name) - entry.children = entry.childrenWindows entry.rawTreeViewObject = asRawTreeViewObject(entry) console.warn("Created ", entry.kind, " stableId=", entry.stableId) diff --git a/tools/winscope/src/flickerlib/windows/ActivityTask.ts b/tools/winscope/src/flickerlib/windows/ActivityTask.ts index 9bbe428ba..acda9f388 100644 --- a/tools/winscope/src/flickerlib/windows/ActivityTask.ts +++ b/tools/winscope/src/flickerlib/windows/ActivityTask.ts @@ -53,8 +53,8 @@ ActivityTask.fromProto = function (proto, isActivityInTree: Boolean): ActivityTa ) entry.obj = getWMPropertiesForDisplay(proto) + entry.kind = entry.constructor.name entry.shortName = shortenName(entry.name) - entry.children = entry.childrenWindows entry.rawTreeViewObject = asRawTreeViewObject(entry) console.warn("Created ", entry.kind, " stableId=", entry.stableId) diff --git a/tools/winscope/src/flickerlib/windows/DisplayArea.ts b/tools/winscope/src/flickerlib/windows/DisplayArea.ts index 066e71698..26336f2c8 100644 --- a/tools/winscope/src/flickerlib/windows/DisplayArea.ts +++ b/tools/winscope/src/flickerlib/windows/DisplayArea.ts @@ -34,8 +34,8 @@ DisplayArea.fromProto = function (proto, isActivityInTree: Boolean): DisplayArea const entry = new DisplayArea(proto.isTaskDisplayArea, windowContainer) entry.obj = getWMPropertiesForDisplay(proto) + entry.kind = entry.constructor.name entry.shortName = shortenName(entry.name) - entry.children = entry.childrenWindows entry.rawTreeViewObject = asRawTreeViewObject(entry) console.warn("Created ", entry.kind, " stableId=", entry.stableId) diff --git a/tools/winscope/src/flickerlib/windows/DisplayContent.ts b/tools/winscope/src/flickerlib/windows/DisplayContent.ts index bbb41c285..fad22f2e2 100644 --- a/tools/winscope/src/flickerlib/windows/DisplayContent.ts +++ b/tools/winscope/src/flickerlib/windows/DisplayContent.ts @@ -62,8 +62,8 @@ DisplayContent.fromProto = function (proto, isActivityInTree: Boolean): DisplayC ) entry.obj = getWMPropertiesForDisplay(proto) + entry.kind = entry.constructor.name entry.shortName = shortenName(entry.name) - entry.children = entry.childrenWindows entry.rawTreeViewObject = asRawTreeViewObject(entry) console.warn("Created ", entry.kind, " stableId=", entry.stableId) diff --git a/tools/winscope/src/flickerlib/windows/WindowContainer.ts b/tools/winscope/src/flickerlib/windows/WindowContainer.ts index 4bb5ab129..c0ab48455 100644 --- a/tools/winscope/src/flickerlib/windows/WindowContainer.ts +++ b/tools/winscope/src/flickerlib/windows/WindowContainer.ts @@ -61,6 +61,7 @@ WindowContainer.fromProto = function ({ // the properties view of the element as we can always see those elements' // properties by changing the target element in the hierarchy tree view. entry.obj = getWMPropertiesForDisplay(proto) + entry.kind = entry.constructor.name entry.shortName = shortenName(entry.name) entry.rawTreeViewObject = asRawTreeViewObject(entry) return entry @@ -83,7 +84,6 @@ function newConfigurationContainer(proto): ConfigurationContainer { newConfiguration(proto?.mergedOverrideConfiguration ?? null) ) - entry.kind = "ConfigurationContainer" entry.obj = entry return entry } diff --git a/tools/winscope/src/flickerlib/windows/WindowState.ts b/tools/winscope/src/flickerlib/windows/WindowState.ts index 98a7a1c7e..4c6ef1b5a 100644 --- a/tools/winscope/src/flickerlib/windows/WindowState.ts +++ b/tools/winscope/src/flickerlib/windows/WindowState.ts @@ -74,15 +74,14 @@ import WindowContainer from "./WindowContainer" /* isAppWindow */ isActivityInTree ) - entry.rects.map((rect) => rect.ref = entry) + entry.kind = entry.constructor.name entry.obj = getWMPropertiesForDisplay(proto) + entry.rect = entry.frame + entry.rect.ref = entry + entry.rect.label = entry.name entry.shortName = shortenName(entry.name) entry.visible = entry.isVisible ?? false entry.chips = entry.isVisible ? [VISIBLE_CHIP] : [] - entry.children = entry.childrenWindows - if (entry.visible) { - entry.rect = entry.rects[0] - } entry.rawTreeViewObject = asRawTreeViewObject(entry) return entry } diff --git a/tools/winscope/src/flickerlib/windows/WindowToken.ts b/tools/winscope/src/flickerlib/windows/WindowToken.ts index c3142f546..9d1465316 100644 --- a/tools/winscope/src/flickerlib/windows/WindowToken.ts +++ b/tools/winscope/src/flickerlib/windows/WindowToken.ts @@ -33,9 +33,9 @@ WindowToken.fromProto = function (proto, isActivityInTree: Boolean): WindowToken throw "Window container should not be null: " + JSON.stringify(proto) } const entry = new WindowToken(windowContainer) + entry.kind = entry.constructor.name entry.obj = getWMPropertiesForDisplay(proto) entry.shortName = shortenName(entry.name) - entry.children = entry.childrenWindows entry.rawTreeViewObject = asRawTreeViewObject(entry) console.warn("Created ", entry.kind, " stableId=", entry.stableId)