@samitouri / QOS-React-1 / commits / 1e9ef39a87

[flags] Delete enableSchedulerDebugger (#31826)

The tool for this isn't used so I killed it internally and we can clean up the code to make it easier to reduce the scheduler code.

Ricky committed Dec 18, 2024 at 13:29 UTC 1e9ef39a8742889f8414c7df9c9e6ef463fe3d01
8 files changed +8 -133
fixtures/scheduler/index.html
+2 -60
@@ -91,19 +91,8 @@
91 <div> If the counter advanced while you were away from this tab, it's correct.</div>
92 </li>
93 <li>
94 - <p>Can pause execution, dump scheduled callbacks, and continue where it left off</p>
95 - <button onClick="runTestEight()">Run Test 8</button>
96 - <div><b>Click the button above, press "continue" to finish the test after it pauses:</b></div>
97 - <button onClick="continueTestEight()">continue</button>
98 - <div><b>Expected:</b></div>
99 - <div id="test-8-expected">
100 - </div>
101 - <div> -------------------------------------------------</div>
102 - <div> If the test didn't progress until you hit "continue" and </div>
103 - <div> you see the same above and below afterwards it's correct.
104 - <div> -------------------------------------------------</div>
105 - <div><b>Actual:</b></div>
106 - <div id="test-8"></div>
94 + <p>Test Eight Removed</p>
95 + <p>Test 8 was removed because it was testing a feature that was removed from the scheduler.</p>
96 </li>
97 <li>
98 <p>Can force a specific framerate</p>
@@ -156,9 +145,6 @@ const {
145 unstable_scheduleCallback: scheduleCallback,
146 unstable_cancelCallback: cancelCallback,
147 unstable_now: now,
159 - unstable_getFirstCallbackNode: getFirstCallbackNode,
160 - unstable_pauseExecution: pauseExecution,
161 - unstable_continueExecution: continueExecution,
148 unstable_forceFrameRate: forceFrameRate,
149 unstable_shouldYield: shouldYield,
150 unstable_NormalPriority: NormalPriority,
@@ -587,50 +573,6 @@ function runTestSeven() {
573 scheduleCallback(NormalPriority, incrementCounterAndScheduleNextCallback);
574 }
575
590 -function runTestEight() {
591 - // Test 8
592 - // Pauses execution, dumps the queue, and continues execution
593 - clearTestResult(8);
594 -
595 - function countNodesInStack(firstCallbackNode) {
596 - var node = firstCallbackNode;
597 - var count = 0;
598 - if (node !== null) {
599 - do {
600 - count = count + 1;
601 - node = node.next;
602 - } while (node !== firstCallbackNode);
603 - }
604 - return count;
605 - }
606 -
607 - scheduleCallback(NormalPriority, () => {
608 -
609 - // size should be 0
610 - updateTestResult(8, `Queue size: ${countNodesInStack(getFirstCallbackNode())}.`);
611 - updateTestResult(8, 'Pausing... press continue to resume.');
612 - pauseExecution();
613 -
614 - scheduleCallback(NormalPriority, function () {
615 - updateTestResult(8, 'Finishing...');
616 - displayTestResult(8);
617 - })
618 - scheduleCallback(NormalPriority, function () {
619 - updateTestResult(8, 'Done!');
620 - displayTestResult(8);
621 - checkTestResult(8);
622 - })
623 -
624 - // new size should be 2 now
625 - updateTestResult(8, `Queue size: ${countNodesInStack(getFirstCallbackNode())}.`);
626 - displayTestResult(8);
627 - });
628 -}
629 -
630 -function continueTestEight() {
631 - continueExecution();
632 -}
633 -
576 function runTestNine() {
577 clearTestResult(9);
578 // We have this to make sure that the thing that goes right after it can get a full frame
packages/scheduler/src/SchedulerFeatureFlags.js
-1
@@ -7,7 +7,6 @@
7 * @flow strict
8 */
9
10 -export const enableSchedulerDebugging = false;
10 export const enableProfiling = false;
11 export const frameYieldMs = 5;
12
packages/scheduler/src/forks/Scheduler.js
+1 -27
@@ -12,7 +12,6 @@
12 import type {PriorityLevel} from '../SchedulerPriorities';
13
14 import {
15 - enableSchedulerDebugging,
15 enableProfiling,
16 frameYieldMs,
17 userBlockingPriorityTimeout,
@@ -83,9 +82,6 @@ var timerQueue: Array<Task> = [];
82 // Incrementing id counter. Used to maintain insertion order.
83 var taskIdCounter = 1;
84
86 -// Pausing the scheduler is useful for debugging.
87 -var isSchedulerPaused = false;
88 -
85 var currentTask = null;
86 var currentPriorityLevel = NormalPriority;
87
@@ -193,10 +189,7 @@ function workLoop(initialTime: number) {
189 let currentTime = initialTime;
190 advanceTimers(currentTime);
191 currentTask = peek(taskQueue);
196 - while (
197 - currentTask !== null &&
198 - !(enableSchedulerDebugging && isSchedulerPaused)
199 - ) {
192 + while (currentTask !== null) {
193 if (!enableAlwaysYieldScheduler) {
194 if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
195 // This currentTask hasn't expired, and we've reached the deadline.
@@ -422,22 +415,6 @@ function unstable_scheduleCallback(
415 return newTask;
416 }
417
425 -function unstable_pauseExecution() {
426 - isSchedulerPaused = true;
427 -}
428 -
429 -function unstable_continueExecution() {
430 - isSchedulerPaused = false;
431 - if (!isHostCallbackScheduled && !isPerformingWork) {
432 - isHostCallbackScheduled = true;
433 - requestHostCallback();
434 - }
435 -}
436 -
437 -function unstable_getFirstCallbackNode(): Task | null {
438 - return peek(taskQueue);
439 -}
440 -
418 function unstable_cancelCallback(task: Task) {
419 if (enableProfiling) {
420 if (task.isQueued) {
@@ -606,9 +583,6 @@ export {
583 unstable_getCurrentPriorityLevel,
584 shouldYieldToHost as unstable_shouldYield,
585 requestPaint as unstable_requestPaint,
609 - unstable_continueExecution,
610 - unstable_pauseExecution,
611 - unstable_getFirstCallbackNode,
586 getCurrentTime as unstable_now,
587 forceFrameRate as unstable_forceFrameRate,
588 };
packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
-1
@@ -12,7 +12,6 @@ const dynamicFeatureFlags = require('SchedulerFeatureFlags');
12
13 export const {enableRequestPaint} = dynamicFeatureFlags;
14
15 -export const enableSchedulerDebugging = false;
15 export const enableProfiling = __DEV__;
16 export const frameYieldMs = 10;
17
packages/scheduler/src/forks/SchedulerMock.js
+2 -30
@@ -12,10 +12,7 @@
12
13 import type {PriorityLevel} from '../SchedulerPriorities';
14
15 -import {
16 - enableSchedulerDebugging,
17 - enableProfiling,
18 -} from '../SchedulerFeatureFlags';
15 +import {enableProfiling} from '../SchedulerFeatureFlags';
16 import {push, pop, peek} from '../SchedulerMinHeap';
17
18 // TODO: Use symbols?
@@ -72,9 +69,6 @@ var timerQueue: Array<Task> = [];
69 // Incrementing id counter. Used to maintain insertion order.
70 var taskIdCounter = 1;
71
75 -// Pausing the scheduler is useful for debugging.
76 -var isSchedulerPaused = false;
77 -
72 var currentTask = null;
73 var currentPriorityLevel = NormalPriority;
74
@@ -195,10 +189,7 @@ function workLoop(hasTimeRemaining: boolean, initialTime: number): boolean {
189 let currentTime = initialTime;
190 advanceTimers(currentTime);
191 currentTask = peek(taskQueue);
198 - while (
199 - currentTask !== null &&
200 - !(enableSchedulerDebugging && isSchedulerPaused)
201 - ) {
192 + while (currentTask !== null) {
193 if (
194 currentTask.expirationTime > currentTime &&
195 (!hasTimeRemaining || shouldYieldToHost())
@@ -422,22 +413,6 @@ function unstable_scheduleCallback(
413 return newTask;
414 }
415
425 -function unstable_pauseExecution() {
426 - isSchedulerPaused = true;
427 -}
428 -
429 -function unstable_continueExecution() {
430 - isSchedulerPaused = false;
431 - if (!isHostCallbackScheduled && !isPerformingWork) {
432 - isHostCallbackScheduled = true;
433 - requestHostCallback(flushWork);
434 - }
435 -}
436 -
437 -function unstable_getFirstCallbackNode(): Task | null {
438 - return peek(taskQueue);
439 -}
440 -
416 function unstable_cancelCallback(task: Task) {
417 if (enableProfiling) {
418 if (task.isQueued) {
@@ -679,9 +654,6 @@ export {
654 unstable_getCurrentPriorityLevel,
655 shouldYieldToHost as unstable_shouldYield,
656 requestPaint as unstable_requestPaint,
682 - unstable_continueExecution,
683 - unstable_pauseExecution,
684 - unstable_getFirstCallbackNode,
657 getCurrentTime as unstable_now,
658 forceFrameRate as unstable_forceFrameRate,
659 unstable_flushAllWithoutAsserting,
packages/scheduler/src/forks/SchedulerNative.js
-3
@@ -97,9 +97,6 @@ export const unstable_now: () => number | DOMHighResTimeStamp =
97 export const unstable_next: any = throwNotImplemented;
98 export const unstable_runWithPriority: any = throwNotImplemented;
99 export const unstable_wrapCallback: any = throwNotImplemented;
100 -export const unstable_continueExecution: any = throwNotImplemented;
101 -export const unstable_pauseExecution: any = throwNotImplemented;
102 -export const unstable_getFirstCallbackNode: any = throwNotImplemented;
100 export const unstable_forceFrameRate: any = throwNotImplemented;
101 export const unstable_Profiling: any = null;
102
packages/scheduler/src/forks/SchedulerPostTask.js
-8
@@ -234,13 +234,5 @@ export function unstable_wrapCallback<T>(callback: () => T): () => T {
234
235 export function unstable_forceFrameRate() {}
236
237 -export function unstable_pauseExecution() {}
238 -
239 -export function unstable_continueExecution() {}
240 -
241 -export function unstable_getFirstCallbackNode(): null {
242 - return null;
243 -}
244 -
237 // Currently no profiling build
238 export const unstable_Profiling = null;
scripts/jest/setupTests.www.js
+3 -3
@@ -34,9 +34,9 @@ jest.mock('scheduler/src/SchedulerFeatureFlags', () => {
34 schedulerSrcPath + '/src/forks/SchedulerFeatureFlags.www'
35 );
36
37 - // These flags are not a dynamic on www, but we still want to run
38 - // tests in both versions.
39 - actual.enableSchedulerDebugging = __VARIANT__;
37 + // Add flags here that are not a dynamic on www,
38 + // but we still want to run tests in both versions.
39 + // <this list is empty>
40
41 return actual;
42 });