Fix fiber memory leak with runAllPassiveEffectDestroysBeforeCreates (#18554)

This commit is contained in:
Dominic Gannaway
2020-04-09 15:35:07 +01:00
committed by GitHub
parent ca1a703d21
commit 0566b706ee
2 changed files with 28 additions and 22 deletions
@@ -2368,12 +2368,15 @@ function flushPassiveEffectsImpl() {
}
}
}
} else {
// Note: This currently assumes there are no passive effects on the root fiber
// because the root is not part of its own effect list.
// This could change in the future.
let effect = root.current.firstEffect;
while (effect !== null) {
}
// Note: This currently assumes there are no passive effects on the root fiber
// because the root is not part of its own effect list.
// This could change in the future.
let effect = root.current.firstEffect;
while (effect !== null) {
// We do this work above if this flag is enabled, so we shouldn't be
// doing it here.
if (!runAllPassiveEffectDestroysBeforeCreates) {
if (__DEV__) {
setCurrentDebugFiberInDEV(effect);
invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
@@ -2391,12 +2394,12 @@ function flushPassiveEffectsImpl() {
captureCommitPhaseError(effect, error);
}
}
const nextNextEffect = effect.nextEffect;
// Remove nextEffect pointer to assist GC
effect.nextEffect = null;
effect = nextNextEffect;
}
const nextNextEffect = effect.nextEffect;
// Remove nextEffect pointer to assist GC
effect.nextEffect = null;
effect = nextNextEffect;
}
if (enableProfilerTimer && enableProfilerCommitHooks) {
@@ -2368,12 +2368,15 @@ function flushPassiveEffectsImpl() {
}
}
}
} else {
// Note: This currently assumes there are no passive effects on the root fiber
// because the root is not part of its own effect list.
// This could change in the future.
let effect = root.current.firstEffect;
while (effect !== null) {
}
// Note: This currently assumes there are no passive effects on the root fiber
// because the root is not part of its own effect list.
// This could change in the future.
let effect = root.current.firstEffect;
while (effect !== null) {
// We do this work above if this flag is enabled, so we shouldn't be
// doing it here.
if (!runAllPassiveEffectDestroysBeforeCreates) {
if (__DEV__) {
setCurrentDebugFiberInDEV(effect);
invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
@@ -2391,12 +2394,12 @@ function flushPassiveEffectsImpl() {
captureCommitPhaseError(effect, error);
}
}
const nextNextEffect = effect.nextEffect;
// Remove nextEffect pointer to assist GC
effect.nextEffect = null;
effect = nextNextEffect;
}
const nextNextEffect = effect.nextEffect;
// Remove nextEffect pointer to assist GC
effect.nextEffect = null;
effect = nextNextEffect;
}
if (enableProfilerTimer && enableProfilerCommitHooks) {