Skip to content

Commit dce2833

Browse files
committed
[Fiber] Yield every other frame for Transition/Retry work (#31828)
This flag first moves the `shouldYield()` logic into React itself. We need this for `postTask` compatibility anyway since this logic is no longer a concern of the scheduler. This means that there can also be no global `requestPaint()` that asks for painting earlier. So this is best rolled out with `enableAlwaysYieldScheduler` (and ideally `enableYieldingBeforePassive`) instead of `enableRequestPaint`. Once in React we can change the yield timing heuristics. This uses the previous 5ms for Idle work to keep everything responsive while doing background work. However, for Transitions and Retries we have seen that same thread animations (like loading states animating, or constant animations like cool Three.js stuff) can take CPU time away from the Transition that causes moving into new content to slow down. Therefore we only yield every 25ms. The purpose of this yield is not to avoid the overhead of yielding, which is very low, but rather to intentionally block any frequently occurring other main thread work like animations from starving our work. If we could we could just tell everyone else to throttle their stuff for ideal scheduling but that's not quite realistic. In other words, the purpose of this is to reduce the frame rate of animations to 30 fps and we achieve this by not yielding. We still do yield to allow the animations to not just stall. This seems like a good balance. The 5ms of Idle is because we don't really need to yield less often since the overhead is low. We keep it low to allow 120 fps animations to run if necessary and our work may not be the only work within a frame so we need to yield early enough to leave enough time left. Similarly we choose 25ms rather than say 35ms to ensure that we push long enough to guarantee to half the frame rate but low enough that there's plenty of time left for a rAF to power each animation every other frame. It's also low enough that if something else interrupts the work like a new interaction, we can still be responsive to that within 50ms or so. We also need to yield in case there's I/O work that needs to get bounced through the main thread. This flag is currently off everywhere since we have so many other scheduling flags but that means there's some urgency to roll those out fully so we can test this one. There's also some tests to update since this doesn't go through the Mock scheduler anymore for yields. DiffTrain build for [fe21c94](fe21c94)
1 parent 8533013 commit dce2833

23 files changed

+116
-116
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.1.0-native-fb-de82912e-20241220
1+
19.1.0-native-fb-fe21c947-20250102

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<7d43d556d6cda21040ca38eaa1899639>>
10+
* @generated SignedSource<<f5f98d68683d36d990518fc59fcd7f67>>
1111
*/
1212

1313
"use strict";
@@ -420,5 +420,5 @@ __DEV__ &&
420420
exports.useFormStatus = function () {
421421
return resolveDispatcher().useHostTransitionStatus();
422422
};
423-
exports.version = "19.1.0-native-fb-de82912e-20241220";
423+
exports.version = "19.1.0-native-fb-fe21c947-20250102";
424424
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<33325bbf8d92f7ad7686bf4ba20ab449>>
10+
* @generated SignedSource<<8afd590b3764dcb29675b7546247396f>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.1.0-native-fb-de82912e-20241220";
206+
exports.version = "19.1.0-native-fb-fe21c947-20250102";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<33325bbf8d92f7ad7686bf4ba20ab449>>
10+
* @generated SignedSource<<8afd590b3764dcb29675b7546247396f>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.1.0-native-fb-de82912e-20241220";
206+
exports.version = "19.1.0-native-fb-fe21c947-20250102";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<885807ecaf8737cedb8a82b81f4d0cfa>>
10+
* @generated SignedSource<<9db0fada83e9a1441d4d3e6380c6bf2a>>
1111
*/
1212

1313
/*
@@ -16085,7 +16085,7 @@ __DEV__ &&
1608516085
}
1608616086
null !== ReactSharedInternals.actQueue
1608716087
? workLoopSync()
16088-
: workLoopConcurrent();
16088+
: workLoopConcurrentByScheduler();
1608916089
break;
1609016090
} catch (thrownValue$43) {
1609116091
handleThrow(root, thrownValue$43);
@@ -16108,7 +16108,7 @@ __DEV__ &&
1610816108
finishQueueingConcurrentUpdates();
1610916109
return workInProgressRootExitStatus;
1611016110
}
16111-
function workLoopConcurrent() {
16111+
function workLoopConcurrentByScheduler() {
1611216112
for (; null !== workInProgress && !shouldYield(); )
1611316113
performUnitOfWork(workInProgress);
1611416114
}
@@ -25875,11 +25875,11 @@ __DEV__ &&
2587525875
};
2587625876
(function () {
2587725877
var isomorphicReactPackageVersion = React.version;
25878-
if ("19.1.0-native-fb-de82912e-20241220" !== isomorphicReactPackageVersion)
25878+
if ("19.1.0-native-fb-fe21c947-20250102" !== isomorphicReactPackageVersion)
2587925879
throw Error(
2588025880
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2588125881
(isomorphicReactPackageVersion +
25882-
"\n - react-dom: 19.1.0-native-fb-de82912e-20241220\nLearn more: https://react.dev/warnings/version-mismatch")
25882+
"\n - react-dom: 19.1.0-native-fb-fe21c947-20250102\nLearn more: https://react.dev/warnings/version-mismatch")
2588325883
);
2588425884
})();
2588525885
("function" === typeof Map &&
@@ -25916,10 +25916,10 @@ __DEV__ &&
2591625916
!(function () {
2591725917
var internals = {
2591825918
bundleType: 1,
25919-
version: "19.1.0-native-fb-de82912e-20241220",
25919+
version: "19.1.0-native-fb-fe21c947-20250102",
2592025920
rendererPackageName: "react-dom",
2592125921
currentDispatcherRef: ReactSharedInternals,
25922-
reconcilerVersion: "19.1.0-native-fb-de82912e-20241220"
25922+
reconcilerVersion: "19.1.0-native-fb-fe21c947-20250102"
2592325923
};
2592425924
internals.overrideHookState = overrideHookState;
2592525925
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26065,5 +26065,5 @@ __DEV__ &&
2606526065
listenToAllSupportedEvents(container);
2606626066
return new ReactDOMHydrationRoot(initialChildren);
2606726067
};
26068-
exports.version = "19.1.0-native-fb-de82912e-20241220";
26068+
exports.version = "19.1.0-native-fb-fe21c947-20250102";
2606926069
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<edd4d2374bbc8b75f540347e845bd122>>
10+
* @generated SignedSource<<2dbf0d86a39afb44385e9b3c7fe0599b>>
1111
*/
1212

1313
/*
@@ -11611,7 +11611,7 @@ function renderRootConcurrent(root, lanes) {
1161111611
throw Error(formatProdErrorMessage(462));
1161211612
}
1161311613
}
11614-
workLoopConcurrent();
11614+
workLoopConcurrentByScheduler();
1161511615
break;
1161611616
} catch (thrownValue$179) {
1161711617
handleThrow(root, thrownValue$179);
@@ -11627,7 +11627,7 @@ function renderRootConcurrent(root, lanes) {
1162711627
finishQueueingConcurrentUpdates();
1162811628
return workInProgressRootExitStatus;
1162911629
}
11630-
function workLoopConcurrent() {
11630+
function workLoopConcurrentByScheduler() {
1163111631
for (; null !== workInProgress && !shouldYield(); )
1163211632
performUnitOfWork(workInProgress);
1163311633
}
@@ -15892,14 +15892,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1589215892
};
1589315893
var isomorphicReactPackageVersion$jscomp$inline_1727 = React.version;
1589415894
if (
15895-
"19.1.0-native-fb-de82912e-20241220" !==
15895+
"19.1.0-native-fb-fe21c947-20250102" !==
1589615896
isomorphicReactPackageVersion$jscomp$inline_1727
1589715897
)
1589815898
throw Error(
1589915899
formatProdErrorMessage(
1590015900
527,
1590115901
isomorphicReactPackageVersion$jscomp$inline_1727,
15902-
"19.1.0-native-fb-de82912e-20241220"
15902+
"19.1.0-native-fb-fe21c947-20250102"
1590315903
)
1590415904
);
1590515905
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -15921,10 +15921,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1592115921
};
1592215922
var internals$jscomp$inline_2185 = {
1592315923
bundleType: 0,
15924-
version: "19.1.0-native-fb-de82912e-20241220",
15924+
version: "19.1.0-native-fb-fe21c947-20250102",
1592515925
rendererPackageName: "react-dom",
1592615926
currentDispatcherRef: ReactSharedInternals,
15927-
reconcilerVersion: "19.1.0-native-fb-de82912e-20241220"
15927+
reconcilerVersion: "19.1.0-native-fb-fe21c947-20250102"
1592815928
};
1592915929
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1593015930
var hook$jscomp$inline_2186 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16030,4 +16030,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1603016030
listenToAllSupportedEvents(container);
1603116031
return new ReactDOMHydrationRoot(initialChildren);
1603216032
};
16033-
exports.version = "19.1.0-native-fb-de82912e-20241220";
16033+
exports.version = "19.1.0-native-fb-fe21c947-20250102";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<e11fdc4be85671d6bba549317df155df>>
10+
* @generated SignedSource<<d8f770b90e41a0833928c9d0bef6bc64>>
1111
*/
1212

1313
/*
@@ -12195,7 +12195,7 @@ function renderRootConcurrent(root, lanes) {
1219512195
default:
1219612196
throw Error(formatProdErrorMessage(462));
1219712197
}
12198-
workLoopConcurrent();
12198+
workLoopConcurrentByScheduler();
1219912199
break;
1220012200
} catch (thrownValue$194) {
1220112201
handleThrow(root, thrownValue$194);
@@ -12218,7 +12218,7 @@ function renderRootConcurrent(root, lanes) {
1221812218
finishQueueingConcurrentUpdates();
1221912219
return workInProgressRootExitStatus;
1222012220
}
12221-
function workLoopConcurrent() {
12221+
function workLoopConcurrentByScheduler() {
1222212222
for (; null !== workInProgress && !shouldYield(); )
1222312223
performUnitOfWork(workInProgress);
1222412224
}
@@ -16545,14 +16545,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1654516545
};
1654616546
var isomorphicReactPackageVersion$jscomp$inline_1817 = React.version;
1654716547
if (
16548-
"19.1.0-native-fb-de82912e-20241220" !==
16548+
"19.1.0-native-fb-fe21c947-20250102" !==
1654916549
isomorphicReactPackageVersion$jscomp$inline_1817
1655016550
)
1655116551
throw Error(
1655216552
formatProdErrorMessage(
1655316553
527,
1655416554
isomorphicReactPackageVersion$jscomp$inline_1817,
16555-
"19.1.0-native-fb-de82912e-20241220"
16555+
"19.1.0-native-fb-fe21c947-20250102"
1655616556
)
1655716557
);
1655816558
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16574,10 +16574,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1657416574
};
1657516575
var internals$jscomp$inline_1824 = {
1657616576
bundleType: 0,
16577-
version: "19.1.0-native-fb-de82912e-20241220",
16577+
version: "19.1.0-native-fb-fe21c947-20250102",
1657816578
rendererPackageName: "react-dom",
1657916579
currentDispatcherRef: ReactSharedInternals,
16580-
reconcilerVersion: "19.1.0-native-fb-de82912e-20241220",
16580+
reconcilerVersion: "19.1.0-native-fb-fe21c947-20250102",
1658116581
getLaneLabelMap: function () {
1658216582
for (
1658316583
var map = new Map(), lane = 1, index$293 = 0;
@@ -16698,4 +16698,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1669816698
listenToAllSupportedEvents(container);
1669916699
return new ReactDOMHydrationRoot(initialChildren);
1670016700
};
16701-
exports.version = "19.1.0-native-fb-de82912e-20241220";
16701+
exports.version = "19.1.0-native-fb-fe21c947-20250102";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<35570adf245d74fc3d3f737ceda7337c>>
10+
* @generated SignedSource<<76a0b956b0477851f57bd34f5e782af7>>
1111
*/
1212

1313
/*
@@ -16097,7 +16097,7 @@ __DEV__ &&
1609716097
}
1609816098
null !== ReactSharedInternals.actQueue
1609916099
? workLoopSync()
16100-
: workLoopConcurrent();
16100+
: workLoopConcurrentByScheduler();
1610116101
break;
1610216102
} catch (thrownValue$43) {
1610316103
handleThrow(root, thrownValue$43);
@@ -16120,7 +16120,7 @@ __DEV__ &&
1612016120
finishQueueingConcurrentUpdates();
1612116121
return workInProgressRootExitStatus;
1612216122
}
16123-
function workLoopConcurrent() {
16123+
function workLoopConcurrentByScheduler() {
1612416124
for (; null !== workInProgress && !shouldYield(); )
1612516125
performUnitOfWork(workInProgress);
1612616126
}
@@ -25936,11 +25936,11 @@ __DEV__ &&
2593625936
};
2593725937
(function () {
2593825938
var isomorphicReactPackageVersion = React.version;
25939-
if ("19.1.0-native-fb-de82912e-20241220" !== isomorphicReactPackageVersion)
25939+
if ("19.1.0-native-fb-fe21c947-20250102" !== isomorphicReactPackageVersion)
2594025940
throw Error(
2594125941
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2594225942
(isomorphicReactPackageVersion +
25943-
"\n - react-dom: 19.1.0-native-fb-de82912e-20241220\nLearn more: https://react.dev/warnings/version-mismatch")
25943+
"\n - react-dom: 19.1.0-native-fb-fe21c947-20250102\nLearn more: https://react.dev/warnings/version-mismatch")
2594425944
);
2594525945
})();
2594625946
("function" === typeof Map &&
@@ -25977,10 +25977,10 @@ __DEV__ &&
2597725977
!(function () {
2597825978
var internals = {
2597925979
bundleType: 1,
25980-
version: "19.1.0-native-fb-de82912e-20241220",
25980+
version: "19.1.0-native-fb-fe21c947-20250102",
2598125981
rendererPackageName: "react-dom",
2598225982
currentDispatcherRef: ReactSharedInternals,
25983-
reconcilerVersion: "19.1.0-native-fb-de82912e-20241220"
25983+
reconcilerVersion: "19.1.0-native-fb-fe21c947-20250102"
2598425984
};
2598525985
internals.overrideHookState = overrideHookState;
2598625986
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26442,7 +26442,7 @@ __DEV__ &&
2644226442
exports.useFormStatus = function () {
2644326443
return resolveDispatcher().useHostTransitionStatus();
2644426444
};
26445-
exports.version = "19.1.0-native-fb-de82912e-20241220";
26445+
exports.version = "19.1.0-native-fb-fe21c947-20250102";
2644626446
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2644726447
"function" ===
2644826448
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5a2e692a7ffa1472e79fb24ea3ae15b1>>
10+
* @generated SignedSource<<48d9fc6160f98bc3bf6d60564e787c9c>>
1111
*/
1212

1313
/*
@@ -11611,7 +11611,7 @@ function renderRootConcurrent(root, lanes) {
1161111611
throw Error(formatProdErrorMessage(462));
1161211612
}
1161311613
}
11614-
workLoopConcurrent();
11614+
workLoopConcurrentByScheduler();
1161511615
break;
1161611616
} catch (thrownValue$179) {
1161711617
handleThrow(root, thrownValue$179);
@@ -11627,7 +11627,7 @@ function renderRootConcurrent(root, lanes) {
1162711627
finishQueueingConcurrentUpdates();
1162811628
return workInProgressRootExitStatus;
1162911629
}
11630-
function workLoopConcurrent() {
11630+
function workLoopConcurrentByScheduler() {
1163111631
for (; null !== workInProgress && !shouldYield(); )
1163211632
performUnitOfWork(workInProgress);
1163311633
}
@@ -15903,14 +15903,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1590315903
};
1590415904
var isomorphicReactPackageVersion$jscomp$inline_1728 = React.version;
1590515905
if (
15906-
"19.1.0-native-fb-de82912e-20241220" !==
15906+
"19.1.0-native-fb-fe21c947-20250102" !==
1590715907
isomorphicReactPackageVersion$jscomp$inline_1728
1590815908
)
1590915909
throw Error(
1591015910
formatProdErrorMessage(
1591115911
527,
1591215912
isomorphicReactPackageVersion$jscomp$inline_1728,
15913-
"19.1.0-native-fb-de82912e-20241220"
15913+
"19.1.0-native-fb-fe21c947-20250102"
1591415914
)
1591515915
);
1591615916
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -15932,10 +15932,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1593215932
};
1593315933
var internals$jscomp$inline_2188 = {
1593415934
bundleType: 0,
15935-
version: "19.1.0-native-fb-de82912e-20241220",
15935+
version: "19.1.0-native-fb-fe21c947-20250102",
1593615936
rendererPackageName: "react-dom",
1593715937
currentDispatcherRef: ReactSharedInternals,
15938-
reconcilerVersion: "19.1.0-native-fb-de82912e-20241220"
15938+
reconcilerVersion: "19.1.0-native-fb-fe21c947-20250102"
1593915939
};
1594015940
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1594115941
var hook$jscomp$inline_2189 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16195,4 +16195,4 @@ exports.useFormState = function (action, initialState, permalink) {
1619516195
exports.useFormStatus = function () {
1619616196
return ReactSharedInternals.H.useHostTransitionStatus();
1619716197
};
16198-
exports.version = "19.1.0-native-fb-de82912e-20241220";
16198+
exports.version = "19.1.0-native-fb-fe21c947-20250102";

0 commit comments

Comments
 (0)