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
Remove callbackId field from FiberRoot #19458
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -677,10 +677,10 @@ function markUpdateLaneFromFiberToRoot( | |
} | ||
|
||
// Use this function to schedule a task for a root. There's only one task per | ||
// root; if a task was already scheduled, we'll check to make sure the | ||
// expiration time of the existing task is the same as the expiration time of | ||
// the next level that the root has work on. This function is called on every | ||
// update, and right before exiting a task. | ||
// root; if a task was already scheduled, we'll check to make sure the priority | ||
// of the existing task is the same as the priority of the next level that the | ||
// root has work on. This function is called on every update, and right before | ||
// exiting a task. | ||
function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | ||
const existingCallbackNode = root.callbackNode; | ||
|
||
|
@@ -689,37 +689,32 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | |
markStarvedLanesAsExpired(root, currentTime); | ||
|
||
// Determine the next lanes to work on, and their priority. | ||
const newCallbackId = getNextLanes( | ||
const nextLanes = getNextLanes( | ||
root, | ||
root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes, | ||
); | ||
// This returns the priority level computed during the `getNextLanes` call. | ||
const newCallbackPriority = returnNextLanesPriority(); | ||
|
||
if (newCallbackId === NoLanes) { | ||
if (nextLanes === NoLanes) { | ||
// Special case: There's nothing to work on. | ||
if (existingCallbackNode !== null) { | ||
cancelCallback(existingCallbackNode); | ||
root.callbackNode = null; | ||
root.callbackPriority = NoLanePriority; | ||
root.callbackId = NoLanes; | ||
} | ||
return; | ||
} | ||
|
||
// Check if there's an existing task. We may be able to reuse it. | ||
const existingCallbackId = root.callbackId; | ||
const existingCallbackPriority = root.callbackPriority; | ||
if (existingCallbackId !== NoLanes) { | ||
if (newCallbackId === existingCallbackId) { | ||
// This task is already scheduled. Let's check its priority. | ||
if (existingCallbackPriority === newCallbackPriority) { | ||
// The priority hasn't changed. Exit. | ||
return; | ||
} | ||
// The task ID is the same but the priority changed. Cancel the existing | ||
// callback. We'll schedule a new one below. | ||
if (existingCallbackNode !== null) { | ||
const existingCallbackPriority = root.callbackPriority; | ||
if (existingCallbackPriority === newCallbackPriority) { | ||
// The priority hasn't changed. We can reuse the existing task. Exit. | ||
return; | ||
} | ||
// The priority changed. Cancel the existing callback. We'll schedule a new | ||
// one below. | ||
cancelCallback(existingCallbackNode); | ||
} | ||
|
||
|
@@ -741,7 +736,6 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | |
); | ||
} | ||
|
||
root.callbackId = newCallbackId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We used to update the root There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was only used by this function. Since we don't need it for the logic above anymore, we don't have to store it. |
||
root.callbackPriority = newCallbackPriority; | ||
root.callbackNode = newCallbackNode; | ||
} | ||
|
@@ -2041,7 +2035,6 @@ function commitRootImpl(root, renderPriorityLevel) { | |
// commitRoot never returns a continuation; it always finishes synchronously. | ||
// So we can clear these now to allow a new callback to be scheduled. | ||
root.callbackNode = null; | ||
root.callbackId = NoLanes; | ||
|
||
// Update the first and last pending times on this root. The new first | ||
// pending time is whatever is left on the root fiber. | ||
|
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.
Looks like the comment on line 681 (which references the expiration time) is out of date, should we update that as well?