[11] Change matching WM/SF entry to IME entry algo
Due to there being some slightly different timestamps between WM/SF trace and IME trace, we want to allow some "fault tolerance" -- even if a WM/SF entry comes after IME entry in time, it may still be the corresponding entry if it's within a manually-defined "fault tolerance" time. For now, fault tolerance is defined to be 200ms. So if a WM/SF entry is within IME entry +- 200ms, it may be considered a matching / corresponding entry. Within this range, we will always try to pick a WM/SF entry that comes before the IME entry. If there is no such WM/SF entry, then we will pick one that comes after. Bug: 236226833 Test: manual on local build of Winscope Change-Id: I0782ec520284517bf964eeffd552e6175758c9f1
This commit is contained in:
@@ -159,13 +159,13 @@
|
||||
<div class="group">
|
||||
<span class="group-header">Visibility</span>
|
||||
<div class="full-width">
|
||||
<span class="key">InputMethod Window:</span>
|
||||
<span class="value">{{
|
||||
<span class="key" v-if="entry.wmProperties">InputMethod Window:</span>
|
||||
<span class="value" v-if="entry.wmProperties">{{
|
||||
entry.wmProperties.isInputMethodWindowVisible
|
||||
}}</span>
|
||||
<div />
|
||||
<span class="key">InputMethod Surface:</span>
|
||||
<span class="value">{{
|
||||
<span class="key" v-if="entry.sfProperties">InputMethod Surface:</span>
|
||||
<span class="value" v-if="entry.sfProperties">{{
|
||||
entry.sfProperties.isInputMethodSurfaceVisible }}</span>
|
||||
<div />
|
||||
</div>
|
||||
|
||||
@@ -100,23 +100,35 @@ function combineWmSfPropertiesIntoImeData(imeTraceFile, wmOrSfTraceFile) {
|
||||
}
|
||||
|
||||
function matchCorrespondingTimestamps(imeTimestamps, wmOrSfTimestamps) {
|
||||
// find the latest sf / wm timestamp that comes before current ime timestamp
|
||||
// we want to take the earliest sf / wm entry that is within
|
||||
// +-[FAULT_TOLERANCE] ns of the ime entry as the corresponding sf / wm entry
|
||||
const FAULT_TOLERANCE = 200000000; // 200ms in ns
|
||||
|
||||
let wmOrSfIndex = 0;
|
||||
const intersectWmOrSfIndices = [];
|
||||
for (let imeIndex = 0; imeIndex < imeTimestamps.length; imeIndex++) {
|
||||
const currImeTimestamp = imeTimestamps[imeIndex];
|
||||
|
||||
let currWmOrSfTimestamp = wmOrSfTimestamps[wmOrSfIndex];
|
||||
while (currWmOrSfTimestamp < currImeTimestamp) {
|
||||
let wmOrSfTimestamp = wmOrSfTimestamps[wmOrSfIndex];
|
||||
while (wmOrSfTimestamp < currImeTimestamp) {
|
||||
wmOrSfIndex++;
|
||||
currWmOrSfTimestamp = wmOrSfTimestamps[wmOrSfIndex];
|
||||
wmOrSfTimestamp = wmOrSfTimestamps[wmOrSfIndex];
|
||||
}
|
||||
// wmOrSfIndex should now be at the first entry that is past
|
||||
// [currImeTimestamp] ns. We want the most recent entry that comes
|
||||
// before [currImeTimestamp] ns if it's within
|
||||
// [currImeTimestamp - FAULT_TOLERANCE] ns. Otherwise, we want the most
|
||||
// recent entry that comes after [currImeTimestamp] ns if it's within
|
||||
// [currImeTimestamp + FAULT_TOLERANCE] ns.
|
||||
const previousWmOrSfTimestamp = wmOrSfTimestamps[wmOrSfIndex - 1];
|
||||
if (previousWmOrSfTimestamp >= currImeTimestamp - FAULT_TOLERANCE) {
|
||||
intersectWmOrSfIndices.push(wmOrSfIndex - 1);
|
||||
} else if (wmOrSfTimestamp <= currImeTimestamp + FAULT_TOLERANCE) {
|
||||
intersectWmOrSfIndices.push(wmOrSfIndex);
|
||||
} else {
|
||||
intersectWmOrSfIndices.push(null);
|
||||
}
|
||||
// if wmOrSfIndex is 0, i.e. no corresponding entry is found,
|
||||
// we take the first wm / sf entry
|
||||
// intersectWmOrSfIndices.push(Math.max(0, wmOrSfIndex - 1));
|
||||
intersectWmOrSfIndices.push(wmOrSfIndex - 1);
|
||||
}
|
||||
console.log('done matching corresponding timestamps');
|
||||
console.log('done matching corresponding timestamps', intersectWmOrSfIndices);
|
||||
return intersectWmOrSfIndices;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user