Skip to content

Commit 40ea970

Browse files
committed
Resubmit Add HydrationSyncLane (#25878)
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)
1 parent 5507039 commit 40ea970

28 files changed

+1144
-1046
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7efa9e59707b341f10fab79724e0fca373187925
1+
fabef7a6b71798fe2477720e59d090a0e74e0009
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7efa9e59707b341f10fab79724e0fca373187925
1+
fabef7a6b71798fe2477720e59d090a0e74e0009

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

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

3232
// ATTENTION
3333
// When adding new symbols to this file,

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

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

3232
// ATTENTION
3333
// When adding new symbols to this file,

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,4 @@ exports.useSyncExternalStore = function(
643643
);
644644
};
645645
exports.useTransition = useTransition;
646-
exports.version = "18.3.0-www-classic-7efa9e597-20221215";
646+
exports.version = "18.3.0-www-classic-fabef7a6b-20221215";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,4 @@ exports.useSyncExternalStore = function(
635635
);
636636
};
637637
exports.useTransition = useTransition;
638-
exports.version = "18.3.0-www-modern-7efa9e597-20221215";
638+
exports.version = "18.3.0-www-modern-fabef7a6b-20221215";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ exports.useSyncExternalStore = function(
654654
);
655655
};
656656
exports.useTransition = useTransition;
657-
exports.version = "18.3.0-www-classic-7efa9e597-20221215";
657+
exports.version = "18.3.0-www-classic-fabef7a6b-20221215";
658658

659659
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
660660
if (

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ exports.useSyncExternalStore = function(
646646
);
647647
};
648648
exports.useTransition = useTransition;
649-
exports.version = "18.3.0-www-modern-7efa9e597-20221215";
649+
exports.version = "18.3.0-www-modern-fabef7a6b-20221215";
650650

