From c72b1da62aa69edb4dd7cafab65c404bd96e24c8 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Wed, 29 Sep 2021 14:46:17 -0700 Subject: [PATCH] Release pooled cache reference in complete/unwind --- .../src/ReactFiberCacheComponent.new.js | 10 ++++++---- .../src/ReactFiberCacheComponent.old.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCacheComponent.new.js b/packages/react-reconciler/src/ReactFiberCacheComponent.new.js index 042a8b2efc098..0d284c683ed1f 100644 --- a/packages/react-reconciler/src/ReactFiberCacheComponent.new.js +++ b/packages/react-reconciler/src/ReactFiberCacheComponent.new.js @@ -99,14 +99,16 @@ export function popRootCachePool(root: FiberRoot, renderLanes: Lanes) { return; } // The `pooledCache` variable points to the cache that was used for new - // cache boundaries during this render, if any. Stash it on the root so that - // parallel transitions may share the same cache. We will clear this field - // once all the transitions that depend on it (which we track with - // `pooledCacheLanes`) have committed. + // cache boundaries during this render, if any. Move ownership of the + // cache to the root so that parallel transitions may share the same + // cache. We will clear this field once all the transitions that depend + // on it (which we track with `pooledCacheLanes`) have committed. root.pooledCache = pooledCache; if (pooledCache !== null) { root.pooledCacheLanes |= renderLanes; } + // set to null, conceptually we are moving ownership to the root + pooledCache = null; } export function restoreSpawnedCachePool( diff --git a/packages/react-reconciler/src/ReactFiberCacheComponent.old.js b/packages/react-reconciler/src/ReactFiberCacheComponent.old.js index 2bc64254d3092..dd450fff76b50 100644 --- a/packages/react-reconciler/src/ReactFiberCacheComponent.old.js +++ b/packages/react-reconciler/src/ReactFiberCacheComponent.old.js @@ -99,14 +99,16 @@ export function popRootCachePool(root: FiberRoot, renderLanes: Lanes) { return; } // The `pooledCache` variable points to the cache that was used for new - // cache boundaries during this render, if any. Stash it on the root so that - // parallel transitions may share the same cache. We will clear this field - // once all the transitions that depend on it (which we track with - // `pooledCacheLanes`) have committed. + // cache boundaries during this render, if any. Move ownership of the + // cache to the root so that parallel transitions may share the same + // cache. We will clear this field once all the transitions that depend + // on it (which we track with `pooledCacheLanes`) have committed. root.pooledCache = pooledCache; if (pooledCache !== null) { root.pooledCacheLanes |= renderLanes; } + // set to null, conceptually we are moving ownership to the root + pooledCache = null; } export function restoreSpawnedCachePool(