@samitouri / QOS-React-2 / commits / 0566b706ee

Fix fiber memory leak with runAllPassiveEffectDestroysBeforeCreates (#18554)

Dominic Gannaway committed Apr 9, 2020 at 15:35 UTC 0566b706eefc41b1e5f479e0f745c229b8958ca2
2 files changed +28 -22
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+14 -11
@@ -2368,12 +2368,15 @@ function flushPassiveEffectsImpl() {
2368 }
2369 }
2370 }
2371 - } else {
2372 - // Note: This currently assumes there are no passive effects on the root fiber
2373 - // because the root is not part of its own effect list.
2374 - // This could change in the future.
2375 - let effect = root.current.firstEffect;
2376 - while (effect !== null) {
2371 + }
2372 + // Note: This currently assumes there are no passive effects on the root fiber
2373 + // because the root is not part of its own effect list.
2374 + // This could change in the future.
2375 + let effect = root.current.firstEffect;
2376 + while (effect !== null) {
2377 + // We do this work above if this flag is enabled, so we shouldn't be
2378 + // doing it here.
2379 + if (!runAllPassiveEffectDestroysBeforeCreates) {
2380 if (__DEV__) {
2381 setCurrentDebugFiberInDEV(effect);
2382 invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
@@ -2391,12 +2394,12 @@ function flushPassiveEffectsImpl() {
2394 captureCommitPhaseError(effect, error);
2395 }
2396 }
2394 -
2395 - const nextNextEffect = effect.nextEffect;
2396 - // Remove nextEffect pointer to assist GC
2397 - effect.nextEffect = null;
2398 - effect = nextNextEffect;
2397 }
2398 +
2399 + const nextNextEffect = effect.nextEffect;
2400 + // Remove nextEffect pointer to assist GC
2401 + effect.nextEffect = null;
2402 + effect = nextNextEffect;
2403 }
2404
2405 if (enableProfilerTimer && enableProfilerCommitHooks) {
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+14 -11
@@ -2368,12 +2368,15 @@ function flushPassiveEffectsImpl() {
2368 }
2369 }
2370 }
2371 - } else {
2372 - // Note: This currently assumes there are no passive effects on the root fiber
2373 - // because the root is not part of its own effect list.
2374 - // This could change in the future.
2375 - let effect = root.current.firstEffect;
2376 - while (effect !== null) {
2371 + }
2372 + // Note: This currently assumes there are no passive effects on the root fiber
2373 + // because the root is not part of its own effect list.
2374 + // This could change in the future.
2375 + let effect = root.current.firstEffect;
2376 + while (effect !== null) {
2377 + // We do this work above if this flag is enabled, so we shouldn't be
2378 + // doing it here.
2379 + if (!runAllPassiveEffectDestroysBeforeCreates) {
2380 if (__DEV__) {
2381 setCurrentDebugFiberInDEV(effect);
2382 invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
@@ -2391,12 +2394,12 @@ function flushPassiveEffectsImpl() {
2394 captureCommitPhaseError(effect, error);
2395 }
2396 }
2394 -
2395 - const nextNextEffect = effect.nextEffect;
2396 - // Remove nextEffect pointer to assist GC
2397 - effect.nextEffect = null;
2398 - effect = nextNextEffect;
2397 }
2398 +
2399 + const nextNextEffect = effect.nextEffect;
2400 + // Remove nextEffect pointer to assist GC
2401 + effect.nextEffect = null;
2402 + effect = nextNextEffect;
2403 }
2404
2405 if (enableProfilerTimer && enableProfilerCommitHooks) {