651651
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
652652
if (

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

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

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;
@@ -1579,91 +1579,91 @@ var NoLanes =
15791579
var NoLane =
15801580
/* */
15811581
0;
1582+
var SyncHydrationLane =
1583+
/* */
1584+
1;
15821585
var SyncLane =
15831586
/* */
1584-
1;
1587+
2;
15851588
var InputContinuousHydrationLane =
15861589
/* */
1587-
2;
1590+
4;
15881591
var InputContinuousLane =
15891592
/* */
1590-
4;
1593+
8;
15911594
var DefaultHydrationLane =
15921595
/* */
1593-
8;
1596+
16;
15941597
var DefaultLane =
15951598
/* */
1596-
16;
1599+
32;
15971600
var TransitionHydrationLane =
15981601
/* */
1599-
32;
1602+
64;
16001603
var TransitionLanes =
16011604
/* */
1602-
4194240;
1605+
8388480;
16031606
var TransitionLane1 =
16041607
/* */
1605-
64;
1608+
128;
16061609
var TransitionLane2 =
16071610
/* */
1608-
128;
1611+
256;
16091612
var TransitionLane3 =
16101613
/* */
1611-
256;
1614+
512;
16121615
var TransitionLane4 =
16131616
/* */
1614-
512;
1617+
1024;
16151618
var TransitionLane5 =
16161619
/* */
1617-
1024;
1620+
2048;
16181621
var TransitionLane6 =
16191622
/* */
1620-
2048;
1623+
4096;
16211624
var TransitionLane7 =
16221625
/* */
1623-
4096;
1626+
8192;
16241627
var TransitionLane8 =
16251628
/* */
1626-
8192;
1629+
16384;
16271630
var TransitionLane9 =
16281631
/* */
1629-
16384;
1632+
32768;
16301633
var TransitionLane10 =
16311634
/* */
1632-
32768;
1635+
65536;
16331636
var TransitionLane11 =
16341637
/* */
1635-
65536;
1638+
131072;
16361639
var TransitionLane12 =
16371640
/* */
1638-
131072;
1641+
262144;
16391642
var TransitionLane13 =
16401643
/* */
1641-
262144;
1644+
524288;
16421645
var TransitionLane14 =
16431646
/* */
1644-
524288;
1647+
1048576;
16451648
var TransitionLane15 =
16461649
/* */
1647-
1048576;
1650+
2097152;
16481651
var TransitionLane16 =
16491652
/* */
1650-
2097152;
1653+
4194304;
16511654
var RetryLanes =
16521655
/* */
1653-
130023424;
1656+
125829120;
16541657
var RetryLane1 =
1655-
/* */
1656-
4194304;
1657-
var RetryLane2 =
16581658
/* */
16591659
8388608;
1660-
var RetryLane3 =
1660+
var RetryLane2 =
16611661
/* */
16621662
16777216;
1663-
var RetryLane4 =
1663+
var RetryLane3 =
16641664
/* */
16651665
33554432;
1666-
var RetryLane5 =
1666+
var RetryLane4 =
16671667
/* */
16681668
67108864;
16691669
var SomeRetryLane = RetryLane1;
@@ -1686,6 +1686,10 @@ var OffscreenLane =
16861686

16871687
function getLabelForLane(lane) {
16881688
if (enableSchedulingProfiler) {
1689+
if (lane & SyncHydrationLane) {
1690+
return "SyncHydrationLane";
1691+
}
1692+
16891693
if (lane & SyncLane) {
16901694
return "Sync";
16911695
}
@@ -1741,6 +1745,9 @@ var nextRetryLane = RetryLane1;
17411745

17421746
function getHighestPriorityLanes(lanes) {
17431747
switch (getHighestPriorityLane(lanes)) {
1748+
case SyncHydrationLane:
1749+
return SyncHydrationLane;
1750+
17441751
case SyncLane:
17451752
return SyncLane;
17461753

@@ -1781,7 +1788,6 @@ function getHighestPriorityLanes(lanes) {
17811788
case RetryLane2:
17821789
case RetryLane3:
17831790
case RetryLane4:
1784-
case RetryLane5:
17851791
return lanes & RetryLanes;
17861792

17871793
case SelectiveHydrationLane:
@@ -1942,6 +1948,7 @@ function getMostRecentEventTime(root, lanes) {
19421948

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

20652071
return NoLanes;
20662072
}
2073+
function includesSyncLane(lanes) {
2074+
return (lanes & (SyncLane | SyncHydrationLane)) !== NoLanes;
2075+
}
20672076
function includesNonIdleWork(lanes) {
20682077
return (lanes & NonIdleLanes) !== NoLanes;
20692078
}
20702079
function includesOnlyRetries(lanes) {
20712080
return (lanes & RetryLanes) === lanes;
20722081
}
20732082
function includesOnlyNonUrgentLanes(lanes) {
2083+
// TODO: Should hydration lanes be included here? This function is only
2084+
// used in `updateDeferredValueImpl`.
20742085
var UrgentLanes = SyncLane | InputContinuousLane | DefaultLane;
20752086
return (lanes & UrgentLanes) === NoLanes;
20762087
}
@@ -2308,6 +2319,10 @@ function getBumpedLaneForHydration(root, renderLanes) {
23082319
var lane;
23092320

23102321
switch (renderLane) {
2322+
case SyncLane:
2323+
lane = SyncHydrationLane;
2324+
break;
2325+
23112326
case InputContinuousLane:
23122327
lane = InputContinuousHydrationLane;
23132328
break;
@@ -2336,7 +2351,6 @@ function getBumpedLaneForHydration(root, renderLanes) {
23362351
case RetryLane2:
23372352
case RetryLane3:
23382353
case RetryLane4:
2339-
case RetryLane5:
23402354
lane = TransitionHydrationLane;
23412355
break;
23422356

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

2347923493
var newCallbackNode;
2348023494

23481-
if (newCallbackPriority === SyncLane) {
23495+
if (includesSyncLane(newCallbackPriority)) {
2348223496
// Special case: Sync React callbacks are scheduled on a special
2348323497
// internal queue
2348423498
if (root.tag === LegacyRoot) {
@@ -24015,7 +24029,7 @@ function performSyncWorkOnRoot(root) {
2401524029
flushPassiveEffects();
2401624030
var lanes = getNextLanes(root, NoLanes);
2401724031

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

25320-
if (
25321-
includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
25322-
root.tag !== LegacyRoot
25323-
) {
25334+
if (includesSyncLane(pendingPassiveEffectsLanes) && root.tag !== LegacyRoot) {
2532425335
flushPassiveEffects();
2532525336
} // Read this again, since a passive effect might have updated it
2532625337

2532725338
remainingLanes = root.pendingLanes;
2532825339

25329-
if (includesSomeLane(remainingLanes, SyncLane)) {
25340+
if (includesSyncLane(remainingLanes)) {
2533025341
{
2533125342
markNestedUpdateScheduled();
2533225343
} // Count the number of times the root synchronously re-renders without

0 commit comments

Comments
 (0)