-
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
Expiration times #10426
Expiration times #10426
Conversation
ee127ed
to
796db96
Compare
Confirms that this makes the Triangle demo work as expected. Still need to write some unit tests, but this is ready for review. |
Added unit tests. I confirmed that all the existing tests, including the sync DOM ones, are passing when expiration is enabled. |
@@ -249,6 +249,11 @@ var TestRenderer = ReactFiberReconciler({ | |||
useSyncScheduling: true, | |||
|
|||
getPublicInstance, | |||
|
|||
now(): number { | |||
// Test renderer does not use expiration |
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.
@sebmarkbage I went back and forth on whether this should be an optional method. Landed on making it required because all renderers will need to account for features like expiration boundaries.
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.
Since scheduleDeferredCallback
is required it seems reasonable that this would be too since they kind of pair together.
@@ -163,6 +163,22 @@ function shouldAutoFocusHostComponent(type: string, props: Props): boolean { | |||
return false; | |||
} | |||
|
|||
// TODO: Better polyfill |
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.
Is this polyfill sufficient? Or am I overlooking something?
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.
It's fine. Maybe we should colocate it with ReactDOMFrameScheduling
to have all these in one place?
It is also performance.now
aware: https://github.com/facebook/react/blob/master/src/renderers/shared/ReactDOMFrameScheduling.js#L73
67388a1
to
14e68e3
Compare
window.performance && | ||
typeof window.performance.now === 'function' | ||
) { | ||
now = function() { |
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.
Why not now = performance.now
and now = Date.now
?
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.
performance.now
needs to be bound, but looks like Date.now
doesn't. I'll update.
da21094
to
43360d9
Compare
0d4f363
to
36244ac
Compare
@@ -42,7 +42,7 @@ var { | |||
Fragment, | |||
} = ReactTypeOfWork; | |||
var {Placement, Ref, Update} = ReactTypeOfSideEffect; | |||
var {OffscreenPriority} = ReactPriorityLevel; | |||
var {Never} = ReactFiberExpirationTime; |
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 like that this name change decouples this expiration time from the UI context in which it's used. What we really mean is 'this might never finish updating, and that's ok' and that may or may not be literally "offscreen" in the UI.
TaskPriority, | ||
HighPriority, | ||
LowPriority, | ||
OffscreenPriority, |
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.
haha, I guess it's not a rename after all. ("OffscreenPriority" to "Never" expirationTime)
Deploy preview ready! Built with commit 564c7e9 |
@gaearon I’ve rebased this locally, just haven’t pushed yet. I’ll work on getting all my PRs updated tomorrow. |
An expiration time represents a time in the future by which an update should flush. The priority of the update is related to the difference between the current clock time and the expiration time. This has the effect of increasing the priority of updates as time progresses, to prevent starvation.