Skip to content
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

[WIP] Fix for fiber root scheduling memory leak #11644

Merged
merged 2 commits into from
Nov 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 24 additions & 14 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,27 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
return scheduleWorkImpl(fiber, expirationTime, false);
}

function checkRootNeedsClearing(
root: FiberRoot,
fiber: Fiber,
expirationTime: ExpirationTime,
) {
if (
!isWorking &&
root === nextRoot &&
expirationTime < nextRenderExpirationTime
) {
// Restart the root from the top.
if (nextUnitOfWork !== null) {
// This is an interruption. (Used for performance tracking.)
interruptedBy = fiber;
}
nextRoot = null;
nextUnitOfWork = null;
nextRenderExpirationTime = NoWork;
}
}

function scheduleWorkImpl(
fiber: Fiber,
expirationTime: ExpirationTime,
Expand Down Expand Up @@ -1203,21 +1224,10 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
if (node.return === null) {
if (node.tag === HostRoot) {
const root: FiberRoot = (node.stateNode: any);
if (
!isWorking &&
root === nextRoot &&
expirationTime < nextRenderExpirationTime
) {
// Restart the root from the top.
if (nextUnitOfWork !== null) {
// This is an interruption. (Used for performance tracking.)
interruptedBy = fiber;
}
nextRoot = null;
nextUnitOfWork = null;
nextRenderExpirationTime = NoWork;
}

checkRootNeedsClearing(root, fiber, expirationTime);
requestWork(root, expirationTime);
checkRootNeedsClearing(root, fiber, expirationTime);
} else {
if (__DEV__) {
if (!isErrorRecovery && fiber.tag === ClassComponent) {
Expand Down