Skip to content

Commit 5ca65e1

Browse files
committed
clean up isInputPending
1 parent 8fb0233 commit 5ca65e1

File tree

5 files changed

+6
-119
lines changed

5 files changed

+6
-119
lines changed

packages/scheduler/src/SchedulerFeatureFlags.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
*/
99

1010
export const enableSchedulerDebugging = false;
11-
export const enableIsInputPending = false;
1211
export const enableProfiling = false;
13-
export const enableIsInputPendingContinuous = false;
1412
export const frameYieldMs = 5;
15-
export const continuousYieldMs = 50;
16-
export const maxYieldMs = 300;
1713

1814
export const userBlockingPriorityTimeout = 250;
1915
export const normalPriorityTimeout = 5000;

packages/scheduler/src/__tests__/Scheduler-test.js

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,7 @@ describe('SchedulerBrowser', () => {
339339
runtime.assertLog([
340340
'Message Event',
341341
'Task with no pending input',
342-
// Even though there's no input, eventually Scheduler will yield
343-
// regardless in case there's a pending main thread task we don't know
344-
// about, like a network event.
345-
gate(flags =>
346-
flags.enableIsInputPending
347-
? 'Yield at 10ms'
348-
: // When isInputPending is disabled, we always yield quickly
349-
'Yield at 5ms',
350-
),
342+
'Yield at 5ms',
351343
]);
352344

353345
runtime.resetTime();
@@ -393,15 +385,7 @@ describe('SchedulerBrowser', () => {
393385
runtime.assertLog([
394386
'Message Event',
395387
'Task with no pending input',
396-
// Even though there's no input, eventually Scheduler will yield
397-
// regardless in case there's a pending main thread task we don't know
398-
// about, like a network event.
399-
gate(flags =>
400-
flags.enableIsInputPending
401-
? 'Yield at 10ms'
402-
: // When isInputPending is disabled, we always yield quickly
403-
'Yield at 5ms',
404-
),
388+
'Yield at 5ms',
405389
]);
406390

407391
runtime.resetTime();
@@ -419,14 +403,7 @@ describe('SchedulerBrowser', () => {
419403
runtime.assertLog([
420404
'Message Event',
421405
'Task with continuous input',
422-
// This time we yielded quickly to unblock the continuous event. But not
423-
// as quickly as for a discrete event.
424-
gate(flags =>
425-
flags.enableIsInputPending
426-
? 'Yield at 10ms'
427-
: // When isInputPending is disabled, we always yield quickly
428-
'Yield at 5ms',
429-
),
406+
'Yield at 5ms',
430407
'Continuous Event',
431408
]);
432409
},
@@ -448,16 +425,7 @@ describe('SchedulerBrowser', () => {
448425
runtime.assertLog(['Post Message']);
449426

450427
runtime.fireMessageEvent();
451-
runtime.assertLog([
452-
'Message Event',
453-
'Task with no paint',
454-
gate(flags =>
455-
flags.enableIsInputPending
456-
? 'Yield at 10ms'
457-
: // When isInputPending is disabled, we always yield quickly
458-
'Yield at 5ms',
459-
),
460-
]);
428+
runtime.assertLog(['Message Event', 'Task with no paint', 'Yield at 5ms']);
461429

462430
runtime.resetTime();
463431

packages/scheduler/src/forks/Scheduler.js

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ import type {PriorityLevel} from '../SchedulerPriorities';
1414
import {
1515
enableSchedulerDebugging,
1616
enableProfiling,
17-
enableIsInputPending,
18-
enableIsInputPendingContinuous,
1917
frameYieldMs,
20-
continuousYieldMs,
21-
maxYieldMs,
2218
userBlockingPriorityTimeout,
2319
lowPriorityTimeout,
2420
normalPriorityTimeout,
@@ -104,17 +100,6 @@ const localClearTimeout =
104100
const localSetImmediate =
105101
typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom
106102

107-
const isInputPending =
108-
typeof navigator !== 'undefined' &&
109-
// $FlowFixMe[prop-missing]
110-
navigator.scheduling !== undefined &&
111-
// $FlowFixMe[incompatible-type]
112-
navigator.scheduling.isInputPending !== undefined
113-
? navigator.scheduling.isInputPending.bind(navigator.scheduling)
114-
: null;
115-
116-
const continuousOptions = {includeContinuous: enableIsInputPendingContinuous};
117-
118103
function advanceTimers(currentTime: number) {
119104
// Check for tasks that are no longer delayed and add them to the queue.
120105
let timer = peek(timerQueue);
@@ -468,71 +453,20 @@ let taskTimeoutID: TimeoutID = (-1: any);
468453
// It does not attempt to align with frame boundaries, since most tasks don't
469454
// need to be frame aligned; for those that do, use requestAnimationFrame.
470455
let frameInterval = frameYieldMs;
471-
const continuousInputInterval = continuousYieldMs;
472-
const maxInterval = maxYieldMs;
473456
let startTime = -1;
474457

475-
let needsPaint = false;
476-
477458
function shouldYieldToHost(): boolean {
478459
const timeElapsed = getCurrentTime() - startTime;
479460
if (timeElapsed < frameInterval) {
480461
// The main thread has only been blocked for a really short amount of time;
481462
// smaller than a single frame. Don't yield yet.
482463
return false;
483464
}
484-
485-
// The main thread has been blocked for a non-negligible amount of time. We
486-
// may want to yield control of the main thread, so the browser can perform
487-
// high priority tasks. The main ones are painting and user input. If there's
488-
// a pending paint or a pending input, then we should yield. But if there's
489-
// neither, then we can yield less often while remaining responsive. We'll
490-
// eventually yield regardless, since there could be a pending paint that
491-
// wasn't accompanied by a call to `requestPaint`, or other main thread tasks
492-
// like network events.
493-
if (enableIsInputPending) {
494-
if (needsPaint) {
495-
// There's a pending paint (signaled by `requestPaint`). Yield now.
496-
return true;
497-
}
498-
if (timeElapsed < continuousInputInterval) {
499-
// We haven't blocked the thread for that long. Only yield if there's a
500-
// pending discrete input (e.g. click). It's OK if there's pending
501-
// continuous input (e.g. mouseover).
502-
if (isInputPending !== null) {
503-
return isInputPending();
504-
}
505-
} else if (timeElapsed < maxInterval) {
506-
// Yield if there's either a pending discrete or continuous input.
507-
if (isInputPending !== null) {
508-
return isInputPending(continuousOptions);
509-
}
510-
} else {
511-
// We've blocked the thread for a long time. Even if there's no pending
512-
// input, there may be some other scheduled work that we don't know about,
513-
// like a network event. Yield now.
514-
return true;
515-
}
516-
}
517-
518-
// `isInputPending` isn't available. Yield now.
465+
// Yield now.
519466
return true;
520467
}
521468

522-
function requestPaint() {
523-
if (
524-
enableIsInputPending &&
525-
navigator !== undefined &&
526-
// $FlowFixMe[prop-missing]
527-
navigator.scheduling !== undefined &&
528-
// $FlowFixMe[incompatible-type]
529-
navigator.scheduling.isInputPending !== undefined
530-
) {
531-
needsPaint = true;
532-
}
533-
534-
// Since we yield every frame regardless, `requestPaint` has no effect.
535-
}
469+
function requestPaint() {}
536470

537471
function forceFrameRate(fps: number) {
538472
if (fps < 0 || fps > 125) {
@@ -577,9 +511,6 @@ const performWorkUntilDeadline = () => {
577511
}
578512
}
579513
}
580-
// Yielding to the browser will give it a chance to paint, so we can
581-
// reset this.
582-
needsPaint = false;
583514
};
584515

585516
let schedulePerformWorkUntilDeadline;

packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313

1414
export const enableProfiling = __VARIANT__;
1515

16-
export const enableIsInputPending = __VARIANT__;
17-
export const enableIsInputPendingContinuous = __VARIANT__;
1816
export const frameYieldMs = 5;
19-
export const continuousYieldMs = 10;
20-
export const maxYieldMs = 10;
2117

2218
export const userBlockingPriorityTimeout = 250;
2319
export const normalPriorityTimeout = 5000;

packages/scheduler/src/forks/SchedulerFeatureFlags.www.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ export const {
1616
userBlockingPriorityTimeout,
1717
normalPriorityTimeout,
1818
lowPriorityTimeout,
19-
enableIsInputPending,
20-
enableIsInputPendingContinuous,
2119
frameYieldMs,
22-
continuousYieldMs,
23-
maxYieldMs,
2420
} = dynamicFeatureFlags;
2521
export const enableSchedulerDebugging = true;
2622
export const enableProfiling: boolean =

0 commit comments

Comments
 (0)