Skip to content

Commit

Permalink
Flag for requestPaint
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Dec 16, 2024
1 parent e06c72f commit c4b1826
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/scheduler/src/SchedulerFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export const frameYieldMs = 5;
export const userBlockingPriorityTimeout = 250;
export const normalPriorityTimeout = 5000;
export const lowPriorityTimeout = 10000;
export const enableRequestPaint = true;
11 changes: 8 additions & 3 deletions packages/scheduler/src/forks/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
userBlockingPriorityTimeout,
lowPriorityTimeout,
normalPriorityTimeout,
enableRequestPaint,
} from '../SchedulerFeatureFlags';

import {push, pop, peek} from '../SchedulerMinHeap';
Expand Down Expand Up @@ -458,7 +459,7 @@ let frameInterval = frameYieldMs;
let startTime = -1;

function shouldYieldToHost(): boolean {
if (needsPaint) {
if (enableRequestPaint && needsPaint) {
// Yield now.
return true;
}
Expand All @@ -473,7 +474,9 @@ function shouldYieldToHost(): boolean {
}

function requestPaint() {
needsPaint = true;
if (enableRequestPaint) {
needsPaint = true;
}
}

function forceFrameRate(fps: number) {
Expand All @@ -494,7 +497,9 @@ function forceFrameRate(fps: number) {
}

const performWorkUntilDeadline = () => {
needsPaint = false;
if (enableRequestPaint) {
needsPaint = false;
}
if (isMessageLoopRunning) {
const currentTime = getCurrentTime();
// Keep track of the start time so we can measure how long the main thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {enableRequestPaint} from '../SchedulerFeatureFlags';

// In www, these flags are controlled by GKs. Because most GKs have some
// population running in either mode, we should run our tests that way, too,
Expand All @@ -14,3 +15,4 @@
export const userBlockingPriorityTimeout = 250;
export const normalPriorityTimeout = 5000;
export const lowPriorityTimeout = 10000;
export const enableRequestPaint = __VARIANT__;

Check failure on line 18 in packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js

View workflow job for this annotation

GitHub Actions / Run eslint

'enableRequestPaint' is assigned a value but never used
1 change: 1 addition & 0 deletions packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const {
userBlockingPriorityTimeout,
normalPriorityTimeout,
lowPriorityTimeout,
enableRequestPaint,
} = dynamicFeatureFlags;

export const frameYieldMs = 10;
Expand Down

0 comments on commit c4b1826

Please sign in to comment.