diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index 89d4ea77deb48..2e85f649c6200 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -484,11 +484,12 @@ var Visibility = 8192; var StoreConsistency = /* */ - 16384; // It's OK to reuse this bit because these flags are mutually exclusive for + 16384; // It's OK to reuse these bits because these flags are mutually exclusive for // different fiber types. We should really be doing this for as many flags as // possible, because we're about to run out of bits. var ScheduleRetry = StoreConsistency; +var ShouldSuspendCommit = Visibility; var LifecycleEffectMask = Passive$1 | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit) @@ -522,8 +523,8 @@ var LayoutStatic = var PassiveStatic = /* */ 8388608; -var SuspenseyCommit = - /* */ +var MaySuspendCommit = + /* */ 16777216; // Flag used to identify newly inserted fibers. It isn't reset after commit unlike `Placement`. var PlacementDEV = @@ -554,7 +555,7 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that // This allows certain concepts to persist without recalculating them, // e.g. whether a subtree contains passive effects or portals. -var StaticMask = LayoutStatic | PassiveStatic | RefStatic | SuspenseyCommit; +var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -2023,9 +2024,6 @@ function unhideInstance(instance, props) { function unhideTextInstance(textInstance, text) { textInstance.isHidden = false; } -function maySuspendCommit(type, props) { - return false; -} function preloadInstance(type, props) { // Return true to indicate it's already loaded return true; @@ -4310,13 +4308,6 @@ function trackUsedThenable(thenableState, thenable, index) { } } } -function suspendCommit() { - // This extra indirection only exists so it can handle passing - // noopSuspenseyCommitThenable through to throwException. - // TODO: Factor the thenable check out of throwException - suspendedThenable = noopSuspenseyCommitThenable; - throw SuspenseyCommitException; -} // This is used to track the actual thenable that suspended so it can be // passed to the rest of the Suspense implementation — which, for historical // reasons, expects to receive a thenable. @@ -14604,7 +14595,11 @@ function updateHostComponent( markUpdate(workInProgress); } } -} // TODO: This should ideally move to begin phase, but currently the instance is +} // This function must be called at the very end of the complete phase, because +// it might throw to suspend, and if the resource immediately loads, the work +// loop will resume rendering as if the work-in-progress completed. So it must +// fully complete. +// TODO: This should ideally move to begin phase, but currently the instance is // not created until the complete phase. For our existing use cases, host nodes // that suspend don't have children, so it doesn't matter. But that might not // always be true in the future. @@ -14615,28 +14610,16 @@ function preloadInstanceAndSuspendIfNeeded( props, renderLanes ) { - workInProgress.flags |= SuspenseyCommit; // Check if we're rendering at a "non-urgent" priority. This is the same - // check that `useDeferredValue` does to determine whether it needs to - // defer. This is partly for gradual adoption purposes (i.e. shouldn't start - // suspending until you opt in with startTransition or Suspense) but it - // also happens to be the desired behavior for the concrete use cases we've - // thought of so far, like CSS loading, fonts, images, etc. - // TODO: We may decide to expose a way to force a fallback even during a - // sync update. - - if (!includesOnlyNonUrgentLanes(renderLanes)); - else { - // Preload the instance - var isReady = preloadInstance(); - - if (!isReady) { - if (shouldRemainOnPreviousScreen()); - else { - // Trigger a fallback rather than block the render. - suspendCommit(); - } - } - } + { + // If this flag was set previously, we can remove it. The flag + // represents whether this particular set of props might ever need to + // suspend. The safest thing to do is for maySuspendCommit to always + // return true, but if the renderer is reasonably confident that the + // underlying resource won't be evicted, it can return false as a + // performance optimization. + workInProgress.flags &= ~MaySuspendCommit; + return; + } // Mark this fiber with a flag. This gets set on all host instances } function scheduleRetryEffect(workInProgress, retryQueue) { @@ -15042,12 +15025,10 @@ function completeWork(current, workInProgress, renderLanes) { case HostComponent: { popHostContext(workInProgress); - var _type = workInProgress.type; - - var _maySuspend = maySuspendCommit(); + var _type2 = workInProgress.type; if (current !== null && workInProgress.stateNode != null) { - updateHostComponent(current, workInProgress, _type, newProps); + updateHostComponent(current, workInProgress, _type2, newProps); if (current.ref !== workInProgress.ref) { markRef(workInProgress); @@ -15084,7 +15065,7 @@ function completeWork(current, workInProgress, renderLanes) { var _rootContainerInstance = getRootHostContainer(); var _instance3 = createInstance( - _type, + _type2, newProps, _rootContainerInstance, _currentHostContext2, @@ -15106,17 +15087,7 @@ function completeWork(current, workInProgress, renderLanes) { // will resume rendering as if the work-in-progress completed. So it must // fully complete. - if (_maySuspend) { - preloadInstanceAndSuspendIfNeeded( - workInProgress, - _type, - newProps, - renderLanes - ); - } else { - workInProgress.flags &= ~SuspenseyCommit; - } - + preloadInstanceAndSuspendIfNeeded(workInProgress); return null; } @@ -18973,13 +18944,24 @@ function commitPassiveUnmountEffects(finishedWork) { setCurrentFiber(finishedWork); commitPassiveUnmountOnFiber(finishedWork); resetCurrentFiber(); -} +} // If we're inside a brand new tree, or a tree that was already visible, then we +// should only suspend host components that have a ShouldSuspendCommit flag. +// Components without it haven't changed since the last commit, so we can skip +// over those. +// +// When we enter a tree that is being revealed (going from hidden -> visible), +// we need to suspend _any_ component that _may_ suspend. Even if they're +// already in the "current" tree. Because their visibility has changed, the +// browser may not have prerendered them yet. So we check the MaySuspendCommit +// flag instead. + +var suspenseyCommitFlag = ShouldSuspendCommit; function accumulateSuspenseyCommit(finishedWork) { accumulateSuspenseyCommitOnFiber(finishedWork); } function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & SuspenseyCommit) { + if (parentFiber.subtreeFlags & suspenseyCommitFlag) { var child = parentFiber.child; while (child !== null) { @@ -18994,7 +18976,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case HostHoistable: { recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & SuspenseyCommit) { + if (fiber.flags & suspenseyCommitFlag) { if (fiber.memoizedState !== null) { suspendResource(); } @@ -19010,8 +18992,36 @@ function accumulateSuspenseyCommitOnFiber(fiber) { } case HostRoot: - case HostPortal: - // eslint-disable-next-line-no-fallthrough + case HostPortal: { + { + recursivelyAccumulateSuspenseyCommit(fiber); + } + + break; + } + + case OffscreenComponent: { + var isHidden = fiber.memoizedState !== null; + + if (isHidden); + else { + var current = fiber.alternate; + var wasHidden = current !== null && current.memoizedState !== null; + + if (wasHidden) { + // This tree is being revealed. Visit all newly visible suspensey + // instances, even if they're in the current tree. + var prevFlags = suspenseyCommitFlag; + suspenseyCommitFlag = MaySuspendCommit; + recursivelyAccumulateSuspenseyCommit(fiber); + suspenseyCommitFlag = prevFlags; + } else { + recursivelyAccumulateSuspenseyCommit(fiber); + } + } + + break; + } default: { recursivelyAccumulateSuspenseyCommit(fiber); @@ -20792,15 +20802,24 @@ function shouldRemainOnPreviousScreen() { if (handler === null); else { - if (includesOnlyRetries(workInProgressRootRenderLanes)) { + if ( + includesOnlyRetries(workInProgressRootRenderLanes) || // In this context, an OffscreenLane counts as a Retry + // TODO: It's become increasingly clear that Retries and Offscreen are + // deeply connected. They probably can be unified further. + includesSomeLane(workInProgressRootRenderLanes, OffscreenLane) + ) { // During a retry, we can suspend rendering if the nearest Suspense boundary // is the boundary of the "shell", because we're guaranteed not to block // any new content from appearing. + // + // The reason we must check if this is a retry is because it guarantees + // that suspending the work loop won't block an actual update, because + // retries don't "update" anything; they fill in fallbacks that were left + // behind by a previous transition. return handler === getShellBoundary(); } } // For all other Lanes besides Transitions and Retries, we should not wait // for the data to load. - // TODO: We should wait during Offscreen prerendering, too. return false; } @@ -23743,7 +23762,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-d12bdcda6-20230325"; +var ReactVersion = "18.3.0-next-768f965de-20230326"; // Might add PROFILE later. diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js index f4145f26d7ce2..0c3d37629ea3c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -6038,8 +6038,9 @@ function recursivelyTraverseAtomicPassiveEffects( parentFiber = parentFiber.sibling; } } +var suspenseyCommitFlag = 8192; function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & 16777216) + if (parentFiber.subtreeFlags & suspenseyCommitFlag) for (parentFiber = parentFiber.child; null !== parentFiber; ) accumulateSuspenseyCommitOnFiber(parentFiber), (parentFiber = parentFiber.sibling); @@ -6048,7 +6049,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { switch (fiber.tag) { case 26: recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & 16777216 && null !== fiber.memoizedState) + if (fiber.flags & suspenseyCommitFlag && null !== fiber.memoizedState) throw Error( "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); @@ -6056,6 +6057,21 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case 5: recursivelyAccumulateSuspenseyCommit(fiber); break; + case 3: + case 4: + recursivelyAccumulateSuspenseyCommit(fiber); + break; + case 22: + if (null === fiber.memoizedState) { + var current = fiber.alternate; + null !== current && null !== current.memoizedState + ? ((current = suspenseyCommitFlag), + (suspenseyCommitFlag = 16777216), + recursivelyAccumulateSuspenseyCommit(fiber), + (suspenseyCommitFlag = current)) + : recursivelyAccumulateSuspenseyCommit(fiber); + } + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -6756,11 +6772,12 @@ function handleThrow(root, thrownValue) { ? (root = null === shellBoundary ? !0 : !1) : ((root = suspenseHandlerStackCursor.current), (root = - null !== root && - (workInProgressRootRenderLanes & 125829120) === - workInProgressRootRenderLanes - ? root === shellBoundary - : !1)), + null === root || + ((workInProgressRootRenderLanes & 125829120) !== + workInProgressRootRenderLanes && + 0 === (workInProgressRootRenderLanes & 1073741824)) + ? !1 + : root === shellBoundary)), (workInProgressSuspendedReason = root && 0 === (workInProgressRootSkippedLanes & 268435455) && @@ -8618,19 +8635,19 @@ function wrapFiber(fiber) { fiberToWrapper.set(fiber, wrapper)); return wrapper; } -var devToolsConfig$jscomp$inline_1002 = { +var devToolsConfig$jscomp$inline_1007 = { findFiberByHostInstance: function () { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-d12bdcda6-20230325", + version: "18.3.0-next-768f965de-20230326", rendererPackageName: "react-test-renderer" }; -var internals$jscomp$inline_1193 = { - bundleType: devToolsConfig$jscomp$inline_1002.bundleType, - version: devToolsConfig$jscomp$inline_1002.version, - rendererPackageName: devToolsConfig$jscomp$inline_1002.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1002.rendererConfig, +var internals$jscomp$inline_1198 = { + bundleType: devToolsConfig$jscomp$inline_1007.bundleType, + version: devToolsConfig$jscomp$inline_1007.version, + rendererPackageName: devToolsConfig$jscomp$inline_1007.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1007.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8647,26 +8664,26 @@ var internals$jscomp$inline_1193 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1002.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1007.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-d12bdcda6-20230325" + reconcilerVersion: "18.3.0-next-768f965de-20230326" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1194 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1199 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1194.isDisabled && - hook$jscomp$inline_1194.supportsFiber + !hook$jscomp$inline_1199.isDisabled && + hook$jscomp$inline_1199.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1194.inject( - internals$jscomp$inline_1193 + (rendererID = hook$jscomp$inline_1199.inject( + internals$jscomp$inline_1198 )), - (injectedHook = hook$jscomp$inline_1194); + (injectedHook = hook$jscomp$inline_1199); } catch (err) {} } exports._Scheduler = Scheduler; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js index e061d7d0aa148..7feef715b5834 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -6354,8 +6354,9 @@ function recursivelyTraverseAtomicPassiveEffects( parentFiber = parentFiber.sibling; } } +var suspenseyCommitFlag = 8192; function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & 16777216) + if (parentFiber.subtreeFlags & suspenseyCommitFlag) for (parentFiber = parentFiber.child; null !== parentFiber; ) accumulateSuspenseyCommitOnFiber(parentFiber), (parentFiber = parentFiber.sibling); @@ -6364,7 +6365,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { switch (fiber.tag) { case 26: recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & 16777216 && null !== fiber.memoizedState) + if (fiber.flags & suspenseyCommitFlag && null !== fiber.memoizedState) throw Error( "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); @@ -6372,6 +6373,21 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case 5: recursivelyAccumulateSuspenseyCommit(fiber); break; + case 3: + case 4: + recursivelyAccumulateSuspenseyCommit(fiber); + break; + case 22: + if (null === fiber.memoizedState) { + var current = fiber.alternate; + null !== current && null !== current.memoizedState + ? ((current = suspenseyCommitFlag), + (suspenseyCommitFlag = 16777216), + recursivelyAccumulateSuspenseyCommit(fiber), + (suspenseyCommitFlag = current)) + : recursivelyAccumulateSuspenseyCommit(fiber); + } + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -7095,11 +7111,12 @@ function handleThrow(root, thrownValue) { ? (root = null === shellBoundary ? !0 : !1) : ((root = suspenseHandlerStackCursor.current), (root = - null !== root && - (workInProgressRootRenderLanes & 125829120) === - workInProgressRootRenderLanes - ? root === shellBoundary - : !1)), + null === root || + ((workInProgressRootRenderLanes & 125829120) !== + workInProgressRootRenderLanes && + 0 === (workInProgressRootRenderLanes & 1073741824)) + ? !1 + : root === shellBoundary)), (workInProgressSuspendedReason = root && 0 === (workInProgressRootSkippedLanes & 268435455) && @@ -9043,19 +9060,19 @@ function wrapFiber(fiber) { fiberToWrapper.set(fiber, wrapper)); return wrapper; } -var devToolsConfig$jscomp$inline_1045 = { +var devToolsConfig$jscomp$inline_1050 = { findFiberByHostInstance: function () { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "18.3.0-next-d12bdcda6-20230325", + version: "18.3.0-next-768f965de-20230326", rendererPackageName: "react-test-renderer" }; -var internals$jscomp$inline_1234 = { - bundleType: devToolsConfig$jscomp$inline_1045.bundleType, - version: devToolsConfig$jscomp$inline_1045.version, - rendererPackageName: devToolsConfig$jscomp$inline_1045.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1045.rendererConfig, +var internals$jscomp$inline_1239 = { + bundleType: devToolsConfig$jscomp$inline_1050.bundleType, + version: devToolsConfig$jscomp$inline_1050.version, + rendererPackageName: devToolsConfig$jscomp$inline_1050.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1050.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9072,26 +9089,26 @@ var internals$jscomp$inline_1234 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1045.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1050.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-d12bdcda6-20230325" + reconcilerVersion: "18.3.0-next-768f965de-20230326" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1235 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1240 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1235.isDisabled && - hook$jscomp$inline_1235.supportsFiber + !hook$jscomp$inline_1240.isDisabled && + hook$jscomp$inline_1240.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1235.inject( - internals$jscomp$inline_1234 + (rendererID = hook$jscomp$inline_1240.inject( + internals$jscomp$inline_1239 )), - (injectedHook = hook$jscomp$inline_1235); + (injectedHook = hook$jscomp$inline_1240); } catch (err) {} } exports._Scheduler = Scheduler; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index eec433b17ba43..a70ee3704e90f 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-next-d12bdcda6-20230325"; +var ReactVersion = "18.3.0-next-768f965de-20230326"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js index 967d8de485a25..6852ae6a47c29 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-d12bdcda6-20230325"; +exports.version = "18.3.0-next-768f965de-20230326"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js index 98ed1f252f7f5..6894c4dd7232e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js @@ -642,7 +642,7 @@ exports.useSyncExternalStore = function ( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-next-d12bdcda6-20230325"; +exports.version = "18.3.0-next-768f965de-20230326"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index dd4e3ba16f7f7..dab5c4b86a46a 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -d12bdcda69afd219f4d91cbd60d6fae2a375d35b +768f965de2d4c6be7f688562ef02382478c82e5b diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 68f72aa37b9ad..3e5d3c6df316c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -3254,11 +3254,12 @@ var Visibility = 8192; var StoreConsistency = /* */ - 16384; // It's OK to reuse this bit because these flags are mutually exclusive for + 16384; // It's OK to reuse these bits because these flags are mutually exclusive for // different fiber types. We should really be doing this for as many flags as // possible, because we're about to run out of bits. var ScheduleRetry = StoreConsistency; +var ShouldSuspendCommit = Visibility; var LifecycleEffectMask = Passive$1 | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit) @@ -3292,8 +3293,8 @@ var LayoutStatic = var PassiveStatic = /* */ 8388608; -var SuspenseyCommit = - /* */ +var MaySuspendCommit = + /* */ 16777216; // Flag used to identify newly inserted fibers. It isn't reset after commit unlike `Placement`. var PlacementDEV = @@ -3324,7 +3325,7 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that // This allows certain concepts to persist without recalculating them, // e.g. whether a subtree contains passive effects or portals. -var StaticMask = LayoutStatic | PassiveStatic | RefStatic | SuspenseyCommit; +var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; // This module only exists as an ESM wrapper around the external CommonJS var scheduleCallback$1 = Scheduler.unstable_scheduleCallback; @@ -5087,9 +5088,6 @@ function finalizeContainerChildren(container, newChildren) { completeRoot(container, newChildren); } function replaceContainerChildren(container, newChildren) {} -function maySuspendCommit(type, props) { - return false; -} function preloadInstance(type, props) { return true; } @@ -8020,13 +8018,6 @@ function trackUsedThenable(thenableState, thenable, index) { } } } -function suspendCommit() { - // This extra indirection only exists so it can handle passing - // noopSuspenseyCommitThenable through to throwException. - // TODO: Factor the thenable check out of throwException - suspendedThenable = noopSuspenseyCommitThenable; - throw SuspenseyCommitException; -} // This is used to track the actual thenable that suspended so it can be // passed to the rest of the Suspense implementation — which, for historical // reasons, expects to receive a thenable. @@ -18684,7 +18675,11 @@ function updateHostComponent( appendAllChildren(newInstance, workInProgress, false, false); } } -} // TODO: This should ideally move to begin phase, but currently the instance is +} // This function must be called at the very end of the complete phase, because +// it might throw to suspend, and if the resource immediately loads, the work +// loop will resume rendering as if the work-in-progress completed. So it must +// fully complete. +// TODO: This should ideally move to begin phase, but currently the instance is // not created until the complete phase. For our existing use cases, host nodes // that suspend don't have children, so it doesn't matter. But that might not // always be true in the future. @@ -18695,28 +18690,16 @@ function preloadInstanceAndSuspendIfNeeded( props, renderLanes ) { - workInProgress.flags |= SuspenseyCommit; // Check if we're rendering at a "non-urgent" priority. This is the same - // check that `useDeferredValue` does to determine whether it needs to - // defer. This is partly for gradual adoption purposes (i.e. shouldn't start - // suspending until you opt in with startTransition or Suspense) but it - // also happens to be the desired behavior for the concrete use cases we've - // thought of so far, like CSS loading, fonts, images, etc. - // TODO: We may decide to expose a way to force a fallback even during a - // sync update. - - if (!includesOnlyNonUrgentLanes(renderLanes)); - else { - // Preload the instance - var isReady = preloadInstance(); - - if (!isReady) { - if (shouldRemainOnPreviousScreen()); - else { - // Trigger a fallback rather than block the render. - suspendCommit(); - } - } - } + { + // If this flag was set previously, we can remove it. The flag + // represents whether this particular set of props might ever need to + // suspend. The safest thing to do is for maySuspendCommit to always + // return true, but if the renderer is reasonably confident that the + // underlying resource won't be evicted, it can return false as a + // performance optimization. + workInProgress.flags &= ~MaySuspendCommit; + return; + } // Mark this fiber with a flag. This gets set on all host instances } function scheduleRetryEffect(workInProgress, retryQueue) { @@ -19119,12 +19102,10 @@ function completeWork(current, workInProgress, renderLanes) { case HostComponent: { popHostContext(workInProgress); - var _type = workInProgress.type; - - var _maySuspend = maySuspendCommit(); + var _type2 = workInProgress.type; if (current !== null && workInProgress.stateNode != null) { - updateHostComponent(current, workInProgress, _type, newProps); + updateHostComponent(current, workInProgress, _type2, newProps); if (current.ref !== workInProgress.ref) { markRef(workInProgress); @@ -19161,7 +19142,7 @@ function completeWork(current, workInProgress, renderLanes) { var _rootContainerInstance = getRootHostContainer(); var _instance3 = createInstance( - _type, + _type2, newProps, _rootContainerInstance, _currentHostContext2, @@ -19183,17 +19164,7 @@ function completeWork(current, workInProgress, renderLanes) { // will resume rendering as if the work-in-progress completed. So it must // fully complete. - if (_maySuspend) { - preloadInstanceAndSuspendIfNeeded( - workInProgress, - _type, - newProps, - renderLanes - ); - } else { - workInProgress.flags &= ~SuspenseyCommit; - } - + preloadInstanceAndSuspendIfNeeded(workInProgress); return null; } @@ -22100,13 +22071,24 @@ function commitPassiveUnmountEffects(finishedWork) { setCurrentFiber(finishedWork); commitPassiveUnmountOnFiber(finishedWork); resetCurrentFiber(); -} +} // If we're inside a brand new tree, or a tree that was already visible, then we +// should only suspend host components that have a ShouldSuspendCommit flag. +// Components without it haven't changed since the last commit, so we can skip +// over those. +// +// When we enter a tree that is being revealed (going from hidden -> visible), +// we need to suspend _any_ component that _may_ suspend. Even if they're +// already in the "current" tree. Because their visibility has changed, the +// browser may not have prerendered them yet. So we check the MaySuspendCommit +// flag instead. + +var suspenseyCommitFlag = ShouldSuspendCommit; function accumulateSuspenseyCommit(finishedWork) { accumulateSuspenseyCommitOnFiber(finishedWork); } function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & SuspenseyCommit) { + if (parentFiber.subtreeFlags & suspenseyCommitFlag) { var child = parentFiber.child; while (child !== null) { @@ -22121,7 +22103,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case HostHoistable: { recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & SuspenseyCommit) { + if (fiber.flags & suspenseyCommitFlag) { if (fiber.memoizedState !== null) { suspendResource(); } @@ -22137,8 +22119,36 @@ function accumulateSuspenseyCommitOnFiber(fiber) { } case HostRoot: - case HostPortal: - // eslint-disable-next-line-no-fallthrough + case HostPortal: { + { + recursivelyAccumulateSuspenseyCommit(fiber); + } + + break; + } + + case OffscreenComponent: { + var isHidden = fiber.memoizedState !== null; + + if (isHidden); + else { + var current = fiber.alternate; + var wasHidden = current !== null && current.memoizedState !== null; + + if (wasHidden) { + // This tree is being revealed. Visit all newly visible suspensey + // instances, even if they're in the current tree. + var prevFlags = suspenseyCommitFlag; + suspenseyCommitFlag = MaySuspendCommit; + recursivelyAccumulateSuspenseyCommit(fiber); + suspenseyCommitFlag = prevFlags; + } else { + recursivelyAccumulateSuspenseyCommit(fiber); + } + } + + break; + } default: { recursivelyAccumulateSuspenseyCommit(fiber); @@ -23883,15 +23893,24 @@ function shouldRemainOnPreviousScreen() { if (handler === null); else { - if (includesOnlyRetries(workInProgressRootRenderLanes)) { + if ( + includesOnlyRetries(workInProgressRootRenderLanes) || // In this context, an OffscreenLane counts as a Retry + // TODO: It's become increasingly clear that Retries and Offscreen are + // deeply connected. They probably can be unified further. + includesSomeLane(workInProgressRootRenderLanes, OffscreenLane) + ) { // During a retry, we can suspend rendering if the nearest Suspense boundary // is the boundary of the "shell", because we're guaranteed not to block // any new content from appearing. + // + // The reason we must check if this is a retry is because it guarantees + // that suspending the work loop won't block an actual update, because + // retries don't "update" anything; they fill in fallbacks that were left + // behind by a previous transition. return handler === getShellBoundary(); } } // For all other Lanes besides Transitions and Retries, we should not wait // for the data to load. - // TODO: We should wait during Offscreen prerendering, too. return false; } @@ -27008,7 +27027,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-d12bdcda6-20230325"; +var ReactVersion = "18.3.0-next-768f965de-20230326"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index eccd021b08f32..4cd5aaae585cc 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7172,8 +7172,9 @@ function recursivelyTraverseReconnectPassiveEffects( parentFiber = parentFiber.sibling; } } +var suspenseyCommitFlag = 8192; function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & 16777216) + if (parentFiber.subtreeFlags & suspenseyCommitFlag) for (parentFiber = parentFiber.child; null !== parentFiber; ) accumulateSuspenseyCommitOnFiber(parentFiber), (parentFiber = parentFiber.sibling); @@ -7182,7 +7183,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { switch (fiber.tag) { case 26: recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & 16777216 && null !== fiber.memoizedState) + if (fiber.flags & suspenseyCommitFlag && null !== fiber.memoizedState) throw Error( "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); @@ -7190,6 +7191,21 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case 5: recursivelyAccumulateSuspenseyCommit(fiber); break; + case 3: + case 4: + recursivelyAccumulateSuspenseyCommit(fiber); + break; + case 22: + if (null === fiber.memoizedState) { + var current = fiber.alternate; + null !== current && null !== current.memoizedState + ? ((current = suspenseyCommitFlag), + (suspenseyCommitFlag = 16777216), + recursivelyAccumulateSuspenseyCommit(fiber), + (suspenseyCommitFlag = current)) + : recursivelyAccumulateSuspenseyCommit(fiber); + } + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -7851,11 +7867,12 @@ function handleThrow(root, thrownValue) { ? (root = null === shellBoundary ? !0 : !1) : ((root = suspenseHandlerStackCursor.current), (root = - null !== root && - (workInProgressRootRenderLanes & 125829120) === - workInProgressRootRenderLanes - ? root === shellBoundary - : !1)), + null === root || + ((workInProgressRootRenderLanes & 125829120) !== + workInProgressRootRenderLanes && + 0 === (workInProgressRootRenderLanes & 1073741824)) + ? !1 + : root === shellBoundary)), (workInProgressSuspendedReason = root && 0 === (workInProgressRootSkippedLanes & 268435455) && @@ -9487,10 +9504,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1022 = { + devToolsConfig$jscomp$inline_1027 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-d12bdcda6-20230325", + version: "18.3.0-next-768f965de-20230326", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9505,11 +9522,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1268 = { - bundleType: devToolsConfig$jscomp$inline_1022.bundleType, - version: devToolsConfig$jscomp$inline_1022.version, - rendererPackageName: devToolsConfig$jscomp$inline_1022.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1022.rendererConfig, +var internals$jscomp$inline_1273 = { + bundleType: devToolsConfig$jscomp$inline_1027.bundleType, + version: devToolsConfig$jscomp$inline_1027.version, + rendererPackageName: devToolsConfig$jscomp$inline_1027.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1027.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9525,26 +9542,26 @@ var internals$jscomp$inline_1268 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1022.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1027.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-d12bdcda6-20230325" + reconcilerVersion: "18.3.0-next-768f965de-20230326" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1269 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1274 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1269.isDisabled && - hook$jscomp$inline_1269.supportsFiber + !hook$jscomp$inline_1274.isDisabled && + hook$jscomp$inline_1274.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1269.inject( - internals$jscomp$inline_1268 + (rendererID = hook$jscomp$inline_1274.inject( + internals$jscomp$inline_1273 )), - (injectedHook = hook$jscomp$inline_1269); + (injectedHook = hook$jscomp$inline_1274); } catch (err) {} } exports.createPortal = function (children, containerTag) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index ef58b2d1ebd80..e28fbf5446437 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7678,8 +7678,9 @@ function recursivelyTraverseReconnectPassiveEffects( parentFiber = parentFiber.sibling; } } +var suspenseyCommitFlag = 8192; function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & 16777216) + if (parentFiber.subtreeFlags & suspenseyCommitFlag) for (parentFiber = parentFiber.child; null !== parentFiber; ) accumulateSuspenseyCommitOnFiber(parentFiber), (parentFiber = parentFiber.sibling); @@ -7688,7 +7689,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { switch (fiber.tag) { case 26: recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & 16777216 && null !== fiber.memoizedState) + if (fiber.flags & suspenseyCommitFlag && null !== fiber.memoizedState) throw Error( "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); @@ -7696,6 +7697,21 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case 5: recursivelyAccumulateSuspenseyCommit(fiber); break; + case 3: + case 4: + recursivelyAccumulateSuspenseyCommit(fiber); + break; + case 22: + if (null === fiber.memoizedState) { + var current = fiber.alternate; + null !== current && null !== current.memoizedState + ? ((current = suspenseyCommitFlag), + (suspenseyCommitFlag = 16777216), + recursivelyAccumulateSuspenseyCommit(fiber), + (suspenseyCommitFlag = current)) + : recursivelyAccumulateSuspenseyCommit(fiber); + } + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -8381,11 +8397,12 @@ function handleThrow(root, thrownValue) { ? (root = null === shellBoundary ? !0 : !1) : ((root = suspenseHandlerStackCursor.current), (root = - null !== root && - (workInProgressRootRenderLanes & 125829120) === - workInProgressRootRenderLanes - ? root === shellBoundary - : !1)), + null === root || + ((workInProgressRootRenderLanes & 125829120) !== + workInProgressRootRenderLanes && + 0 === (workInProgressRootRenderLanes & 1073741824)) + ? !1 + : root === shellBoundary)), (workInProgressSuspendedReason = root && 0 === (workInProgressRootSkippedLanes & 268435455) && @@ -10195,10 +10212,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1101 = { + devToolsConfig$jscomp$inline_1106 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "18.3.0-next-d12bdcda6-20230325", + version: "18.3.0-next-768f965de-20230326", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10227,10 +10244,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1101.bundleType, - version: devToolsConfig$jscomp$inline_1101.version, - rendererPackageName: devToolsConfig$jscomp$inline_1101.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1101.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1106.bundleType, + version: devToolsConfig$jscomp$inline_1106.version, + rendererPackageName: devToolsConfig$jscomp$inline_1106.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1106.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10246,14 +10263,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1101.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1106.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-d12bdcda6-20230325" + reconcilerVersion: "18.3.0-next-768f965de-20230326" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 097009e9aef78..e9df167f7d9af 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -3231,11 +3231,12 @@ var Visibility = 8192; var StoreConsistency = /* */ - 16384; // It's OK to reuse this bit because these flags are mutually exclusive for + 16384; // It's OK to reuse these bits because these flags are mutually exclusive for // different fiber types. We should really be doing this for as many flags as // possible, because we're about to run out of bits. var ScheduleRetry = StoreConsistency; +var ShouldSuspendCommit = Visibility; var LifecycleEffectMask = Passive$1 | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit) @@ -3269,8 +3270,8 @@ var LayoutStatic = var PassiveStatic = /* */ 8388608; -var SuspenseyCommit = - /* */ +var MaySuspendCommit = + /* */ 16777216; // Flag used to identify newly inserted fibers. It isn't reset after commit unlike `Placement`. var PlacementDEV = @@ -3301,7 +3302,7 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that // This allows certain concepts to persist without recalculating them, // e.g. whether a subtree contains passive effects or portals. -var StaticMask = LayoutStatic | PassiveStatic | RefStatic | SuspenseyCommit; +var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit; var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -6036,9 +6037,6 @@ function unhideInstance(instance, props) { function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } -function maySuspendCommit(type, props) { - return false; -} function preloadInstance(type, props) { // Return true to indicate it's already loaded return true; @@ -8364,13 +8362,6 @@ function trackUsedThenable(thenableState, thenable, index) { } } } -function suspendCommit() { - // This extra indirection only exists so it can handle passing - // noopSuspenseyCommitThenable through to throwException. - // TODO: Factor the thenable check out of throwException - suspendedThenable = noopSuspenseyCommitThenable; - throw SuspenseyCommitException; -} // This is used to track the actual thenable that suspended so it can be // passed to the rest of the Suspense implementation — which, for historical // reasons, expects to receive a thenable. @@ -18841,7 +18832,11 @@ function updateHostComponent( markUpdate(workInProgress); } } -} // TODO: This should ideally move to begin phase, but currently the instance is +} // This function must be called at the very end of the complete phase, because +// it might throw to suspend, and if the resource immediately loads, the work +// loop will resume rendering as if the work-in-progress completed. So it must +// fully complete. +// TODO: This should ideally move to begin phase, but currently the instance is // not created until the complete phase. For our existing use cases, host nodes // that suspend don't have children, so it doesn't matter. But that might not // always be true in the future. @@ -18852,28 +18847,16 @@ function preloadInstanceAndSuspendIfNeeded( props, renderLanes ) { - workInProgress.flags |= SuspenseyCommit; // Check if we're rendering at a "non-urgent" priority. This is the same - // check that `useDeferredValue` does to determine whether it needs to - // defer. This is partly for gradual adoption purposes (i.e. shouldn't start - // suspending until you opt in with startTransition or Suspense) but it - // also happens to be the desired behavior for the concrete use cases we've - // thought of so far, like CSS loading, fonts, images, etc. - // TODO: We may decide to expose a way to force a fallback even during a - // sync update. - - if (!includesOnlyNonUrgentLanes(renderLanes)); - else { - // Preload the instance - var isReady = preloadInstance(); - - if (!isReady) { - if (shouldRemainOnPreviousScreen()); - else { - // Trigger a fallback rather than block the render. - suspendCommit(); - } - } - } + { + // If this flag was set previously, we can remove it. The flag + // represents whether this particular set of props might ever need to + // suspend. The safest thing to do is for maySuspendCommit to always + // return true, but if the renderer is reasonably confident that the + // underlying resource won't be evicted, it can return false as a + // performance optimization. + workInProgress.flags &= ~MaySuspendCommit; + return; + } // Mark this fiber with a flag. This gets set on all host instances } function scheduleRetryEffect(workInProgress, retryQueue) { @@ -19262,12 +19245,10 @@ function completeWork(current, workInProgress, renderLanes) { case HostComponent: { popHostContext(workInProgress); - var _type = workInProgress.type; - - var _maySuspend = maySuspendCommit(); + var _type2 = workInProgress.type; if (current !== null && workInProgress.stateNode != null) { - updateHostComponent(current, workInProgress, _type, newProps); + updateHostComponent(current, workInProgress, _type2, newProps); if (current.ref !== workInProgress.ref) { markRef(workInProgress); @@ -19304,7 +19285,7 @@ function completeWork(current, workInProgress, renderLanes) { var _rootContainerInstance = getRootHostContainer(); var _instance3 = createInstance( - _type, + _type2, newProps, _rootContainerInstance, _currentHostContext2, @@ -19332,17 +19313,7 @@ function completeWork(current, workInProgress, renderLanes) { // will resume rendering as if the work-in-progress completed. So it must // fully complete. - if (_maySuspend) { - preloadInstanceAndSuspendIfNeeded( - workInProgress, - _type, - newProps, - renderLanes - ); - } else { - workInProgress.flags &= ~SuspenseyCommit; - } - + preloadInstanceAndSuspendIfNeeded(workInProgress); return null; } @@ -22638,13 +22609,24 @@ function commitPassiveUnmountEffects(finishedWork) { setCurrentFiber(finishedWork); commitPassiveUnmountOnFiber(finishedWork); resetCurrentFiber(); -} +} // If we're inside a brand new tree, or a tree that was already visible, then we +// should only suspend host components that have a ShouldSuspendCommit flag. +// Components without it haven't changed since the last commit, so we can skip +// over those. +// +// When we enter a tree that is being revealed (going from hidden -> visible), +// we need to suspend _any_ component that _may_ suspend. Even if they're +// already in the "current" tree. Because their visibility has changed, the +// browser may not have prerendered them yet. So we check the MaySuspendCommit +// flag instead. + +var suspenseyCommitFlag = ShouldSuspendCommit; function accumulateSuspenseyCommit(finishedWork) { accumulateSuspenseyCommitOnFiber(finishedWork); } function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & SuspenseyCommit) { + if (parentFiber.subtreeFlags & suspenseyCommitFlag) { var child = parentFiber.child; while (child !== null) { @@ -22659,7 +22641,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case HostHoistable: { recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & SuspenseyCommit) { + if (fiber.flags & suspenseyCommitFlag) { if (fiber.memoizedState !== null) { suspendResource(); } @@ -22675,8 +22657,36 @@ function accumulateSuspenseyCommitOnFiber(fiber) { } case HostRoot: - case HostPortal: - // eslint-disable-next-line-no-fallthrough + case HostPortal: { + { + recursivelyAccumulateSuspenseyCommit(fiber); + } + + break; + } + + case OffscreenComponent: { + var isHidden = fiber.memoizedState !== null; + + if (isHidden); + else { + var current = fiber.alternate; + var wasHidden = current !== null && current.memoizedState !== null; + + if (wasHidden) { + // This tree is being revealed. Visit all newly visible suspensey + // instances, even if they're in the current tree. + var prevFlags = suspenseyCommitFlag; + suspenseyCommitFlag = MaySuspendCommit; + recursivelyAccumulateSuspenseyCommit(fiber); + suspenseyCommitFlag = prevFlags; + } else { + recursivelyAccumulateSuspenseyCommit(fiber); + } + } + + break; + } default: { recursivelyAccumulateSuspenseyCommit(fiber); @@ -24423,15 +24433,24 @@ function shouldRemainOnPreviousScreen() { if (handler === null); else { - if (includesOnlyRetries(workInProgressRootRenderLanes)) { + if ( + includesOnlyRetries(workInProgressRootRenderLanes) || // In this context, an OffscreenLane counts as a Retry + // TODO: It's become increasingly clear that Retries and Offscreen are + // deeply connected. They probably can be unified further. + includesSomeLane(workInProgressRootRenderLanes, OffscreenLane) + ) { // During a retry, we can suspend rendering if the nearest Suspense boundary // is the boundary of the "shell", because we're guaranteed not to block // any new content from appearing. + // + // The reason we must check if this is a retry is because it guarantees + // that suspending the work loop won't block an actual update, because + // retries don't "update" anything; they fill in fallbacks that were left + // behind by a previous transition. return handler === getShellBoundary(); } } // For all other Lanes besides Transitions and Retries, we should not wait // for the data to load. - // TODO: We should wait during Offscreen prerendering, too. return false; } @@ -27548,7 +27567,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-next-d12bdcda6-20230325"; +var ReactVersion = "18.3.0-next-768f965de-20230326"; function createPortal$1( children, diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 41149a0afae73..25b2d2689c3f7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7434,8 +7434,9 @@ function recursivelyTraverseReconnectPassiveEffects( parentFiber = parentFiber.sibling; } } +var suspenseyCommitFlag = 8192; function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & 16777216) + if (parentFiber.subtreeFlags & suspenseyCommitFlag) for (parentFiber = parentFiber.child; null !== parentFiber; ) accumulateSuspenseyCommitOnFiber(parentFiber), (parentFiber = parentFiber.sibling); @@ -7444,7 +7445,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { switch (fiber.tag) { case 26: recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & 16777216 && null !== fiber.memoizedState) + if (fiber.flags & suspenseyCommitFlag && null !== fiber.memoizedState) throw Error( "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); @@ -7452,6 +7453,21 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case 5: recursivelyAccumulateSuspenseyCommit(fiber); break; + case 3: + case 4: + recursivelyAccumulateSuspenseyCommit(fiber); + break; + case 22: + if (null === fiber.memoizedState) { + var current = fiber.alternate; + null !== current && null !== current.memoizedState + ? ((current = suspenseyCommitFlag), + (suspenseyCommitFlag = 16777216), + recursivelyAccumulateSuspenseyCommit(fiber), + (suspenseyCommitFlag = current)) + : recursivelyAccumulateSuspenseyCommit(fiber); + } + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -8100,11 +8116,12 @@ function handleThrow(root, thrownValue) { ? (root = null === shellBoundary ? !0 : !1) : ((root = suspenseHandlerStackCursor.current), (root = - null !== root && - (workInProgressRootRenderLanes & 125829120) === - workInProgressRootRenderLanes - ? root === shellBoundary - : !1)), + null === root || + ((workInProgressRootRenderLanes & 125829120) !== + workInProgressRootRenderLanes && + 0 === (workInProgressRootRenderLanes & 1073741824)) + ? !1 + : root === shellBoundary)), (workInProgressSuspendedReason = root && 0 === (workInProgressRootSkippedLanes & 268435455) && @@ -9743,10 +9760,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1081 = { + devToolsConfig$jscomp$inline_1086 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-d12bdcda6-20230325", + version: "18.3.0-next-768f965de-20230326", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -9761,11 +9778,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1334 = { - bundleType: devToolsConfig$jscomp$inline_1081.bundleType, - version: devToolsConfig$jscomp$inline_1081.version, - rendererPackageName: devToolsConfig$jscomp$inline_1081.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1081.rendererConfig, +var internals$jscomp$inline_1339 = { + bundleType: devToolsConfig$jscomp$inline_1086.bundleType, + version: devToolsConfig$jscomp$inline_1086.version, + rendererPackageName: devToolsConfig$jscomp$inline_1086.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1086.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -9781,26 +9798,26 @@ var internals$jscomp$inline_1334 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1081.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1086.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-d12bdcda6-20230325" + reconcilerVersion: "18.3.0-next-768f965de-20230326" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1335 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1340 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1335.isDisabled && - hook$jscomp$inline_1335.supportsFiber + !hook$jscomp$inline_1340.isDisabled && + hook$jscomp$inline_1340.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1335.inject( - internals$jscomp$inline_1334 + (rendererID = hook$jscomp$inline_1340.inject( + internals$jscomp$inline_1339 )), - (injectedHook = hook$jscomp$inline_1335); + (injectedHook = hook$jscomp$inline_1340); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 706a53e02effd..9cad2bb386dd9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7940,8 +7940,9 @@ function recursivelyTraverseReconnectPassiveEffects( parentFiber = parentFiber.sibling; } } +var suspenseyCommitFlag = 8192; function recursivelyAccumulateSuspenseyCommit(parentFiber) { - if (parentFiber.subtreeFlags & 16777216) + if (parentFiber.subtreeFlags & suspenseyCommitFlag) for (parentFiber = parentFiber.child; null !== parentFiber; ) accumulateSuspenseyCommitOnFiber(parentFiber), (parentFiber = parentFiber.sibling); @@ -7950,7 +7951,7 @@ function accumulateSuspenseyCommitOnFiber(fiber) { switch (fiber.tag) { case 26: recursivelyAccumulateSuspenseyCommit(fiber); - if (fiber.flags & 16777216 && null !== fiber.memoizedState) + if (fiber.flags & suspenseyCommitFlag && null !== fiber.memoizedState) throw Error( "The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue." ); @@ -7958,6 +7959,21 @@ function accumulateSuspenseyCommitOnFiber(fiber) { case 5: recursivelyAccumulateSuspenseyCommit(fiber); break; + case 3: + case 4: + recursivelyAccumulateSuspenseyCommit(fiber); + break; + case 22: + if (null === fiber.memoizedState) { + var current = fiber.alternate; + null !== current && null !== current.memoizedState + ? ((current = suspenseyCommitFlag), + (suspenseyCommitFlag = 16777216), + recursivelyAccumulateSuspenseyCommit(fiber), + (suspenseyCommitFlag = current)) + : recursivelyAccumulateSuspenseyCommit(fiber); + } + break; default: recursivelyAccumulateSuspenseyCommit(fiber); } @@ -8630,11 +8646,12 @@ function handleThrow(root, thrownValue) { ? (root = null === shellBoundary ? !0 : !1) : ((root = suspenseHandlerStackCursor.current), (root = - null !== root && - (workInProgressRootRenderLanes & 125829120) === - workInProgressRootRenderLanes - ? root === shellBoundary - : !1)), + null === root || + ((workInProgressRootRenderLanes & 125829120) !== + workInProgressRootRenderLanes && + 0 === (workInProgressRootRenderLanes & 1073741824)) + ? !1 + : root === shellBoundary)), (workInProgressSuspendedReason = root && 0 === (workInProgressRootSkippedLanes & 268435455) && @@ -10451,10 +10468,10 @@ batchedUpdatesImpl = function (fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1160 = { + devToolsConfig$jscomp$inline_1165 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.3.0-next-d12bdcda6-20230325", + version: "18.3.0-next-768f965de-20230326", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function () { @@ -10483,10 +10500,10 @@ var roots = new Map(), } catch (err) {} return hook.checkDCE ? !0 : !1; })({ - bundleType: devToolsConfig$jscomp$inline_1160.bundleType, - version: devToolsConfig$jscomp$inline_1160.version, - rendererPackageName: devToolsConfig$jscomp$inline_1160.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1160.rendererConfig, + bundleType: devToolsConfig$jscomp$inline_1165.bundleType, + version: devToolsConfig$jscomp$inline_1165.version, + rendererPackageName: devToolsConfig$jscomp$inline_1165.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1165.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -10502,14 +10519,14 @@ var roots = new Map(), return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1160.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1165.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-d12bdcda6-20230325" + reconcilerVersion: "18.3.0-next-768f965de-20230326" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {