Skip to content

Commit

Permalink
Resubmit Add HydrationSyncLane (#25878)
Browse files Browse the repository at this point in the history
Depends on #25876

Resubmit #25711 again(previously reverted in #25812), and added the fix
for unwinding in selective hydration during a hydration on the sync
lane.

DiffTrain build for [fabef7a](fabef7a)
[View git log for this commit](https://github.com/facebook/react/commits/fabef7a6b71798fe2477720e59d090a0e74e0009)
  • Loading branch information
tyao1 committed Dec 15, 2022
1 parent 5507039 commit 40ea970
Show file tree
Hide file tree
Showing 28 changed files with 1,144 additions and 1,046 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7efa9e59707b341f10fab79724e0fca373187925
fabef7a6b71798fe2477720e59d090a0e74e0009
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7efa9e59707b341f10fab79724e0fca373187925
fabef7a6b71798fe2477720e59d090a0e74e0009
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-classic-7efa9e597-20221215";
var ReactVersion = "18.3.0-www-classic-fabef7a6b-20221215";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-7efa9e597-20221215";
var ReactVersion = "18.3.0-www-modern-fabef7a6b-20221215";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,4 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-7efa9e597-20221215";
exports.version = "18.3.0-www-classic-fabef7a6b-20221215";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,4 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-7efa9e597-20221215";
exports.version = "18.3.0-www-modern-fabef7a6b-20221215";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-7efa9e597-20221215";
exports.version = "18.3.0-www-classic-fabef7a6b-20221215";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-7efa9e597-20221215";
exports.version = "18.3.0-www-modern-fabef7a6b-20221215";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
95 changes: 53 additions & 42 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-classic-7efa9e597-20221215";
var ReactVersion = "18.3.0-www-classic-fabef7a6b-20221215";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -1579,91 +1579,91 @@ var NoLanes =
var NoLane =
/* */
0;
var SyncHydrationLane =
/* */
1;
var SyncLane =
/* */
1;
2;
var InputContinuousHydrationLane =
/* */
2;
4;
var InputContinuousLane =
/* */
4;
8;
var DefaultHydrationLane =
/* */
8;
16;
var DefaultLane =
/* */
16;
32;
var TransitionHydrationLane =
/* */
32;
64;
var TransitionLanes =
/* */
4194240;
8388480;
var TransitionLane1 =
/* */
64;
128;
var TransitionLane2 =
/* */
128;
256;
var TransitionLane3 =
/* */
256;
512;
var TransitionLane4 =
/* */
512;
1024;
var TransitionLane5 =
/* */
1024;
2048;
var TransitionLane6 =
/* */
2048;
4096;
var TransitionLane7 =
/* */
4096;
8192;
var TransitionLane8 =
/* */
8192;
16384;
var TransitionLane9 =
/* */
16384;
32768;
var TransitionLane10 =
/* */
32768;
65536;
var TransitionLane11 =
/* */
65536;
131072;
var TransitionLane12 =
/* */
131072;
262144;
var TransitionLane13 =
/* */
262144;
524288;
var TransitionLane14 =
/* */
524288;
1048576;
var TransitionLane15 =
/* */
1048576;
2097152;
var TransitionLane16 =
/* */
2097152;
4194304;
var RetryLanes =
/* */
130023424;
125829120;
var RetryLane1 =
/* */
4194304;
var RetryLane2 =
/* */
8388608;
var RetryLane3 =
var RetryLane2 =
/* */
16777216;
var RetryLane4 =
var RetryLane3 =
/* */
33554432;
var RetryLane5 =
var RetryLane4 =
/* */
67108864;
var SomeRetryLane = RetryLane1;
Expand All @@ -1686,6 +1686,10 @@ var OffscreenLane =

function getLabelForLane(lane) {
if (enableSchedulingProfiler) {
if (lane & SyncHydrationLane) {
return "SyncHydrationLane";
}

if (lane & SyncLane) {
return "Sync";
}
Expand Down Expand Up @@ -1741,6 +1745,9 @@ var nextRetryLane = RetryLane1;

function getHighestPriorityLanes(lanes) {
switch (getHighestPriorityLane(lanes)) {
case SyncHydrationLane:
return SyncHydrationLane;

case SyncLane:
return SyncLane;

Expand Down Expand Up @@ -1781,7 +1788,6 @@ function getHighestPriorityLanes(lanes) {
case RetryLane2:
case RetryLane3:
case RetryLane4:
case RetryLane5:
return lanes & RetryLanes;

case SelectiveHydrationLane:
Expand Down Expand Up @@ -1942,6 +1948,7 @@ function getMostRecentEventTime(root, lanes) {

function computeExpirationTime(lane, currentTime) {
switch (lane) {
case SyncHydrationLane:
case SyncLane:
case InputContinuousHydrationLane:
case InputContinuousLane:
Expand Down Expand Up @@ -1981,7 +1988,6 @@ function computeExpirationTime(lane, currentTime) {
case RetryLane2:
case RetryLane3:
case RetryLane4:
case RetryLane5:
// TODO: Retries should be allowed to expire if they are CPU bound for
// too long, but when I made this change it caused a spike in browser
// crashes. There must be some other underlying bug; not super urgent but
Expand Down Expand Up @@ -2064,13 +2070,18 @@ function getLanesToRetrySynchronouslyOnError(root, originallyAttemptedLanes) {

return NoLanes;
}
function includesSyncLane(lanes) {
return (lanes & (SyncLane | SyncHydrationLane)) !== NoLanes;
}
function includesNonIdleWork(lanes) {
return (lanes & NonIdleLanes) !== NoLanes;
}
function includesOnlyRetries(lanes) {
return (lanes & RetryLanes) === lanes;
}
function includesOnlyNonUrgentLanes(lanes) {
// TODO: Should hydration lanes be included here? This function is only
// used in `updateDeferredValueImpl`.
var UrgentLanes = SyncLane | InputContinuousLane | DefaultLane;
return (lanes & UrgentLanes) === NoLanes;
}
Expand Down Expand Up @@ -2308,6 +2319,10 @@ function getBumpedLaneForHydration(root, renderLanes) {
var lane;

switch (renderLane) {
case SyncLane:
lane = SyncHydrationLane;
break;

case InputContinuousLane:
lane = InputContinuousHydrationLane;
break;
Expand Down Expand Up @@ -2336,7 +2351,6 @@ function getBumpedLaneForHydration(root, renderLanes) {
case RetryLane2:
case RetryLane3:
case RetryLane4:
case RetryLane5:
lane = TransitionHydrationLane;
break;

Expand Down Expand Up @@ -23460,7 +23474,7 @@ function ensureRootIsScheduled(root, currentTime) {
// TODO: Temporary until we confirm this warning is not fired.
if (
existingCallbackNode == null &&
existingCallbackPriority !== SyncLane
!includesSyncLane(existingCallbackPriority)
) {
error(
"Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue."
Expand All @@ -23478,7 +23492,7 @@ function ensureRootIsScheduled(root, currentTime) {

var newCallbackNode;

if (newCallbackPriority === SyncLane) {
if (includesSyncLane(newCallbackPriority)) {
// Special case: Sync React callbacks are scheduled on a special
// internal queue
if (root.tag === LegacyRoot) {
Expand Down Expand Up @@ -24015,7 +24029,7 @@ function performSyncWorkOnRoot(root) {
flushPassiveEffects();
var lanes = getNextLanes(root, NoLanes);

if (!includesSomeLane(lanes, SyncLane)) {
if (!includesSyncLane(lanes)) {
// There's no remaining sync work left.
ensureRootIsScheduled(root, now());
return null;
Expand Down Expand Up @@ -25317,16 +25331,13 @@ function commitRootImpl(
// currently schedule the callback in multiple places, will wait until those
// are consolidated.

if (
includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
root.tag !== LegacyRoot
) {
if (includesSyncLane(pendingPassiveEffectsLanes) && root.tag !== LegacyRoot) {
flushPassiveEffects();
} // Read this again, since a passive effect might have updated it

remainingLanes = root.pendingLanes;

if (includesSomeLane(remainingLanes, SyncLane)) {
if (includesSyncLane(remainingLanes)) {
{
markNestedUpdateScheduled();
} // Count the number of times the root synchronously re-renders without
Expand Down
Loading

0 comments on commit 40ea970

Please sign in to comment.