Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 29 additions & 37 deletions ui/src/plugins/com.android.AndroidLockContention/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,48 +58,40 @@ export default class AndroidLockContentionPlugin implements PerfettoPlugin {
const selection = trace.selection.selection;
if (selection.kind !== 'track_event') return;

const currentEventId = selection.eventId;
const currentTrackUri = selection.trackUri;

const query = await trace.engine.query(`
SELECT owner_tid, id FROM __android_lock_contention_owner_events WHERE id = ${selection.eventId} LIMIT 1
`);
if (query.numRows() > 0) {
const row = query.firstRow({owner_tid: NUM, id: NUM});
const targetUri = `com.android.AndroidLockContention#OwnerEvents_${row.owner_tid}`;

if (currentEventId === row.id && currentTrackUri === targetUri) {
return;
if (
selection.trackUri.startsWith(
'com.android.AndroidLockContention#OwnerEvents',
)
) {
if (this.currentBlockedSlice?.trackUri) {
this.selectAndNavigate(
trace,
this.currentBlockedSlice.id,
this.currentBlockedSlice.trackUri,
);
} else {
this.selectAndNavigate(trace, selection.eventId, undefined, true);
}

this.selectAndNavigate(trace, row.id, targetUri);
return;
}

const contentionQuery = await trace.engine.query(`
SELECT owner_tid, ts FROM __android_lock_contention_owner_events WHERE id = ${selection.eventId} LIMIT 1
const query = await trace.engine.query(`
SELECT id, owner_tid
FROM __android_lock_contention_owner_events
WHERE id = ${selection.eventId}
LIMIT 1
`);
if (contentionQuery.numRows() > 0) {
const row = contentionQuery.firstRow({owner_tid: NUM, ts: LONG});

const ownerQuery = await trace.engine.query(`
SELECT id FROM __android_lock_contention_owner_events
WHERE owner_tid = ${row.owner_tid}
AND ts <= ${row.ts}
AND ts + dur >= ${row.ts}
LIMIT 1
`);
if (ownerQuery.numRows() > 0) {
const ownerId = ownerQuery.firstRow({id: NUM}).id;
const targetUri = `com.android.AndroidLockContention#OwnerEvents_${row.owner_tid}`;

if (currentEventId === ownerId && currentTrackUri === targetUri) {
return;
}

this.selectAndNavigate(trace, ownerId, targetUri);
return;
}
if (query.numRows() > 0) {
const row = query.firstRow({id: NUM, owner_tid: NUM});
this.currentBlockedSlice = {
id: selection.eventId,
trackUri: selection.trackUri,
};
this.selectAndNavigate(
trace,
row.id,
`com.android.AndroidLockContention#OwnerEvents_${row.owner_tid}`,
);
}
}
public readonly navigation = new LockContentionNavigation();
Expand Down
Loading