-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scheduler] Check for continuous input events #22107
[Scheduler] Check for continuous input events #22107
Conversation
Currently in `shouldYield`, we compare the current time to a deadline that is pre-computed at the beginning of the current chunk. However, since we use different deadlines depending on whether an input event is pending, it makes more sense to track the start of the current chunk and check how much time has elapsed since then. Doesn't change any behavior, just refactors the logic.
`isInputPending` supports a `includeContinuous` option. When set to `true`, the method will check for pending continuous inputs, like `mousemove`, in addition to discrete ones, like `click`. We will only check for pending continuous inputs if we've blocked the main thread for a non-neglible amount of time. If we've only blocked the main thread for, say, a few frames, then we'll only check for discrete inputs. I wrote a test for this but didn't include it because we haven't yet set up the `gate` flag infra to work with Scheduler feature flags. For now, I ran the test locally.
cc: @acomminos GitHub wouldn't let me request a review from you for some reason |
b158495
to
5b81d30
Compare
Comparing: 152ecce...5cce438 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
5b81d30
to
e28bcce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
} else if (timeElapsed < maxInterval) { | ||
// Yield if there's either a pending discrete or continuous input. | ||
if (isInputPending !== null) { | ||
return isInputPending({includeContinuous: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we declare the arg above as continuousOptions
(or something similar) in module scope to avoid an object allocation each call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
@@ -499,7 +515,7 @@ const performWorkUntilDeadline = () => { | |||
// Yield after `yieldInterval` ms, regardless of where we are in the vsync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment needs to be updated :)
Summary: This sync includes the following changes: - **[424fe5870](facebook/react@424fe5870 )**: Revert "Show a soft error when a text string or number is supplied as a child to non text wrappers ([#21953](facebook/react#21953))" ([#22108](facebook/react#22108)) //<Sota>// - **[aebf3b456](facebook/react@aebf3b456 )**: [Scheduler] Check for continuous input events ([#22107](facebook/react#22107)) //<Andrew Clark>// - **[e9b2028b3](facebook/react@e9b2028b3 )**: Show a soft error when a text string or number is supplied as a child to non text wrappers ([#21953](facebook/react#21953)) //<Sota>// - **[ecd73e17b](facebook/react@ecd73e17b )**: Enable enableSuspenseLayoutEffectSemantics flag statically for Facebook ([#22050](facebook/react#22050)) //<Brian Vaughn>// - **[a8725a3e6](facebook/react@a8725a3e6 )**: Scheduling profiler: Added lane labels and durations to React measures ([#22029](facebook/react#22029)) //<Brian Vaughn>// Changelog: [General][Changed] - React Native sync for revisions 19092ac...5634ed1 jest_e2e[run_all_tests] Reviewed By: kacieb Differential Revision: D30225923 fbshipit-source-id: 562895d3e0d264f40770dadb89d4a16241967c4c
* [Scheduler] Track start of current chunk Currently in `shouldYield`, we compare the current time to a deadline that is pre-computed at the beginning of the current chunk. However, since we use different deadlines depending on whether an input event is pending, it makes more sense to track the start of the current chunk and check how much time has elapsed since then. Doesn't change any behavior, just refactors the logic. * [Scheduler] Check for continuous input events `isInputPending` supports a `includeContinuous` option. When set to `true`, the method will check for pending continuous inputs, like `mousemove`, in addition to discrete ones, like `click`. We will only check for pending continuous inputs if we've blocked the main thread for a non-neglible amount of time. If we've only blocked the main thread for, say, a few frames, then we'll only check for discrete inputs. I wrote a test for this but didn't include it because we haven't yet set up the `gate` flag infra to work with Scheduler feature flags. For now, I ran the test locally. * Review nits
isInputPending
supports aincludeContinuous
option. When set totrue
, the method will check for pending continuous inputs, likemousemove
, in addition to discrete ones, likeclick
.We will only check for pending continuous inputs if we've blocked the main thread for a non-negligible amount of time. If we've only blocked the main thread for, say, a few frames, then we'll only check for discrete inputs.
I wrote a test for this but didn't include it because we haven't yet set up the
gate
flag infra to work with Scheduler feature flags. For now, I ran the test locally.