You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prerendering a tree (i.e. with Offscreen) should not suspend the commit
phase, because the content is not yet visible. However, when revealing a
prerendered tree, we should suspend the commit phase if resources in the
prerendered tree haven't finished loading yet.
To do this properly, we need to visit all the visible nodes in the tree
that might possibly suspend. This includes nodes in the current tree,
because even though they were already "mounted", the resources might not
have loaded yet, because we didn't suspend when it was prerendered.
We will need to add this capability to the Offscreen component's
"manual" mode, too. Something like a `ready()` method that returns a
promise that resolves when the tree has fully loaded.
Also includes some fixes to #26450. See PR for details.
DiffTrain build for commit 768f965.
Copy file name to clipboardExpand all lines: compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js
+80-61Lines changed: 80 additions & 61 deletions
Original file line number
Diff line number
Diff line change
@@ -484,11 +484,12 @@ var Visibility =
484
484
8192;
485
485
var StoreConsistency =
486
486
/* */
487
-
16384; // It's OK to reuse this bit because these flags are mutually exclusive for
487
+
16384; // It's OK to reuse these bits because these flags are mutually exclusive for
488
488
// different fiber types. We should really be doing this for as many flags as
489
489
// possible, because we're about to run out of bits.
490
490
491
491
var ScheduleRetry = StoreConsistency;
492
+
var ShouldSuspendCommit = Visibility;
492
493
var LifecycleEffectMask =
493
494
Passive$1 | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit)
494
495
@@ -522,8 +523,8 @@ var LayoutStatic =
522
523
var PassiveStatic =
523
524
/* */
524
525
8388608;
525
-
var SuspenseyCommit =
526
-
/* */
526
+
var MaySuspendCommit =
527
+
/* */
527
528
16777216; // Flag used to identify newly inserted fibers. It isn't reset after commit unlike `Placement`.
528
529
529
530
var PlacementDEV =
@@ -554,7 +555,7 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that
554
555
// This allows certain concepts to persist without recalculating them,
555
556
// e.g. whether a subtree contains passive effects or portals.
556
557
557
-
var StaticMask = LayoutStatic | PassiveStatic | RefStatic | SuspenseyCommit;
558
+
var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit;
558
559
559
560
var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
560
561
function getNearestMountedFiber(fiber) {
@@ -2023,9 +2024,6 @@ function unhideInstance(instance, props) {
2023
2024
function unhideTextInstance(textInstance, text) {
2024
2025
textInstance.isHidden = false;
2025
2026
}
2026
-
function maySuspendCommit(type, props) {
2027
-
return false;
2028
-
}
2029
2027
function preloadInstance(type, props) {
2030
2028
// Return true to indicate it's already loaded
2031
2029
return true;
@@ -4310,13 +4308,6 @@ function trackUsedThenable(thenableState, thenable, index) {
4310
4308
}
4311
4309
}
4312
4310
}
4313
-
function suspendCommit() {
4314
-
// This extra indirection only exists so it can handle passing
4315
-
// noopSuspenseyCommitThenable through to throwException.
4316
-
// TODO: Factor the thenable check out of throwException
4317
-
suspendedThenable = noopSuspenseyCommitThenable;
4318
-
throw SuspenseyCommitException;
4319
-
} // This is used to track the actual thenable that suspended so it can be
4320
4311
// passed to the rest of the Suspense implementation — which, for historical
4321
4312
// reasons, expects to receive a thenable.
4322
4313
@@ -14604,7 +14595,11 @@ function updateHostComponent(
14604
14595
markUpdate(workInProgress);
14605
14596
}
14606
14597
}
14607
-
} // TODO: This should ideally move to begin phase, but currently the instance is
14598
+
} // This function must be called at the very end of the complete phase, because
14599
+
// it might throw to suspend, and if the resource immediately loads, the work
14600
+
// loop will resume rendering as if the work-in-progress completed. So it must
14601
+
// fully complete.
14602
+
// TODO: This should ideally move to begin phase, but currently the instance is
14608
14603
// not created until the complete phase. For our existing use cases, host nodes
14609
14604
// that suspend don't have children, so it doesn't matter. But that might not
14610
14605
// always be true in the future.
@@ -14615,28 +14610,16 @@ function preloadInstanceAndSuspendIfNeeded(
14615
14610
props,
14616
14611
renderLanes
14617
14612
) {
14618
-
workInProgress.flags |= SuspenseyCommit; // Check if we're rendering at a "non-urgent" priority. This is the same
14619
-
// check that `useDeferredValue` does to determine whether it needs to
14620
-
// defer. This is partly for gradual adoption purposes (i.e. shouldn't start
14621
-
// suspending until you opt in with startTransition or Suspense) but it
14622
-
// also happens to be the desired behavior for the concrete use cases we've
14623
-
// thought of so far, like CSS loading, fonts, images, etc.
14624
-
// TODO: We may decide to expose a way to force a fallback even during a
14625
-
// sync update.
14626
-
14627
-
if (!includesOnlyNonUrgentLanes(renderLanes));
14628
-
else {
14629
-
// Preload the instance
14630
-
var isReady = preloadInstance();
14631
-
14632
-
if (!isReady) {
14633
-
if (shouldRemainOnPreviousScreen());
14634
-
else {
14635
-
// Trigger a fallback rather than block the render.
14636
-
suspendCommit();
14637
-
}
14638
-
}
14639
-
}
14613
+
{
14614
+
// If this flag was set previously, we can remove it. The flag
14615
+
// represents whether this particular set of props might ever need to
14616
+
// suspend. The safest thing to do is for maySuspendCommit to always
14617
+
// return true, but if the renderer is reasonably confident that the
14618
+
// underlying resource won't be evicted, it can return false as a
14619
+
// performance optimization.
14620
+
workInProgress.flags &= ~MaySuspendCommit;
14621
+
return;
14622
+
} // Mark this fiber with a flag. This gets set on all host instances
14640
14623
}
14641
14624
14642
14625
function scheduleRetryEffect(workInProgress, retryQueue) {
@@ -15042,12 +15025,10 @@ function completeWork(current, workInProgress, renderLanes) {
15042
15025
15043
15026
case HostComponent: {
15044
15027
popHostContext(workInProgress);
15045
-
var _type = workInProgress.type;
15046
-
15047
-
var _maySuspend = maySuspendCommit();
15028
+
var _type2 = workInProgress.type;
15048
15029
15049
15030
if (current !== null && workInProgress.stateNode != null) {
Copy file name to clipboardExpand all lines: compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js
+39-22Lines changed: 39 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -6038,8 +6038,9 @@ function recursivelyTraverseAtomicPassiveEffects(
0 commit comments