ui: Pass 'TrackDescriptor's to track predicates instead of 'TrackTags'
This allows predicates to be much more powerful, as they have much more
track information to work with compared to just the tags.
Also remove name and groupName from WellKnownTrackTags & converted two
plugins to use the new format.
Change-Id: I263b7a172fe61fb25291a7d495100a9240b63963
diff --git a/ui/src/common/plugins.ts b/ui/src/common/plugins.ts
index 20f0c75..881a109 100644
--- a/ui/src/common/plugins.ts
+++ b/ui/src/common/plugins.ts
@@ -224,14 +224,9 @@
pinTracksByPredicate(predicate: TrackPredicate) {
const tracks = Object.values(globals.state.tracks);
- const groups = globals.state.trackGroups;
for (const track of tracks) {
- const tags = {
- name: track.name,
- groupName: (track.trackGroup ? groups[track.trackGroup] : undefined)
- ?.name,
- };
- if (predicate(tags) && !isPinned(track.key)) {
+ const trackDesc = globals.trackManager.resolveTrackInfo(track.uri);
+ if (trackDesc && predicate(trackDesc) && !isPinned(track.key)) {
globals.dispatch(
Actions.toggleTrackPinned({
trackKey: track.key,
@@ -244,10 +239,8 @@
unpinTracksByPredicate(predicate: TrackPredicate) {
const tracks = Object.values(globals.state.tracks);
for (const track of tracks) {
- const tags = {
- name: track.name,
- };
- if (predicate(tags) && isPinned(track.key)) {
+ const trackDesc = globals.trackManager.resolveTrackInfo(track.uri);
+ if (trackDesc && predicate(trackDesc) && isPinned(track.key)) {
globals.dispatch(
Actions.toggleTrackPinned({
trackKey: track.key,
@@ -260,10 +253,8 @@
removeTracksByPredicate(predicate: TrackPredicate) {
const trackKeysToRemove = Object.values(globals.state.tracks)
.filter((track) => {
- const tags = {
- name: track.name,
- };
- return predicate(tags);
+ const trackDesc = globals.trackManager.resolveTrackInfo(track.uri);
+ return trackDesc && predicate(trackDesc);
})
.map((trackState) => trackState.key);
diff --git a/ui/src/core_plugins/frames/index.ts b/ui/src/core_plugins/frames/index.ts
index d7d94f1..b37134f 100644
--- a/ui/src/core_plugins/frames/index.ts
+++ b/ui/src/core_plugins/frames/index.ts
@@ -78,6 +78,7 @@
},
tags: {
trackIds,
+ upid,
kind: EXPECTED_FRAMES_SLICE_TRACK_KIND,
},
});
@@ -137,6 +138,7 @@
return new ActualFramesTrack(engine, maxDepth, trackKey, trackIds);
},
tags: {
+ upid,
trackIds,
kind: ACTUAL_FRAMES_SLICE_TRACK_KIND,
},
diff --git a/ui/src/plugins/dev.perfetto.LargeScreensPerf/index.ts b/ui/src/plugins/dev.perfetto.LargeScreensPerf/index.ts
index 9bd57d3..218d59f 100644
--- a/ui/src/plugins/dev.perfetto.LargeScreensPerf/index.ts
+++ b/ui/src/plugins/dev.perfetto.LargeScreensPerf/index.ts
@@ -20,18 +20,18 @@
id: 'dev.perfetto.LargeScreensPerf#PinUnfoldLatencyTracks',
name: 'Pin: Unfold latency tracks',
callback: () => {
- ctx.timeline.pinTracksByPredicate((tags) => {
+ ctx.timeline.pinTracksByPredicate((track) => {
return (
- !!tags.name?.includes('UnfoldTransition') ||
- tags.name?.includes('Screen on blocked') ||
- tags.name?.includes('hingeAngle') ||
- tags.name?.includes('UnfoldLightRevealOverlayAnimation') ||
- tags.name?.startsWith('waitForAllWindowsDrawn') ||
- tags.name?.endsWith('UNFOLD_ANIM>') ||
- tags.name?.endsWith('UNFOLD>') ||
- tags.name == 'Waiting for KeyguardDrawnCallback#onDrawn' ||
- tags.name == 'FoldedState' ||
- tags.name == 'FoldUpdate'
+ !!track.title.includes('UnfoldTransition') ||
+ track.title.includes('Screen on blocked') ||
+ track.title.includes('hingeAngle') ||
+ track.title.includes('UnfoldLightRevealOverlayAnimation') ||
+ track.title.startsWith('waitForAllWindowsDrawn') ||
+ track.title.endsWith('UNFOLD_ANIM>') ||
+ track.title.endsWith('UNFOLD>') ||
+ track.title == 'Waiting for KeyguardDrawnCallback#onDrawn' ||
+ track.title == 'FoldedState' ||
+ track.title == 'FoldUpdate'
);
});
},
diff --git a/ui/src/plugins/dev.perfetto.PinSysUITracks/index.ts b/ui/src/plugins/dev.perfetto.PinSysUITracks/index.ts
index b134e16..bcbb2b2 100644
--- a/ui/src/plugins/dev.perfetto.PinSysUITracks/index.ts
+++ b/ui/src/plugins/dev.perfetto.PinSysUITracks/index.ts
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import {Plugin, PluginContextTrace, PluginDescriptor} from '../../public';
+import {NUM, Plugin, PluginContextTrace, PluginDescriptor} from '../../public';
// List of tracks to pin
const TRACKS_TO_PIN: string[] = [
@@ -29,16 +29,36 @@
// Plugin that pins the tracks relevant to System UI
class PinSysUITracks implements Plugin {
async onTraceLoad(ctx: PluginContextTrace): Promise<void> {
+ // Find the upid for the sysui process
+ const result = await ctx.engine.query(`
+ INCLUDE PERFETTO MODULE android.process_metadata;
+ select
+ _process_available_info_summary.upid
+ from _process_available_info_summary
+ join process using(upid)
+ where process.name = 'com.android.systemui';
+ `);
+ if (result.numRows() === 0) {
+ return;
+ }
+ const sysuiUpid = result.firstRow({
+ upid: NUM,
+ }).upid;
+
ctx.registerCommand({
id: 'dev.perfetto.PinSysUITracks#PinSysUITracks',
name: 'Pin: System UI Related Tracks',
callback: () => {
- ctx.timeline.pinTracksByPredicate((tags) => {
- return !!(
- TRACKS_TO_PIN.some((trackName) =>
- tags.name?.startsWith(trackName),
- ) && tags.groupName?.startsWith(SYSTEM_UI_PROCESS)
- );
+ ctx.timeline.pinTracksByPredicate((track) => {
+ if (!track.uri.startsWith(`/process_${sysuiUpid}`)) return false;
+ if (
+ !TRACKS_TO_PIN.some((trackName) =>
+ track.title.startsWith(trackName),
+ )
+ ) {
+ return false;
+ }
+ return true;
});
// expand the sysui process tracks group
diff --git a/ui/src/public/index.ts b/ui/src/public/index.ts
index 9004310..e73b32d 100644
--- a/ui/src/public/index.ts
+++ b/ui/src/public/index.ts
@@ -21,7 +21,7 @@
import {PrimaryTrackSortKey} from '../common/state';
import {Engine} from '../trace_processor/engine';
import {PromptOption} from '../frontend/omnibox_manager';
-import {LegacyDetailsPanel, TrackDescriptor, TrackTags} from './tracks';
+import {LegacyDetailsPanel, TrackDescriptor} from './tracks';
import {TraceContext} from '../frontend/trace_context';
export {Engine} from '../trace_processor/engine';
@@ -359,7 +359,7 @@
}
// A predicate for selecting a subset of tracks.
-export type TrackPredicate = (info: TrackTags) => boolean;
+export type TrackPredicate = (info: TrackDescriptor) => boolean;
// Describes a reference to a group of tracks.
export interface GroupRef {
diff --git a/ui/src/public/tracks.ts b/ui/src/public/tracks.ts
index 8bd9ae2..b3ebbc9 100644
--- a/ui/src/public/tracks.ts
+++ b/ui/src/public/tracks.ts
@@ -206,18 +206,12 @@
};
interface WellKnownTrackTags {
- // A human readable name for this specific track.
- name: string;
-
// Controls whether to show the "metric" chip.
metric: boolean;
// Controls whether to show the "debuggable" chip.
debuggable: boolean;
- // Groupname of the track
- groupName: string;
-
// The track "kind", used by various subsystems e.g. aggregation controllers.
// This is where "XXX_TRACK_KIND" values should be placed.
// TODO(stevegolton): This will be deprecated once we handle group selections