facebook/react

Bug: Scheduler default time interval problem

classmatewu opened this issue · 1 comments

Hello React Team,

While reviewing the packages/scheduler/src/SchedulerFeatureFlags.js file, I noticed that the default frame yield time (frameYieldMs) is set to 5 milliseconds:

export const frameYieldMs = 5;

I have a few questions regarding this configuration and would appreciate your clarification:

  1. Why is 5ms Chosen as the Default Value?
    Why not set it to 16.7ms (which corresponds to the 60fps frame rate of most screens) or 50ms (the threshold for long tasks defined by browsers)?
    Impact of Frequent Task Interruptions

  2. Does setting it to 5ms cause tasks to be interrupted too frequently?
    Considering that calling performance.now() itself might take more than 5ms, could this lead to performance overhead?

  3. Is This a Bug or an Intended Feature?
    Is this setting intentional to optimize specific performance scenarios?
    Or could it potentially lead to unintended task interruption issues?

Additional Information
React Version: 17.0.2
Browser Environment: Chrome Version 112.0.5615.49
Steps to Reproduce:
When performing extensive layout computations, I observed that tasks are being frequently interrupted, which results in decreased rendering performance.
Expected Behavior:
The Scheduler should interrupt tasks near the frame time (approximately 16.7ms) to balance rendering performance and responsiveness effectively.
Actual Behavior:
With frameYieldMs set to 5ms, tasks are frequently interrupted, leading to increased scheduling overhead and rendering performance that falls below expectations.

Thank You
Thank you for your hard work and dedication to maintaining React! I look forward to your explanation and any insights you can provide regarding this configuration.