Skip to content

Commit

Permalink
Better checks for state transitions (fixes #167033) (#167279)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima authored Nov 25, 2022
1 parent d4a2996 commit fd8c903
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/vs/base/browser/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ export namespace inputLatency {
* Mark the end of the keydown event.
*/
function markKeyDownEnd() {
performance.mark('keydown/end');
state.keydown = EventPhase.Finished;
if (state.keydown === EventPhase.InProgress) {
performance.mark('keydown/end');
state.keydown = EventPhase.Finished;
}
}

/**
Expand All @@ -67,12 +69,18 @@ export namespace inputLatency {
* Record the start of the input event.
*/
export function onInput() {
if (state.input === EventPhase.Before) {
// it looks like we didn't receive a `beforeinput`
onBeforeInput();
}
queueMicrotask(markInputEnd);
}

function markInputEnd() {
performance.mark('input/end');
state.input = EventPhase.Finished;
if (state.input === EventPhase.InProgress) {
performance.mark('input/end');
state.input = EventPhase.Finished;
}
}

/**
Expand Down Expand Up @@ -110,8 +118,10 @@ export namespace inputLatency {
* Mark the end of the animation frame performing the rendering.
*/
function markRenderEnd() {
performance.mark('render/end');
state.render = EventPhase.Finished;
if (state.render === EventPhase.InProgress) {
performance.mark('render/end');
state.render = EventPhase.Finished;
}
}

function scheduleRecordIfFinishedTask() {
Expand Down

0 comments on commit fd8c903

Please sign in to comment.