Skip to content

Commit fd8c903

Browse files
authored
Better checks for state transitions (fixes microsoft#167033) (microsoft#167279)
1 parent d4a2996 commit fd8c903

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/vs/base/browser/performance.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ export namespace inputLatency {
4949
* Mark the end of the keydown event.
5050
*/
5151
function markKeyDownEnd() {
52-
performance.mark('keydown/end');
53-
state.keydown = EventPhase.Finished;
52+
if (state.keydown === EventPhase.InProgress) {
53+
performance.mark('keydown/end');
54+
state.keydown = EventPhase.Finished;
55+
}
5456
}
5557

5658
/**
@@ -67,12 +69,18 @@ export namespace inputLatency {
6769
* Record the start of the input event.
6870
*/
6971
export function onInput() {
72+
if (state.input === EventPhase.Before) {
73+
// it looks like we didn't receive a `beforeinput`
74+
onBeforeInput();
75+
}
7076
queueMicrotask(markInputEnd);
7177
}
7278

7379
function markInputEnd() {
74-
performance.mark('input/end');
75-
state.input = EventPhase.Finished;
80+
if (state.input === EventPhase.InProgress) {
81+
performance.mark('input/end');
82+
state.input = EventPhase.Finished;
83+
}
7684
}
7785

7886
/**
@@ -110,8 +118,10 @@ export namespace inputLatency {
110118
* Mark the end of the animation frame performing the rendering.
111119
*/
112120
function markRenderEnd() {
113-
performance.mark('render/end');
114-
state.render = EventPhase.Finished;
121+
if (state.render === EventPhase.InProgress) {
122+
performance.mark('render/end');
123+
state.render = EventPhase.Finished;
124+
}
115125
}
116126

117127
function scheduleRecordIfFinishedTask() {

0 commit comments

Comments
 (0)