@@ -49,8 +49,10 @@ export namespace inputLatency {
49
49
* Mark the end of the keydown event.
50
50
*/
51
51
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
+ }
54
56
}
55
57
56
58
/**
@@ -67,12 +69,18 @@ export namespace inputLatency {
67
69
* Record the start of the input event.
68
70
*/
69
71
export function onInput ( ) {
72
+ if ( state . input === EventPhase . Before ) {
73
+ // it looks like we didn't receive a `beforeinput`
74
+ onBeforeInput ( ) ;
75
+ }
70
76
queueMicrotask ( markInputEnd ) ;
71
77
}
72
78
73
79
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
+ }
76
84
}
77
85
78
86
/**
@@ -110,8 +118,10 @@ export namespace inputLatency {
110
118
* Mark the end of the animation frame performing the rendering.
111
119
*/
112
120
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
+ }
115
125
}
116
126
117
127
function scheduleRecordIfFinishedTask ( ) {
0 commit comments