From 38ed9eb5d7ac080e0ea3ce3b8b81f00b13dfbf23 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Tue, 7 Aug 2018 10:36:05 -0700 Subject: [PATCH] Winscope: Use a unique stableId for all layers and wm entries Top level of the hierarchy contains the entry with a timestamp. When navigating the timeline with arrow keys, entry loses focus since the timestamp changes. See: https://android-window-manager.teams.x20web.corp.google.com/winscope/winscope-staging-vishnun.html Test: Open trace in winscope, click on entry & navigate timeline with arrow keys Merged-In: Ifbd88da717354c66d96a05d25a9d619fa5209e26 Change-Id: Ifbd88da717354c66d96a05d25a9d619fa5209e26 --- tools/winscope/src/transform.js | 7 +++++-- tools/winscope/src/transform_sf.js | 1 + tools/winscope/src/transform_wm.js | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/winscope/src/transform.js b/tools/winscope/src/transform.js index c00b170c2..9abd88832 100644 --- a/tools/winscope/src/transform.js +++ b/tools/winscope/src/transform.js @@ -14,7 +14,7 @@ * limitations under the License. */ -function transform({obj, kind, name, children, timestamp, rect, bounds, highlight, rects_transform, chips, visible, flattened}) { +function transform({obj, kind, name, children, timestamp, rect, bounds, highlight, rects_transform, chips, visible, flattened, stableId}) { function call(fn, arg) { return (typeof fn == 'function') ? fn(arg) : fn; } @@ -55,6 +55,9 @@ function transform({obj, kind, name, children, timestamp, rect, bounds, highligh var kindResolved = call(kind, obj); var nameResolved = call(name, obj); var rectResolved = call(rect, obj); + var stableIdResolved = (stableId === undefined) ? + kindResolved + '|-|' + nameResolved : + call(stableId, obj); var result = { kind: kindResolved, @@ -68,7 +71,7 @@ function transform({obj, kind, name, children, timestamp, rect, bounds, highligh rects: rects_transform(concat(rectResolved, transformed_children, (e) => e.rects)), highlight: call(highlight, obj), chips: call(chips, obj), - stableId: kindResolved + "|-|" + nameResolved, + stableId: stableIdResolved, visible: call(visible, obj), childrenVisible: transformed_children.some((c) => { return c.childrenVisible || c.visible diff --git a/tools/winscope/src/transform_sf.js b/tools/winscope/src/transform_sf.js index 61014c959..3bd070cbc 100644 --- a/tools/winscope/src/transform_sf.js +++ b/tools/winscope/src/transform_sf.js @@ -159,6 +159,7 @@ function transform_layers_entry(entry) { [[entry.layers], transform_layers], ], timestamp: entry.elapsedRealtimeNanos, + stableId: 'entry', }); } diff --git a/tools/winscope/src/transform_wm.js b/tools/winscope/src/transform_wm.js index 981825985..85e60df44 100644 --- a/tools/winscope/src/transform_wm.js +++ b/tools/winscope/src/transform_wm.js @@ -182,6 +182,7 @@ function transform_entry(entry) { [[entry.windowManagerService.policy], transform_policy], ], timestamp: entry.elapsedRealtimeNanos, + stableId: 'entry', }); }