Skip to content

Commit cba1fef

Browse files
committed
Implement requestPaint in the actual scheduler (facebook#31784)
When implementing passive effects we did a pretty massive oversight. While the passive effect is scheduled into its own scheduler task, the scheduler doesn't always yield to the browser if it has time left. That means that if you have a fast commit phase, it might try to squeeze in the passive effects in the same frame but those then might end being very heavy. We had `requestPaint()` for this but that was only implemented for the `isInputPending` experiment. It wasn't thought we needed it for the regular scheduler because it yields "every frame" anyway - but it doesn't yield every task. While the `isInputPending` experiment showed that it wasn't actually any significant impact, and it was better to keep shorter yield time anyway. Which is why we deleted the code. Whatever small win it did see in some cases might have been actually due to this issue rather than anything to do with `isInputPending` at all. As you can see in facebook#31782 we do have this implemented in the mock scheduler and a lot of behavior that we assert assumes that this works. So this just implements yielding after `requestPaint` is called. Before: <img width="1023" alt="Screenshot 2024-12-14 at 3 40 24 PM" src="https://github.com/user-attachments/assets/d60f4bb2-c8f8-4f91-a402-9ac25b278450" /> After: <img width="1108" alt="Screenshot 2024-12-14 at 3 41 25 PM" src="https://github.com/user-attachments/assets/170cdb90-a049-436f-9501-be3fb9bc04ca" /> Notice how in after the native task is split into two. It might not always actually paint and the native scheduler might make the same mistake and think it has enough time left but it's at least less likely to. We do have another way to do this. When we yield a continuation we also yield to the native browser. This is to enable the Suspense Optimization (currently disabled) to work. We could do the same for passive effects and, in fact, I have a branch that does but because that requires a lot more tests to be fixed it's a lot more invasive of a change. The nice thing about this approach is that this is not even running in tests at all and the tests we do have assert that this is the behavior already. 😬 DiffTrain build for [c80b336](facebook@c80b336)
1 parent d42f100 commit cba1fef

26 files changed

+125
-101
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-9e2c2331-20241214
1+
19.1.0-native-fb-c80b336d-20241214

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<<7291728f480390b2252debc84f6fea00>>
10+
* @generated SignedSource<<b04d7e4586e35d0745cc706e21d118d8>>
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-9e2c2331-20241214";
423+
exports.version = "19.1.0-native-fb-c80b336d-20241214";
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<<750b2d06666d3559337bd9db530269cf>>
10+
* @generated SignedSource<<f0bcb042fc8317d7226f720e52e855bc>>
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-9e2c2331-20241214";
206+
exports.version = "19.1.0-native-fb-c80b336d-20241214";

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<<750b2d06666d3559337bd9db530269cf>>
10+
* @generated SignedSource<<f0bcb042fc8317d7226f720e52e855bc>>
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-9e2c2331-20241214";
206+
exports.version = "19.1.0-native-fb-c80b336d-20241214";

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

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

1313
/*
@@ -9373,7 +9373,7 @@ __DEV__ &&
93739373
)
93749374
return (
93759375
isSuspenseInstanceFallback(JSCompiler_object_inline_message_2359)
9376-
? (workInProgress.lanes = 16)
9376+
? (workInProgress.lanes = 32)
93779377
: (workInProgress.lanes = 536870912),
93789378
null
93799379
);
@@ -25892,11 +25892,11 @@ __DEV__ &&
2589225892
};
2589325893
(function () {
2589425894
var isomorphicReactPackageVersion = React.version;
25895-
if ("19.1.0-native-fb-9e2c2331-20241214" !== isomorphicReactPackageVersion)
25895+
if ("19.1.0-native-fb-c80b336d-20241214" !== isomorphicReactPackageVersion)
2589625896
throw Error(
2589725897
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2589825898
(isomorphicReactPackageVersion +
25899-
"\n - react-dom: 19.1.0-native-fb-9e2c2331-20241214\nLearn more: https://react.dev/warnings/version-mismatch")
25899+
"\n - react-dom: 19.1.0-native-fb-c80b336d-20241214\nLearn more: https://react.dev/warnings/version-mismatch")
2590025900
);
2590125901
})();
2590225902
("function" === typeof Map &&
@@ -25933,10 +25933,10 @@ __DEV__ &&
2593325933
!(function () {
2593425934
var internals = {
2593525935
bundleType: 1,
25936-
version: "19.1.0-native-fb-9e2c2331-20241214",
25936+
version: "19.1.0-native-fb-c80b336d-20241214",
2593725937
rendererPackageName: "react-dom",
2593825938
currentDispatcherRef: ReactSharedInternals,
25939-
reconcilerVersion: "19.1.0-native-fb-9e2c2331-20241214"
25939+
reconcilerVersion: "19.1.0-native-fb-c80b336d-20241214"
2594025940
};
2594125941
internals.overrideHookState = overrideHookState;
2594225942
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26082,5 +26082,5 @@ __DEV__ &&
2608226082
listenToAllSupportedEvents(container);
2608326083
return new ReactDOMHydrationRoot(initialChildren);
2608426084
};
26085-
exports.version = "19.1.0-native-fb-9e2c2331-20241214";
26085+
exports.version = "19.1.0-native-fb-c80b336d-20241214";
2608626086
})();

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

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

1313
/*
@@ -6502,7 +6502,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
65026502
)
65036503
return (
65046504
isSuspenseInstanceFallback(nextInstance)
6505-
? (workInProgress.lanes = 16)
6505+
? (workInProgress.lanes = 32)
65066506
: (workInProgress.lanes = 536870912),
65076507
null
65086508
);
@@ -15868,14 +15868,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1586815868
};
1586915869
var isomorphicReactPackageVersion$jscomp$inline_1722 = React.version;
1587015870
if (
15871-
"19.1.0-native-fb-9e2c2331-20241214" !==
15871+
"19.1.0-native-fb-c80b336d-20241214" !==
1587215872
isomorphicReactPackageVersion$jscomp$inline_1722
1587315873
)
1587415874
throw Error(
1587515875
formatProdErrorMessage(
1587615876
527,
1587715877
isomorphicReactPackageVersion$jscomp$inline_1722,
15878-
"19.1.0-native-fb-9e2c2331-20241214"
15878+
"19.1.0-native-fb-c80b336d-20241214"
1587915879
)
1588015880
);
1588115881
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -15897,10 +15897,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1589715897
};
1589815898
var internals$jscomp$inline_2177 = {
1589915899
bundleType: 0,
15900-
version: "19.1.0-native-fb-9e2c2331-20241214",
15900+
version: "19.1.0-native-fb-c80b336d-20241214",
1590115901
rendererPackageName: "react-dom",
1590215902
currentDispatcherRef: ReactSharedInternals,
15903-
reconcilerVersion: "19.1.0-native-fb-9e2c2331-20241214"
15903+
reconcilerVersion: "19.1.0-native-fb-c80b336d-20241214"
1590415904
};
1590515905
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1590615906
var hook$jscomp$inline_2178 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16006,4 +16006,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1600616006
listenToAllSupportedEvents(container);
1600716007
return new ReactDOMHydrationRoot(initialChildren);
1600816008
};
16009-
exports.version = "19.1.0-native-fb-9e2c2331-20241214";
16009+
exports.version = "19.1.0-native-fb-c80b336d-20241214";

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

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

1313
/*
@@ -6673,7 +6673,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
66736673
)
66746674
return (
66756675
isSuspenseInstanceFallback(nextInstance)
6676-
? (workInProgress.lanes = 16)
6676+
? (workInProgress.lanes = 32)
66776677
: (workInProgress.lanes = 536870912),
66786678
null
66796679
);
@@ -16521,14 +16521,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1652116521
};
1652216522
var isomorphicReactPackageVersion$jscomp$inline_1812 = React.version;
1652316523
if (
16524-
"19.1.0-native-fb-9e2c2331-20241214" !==
16524+
"19.1.0-native-fb-c80b336d-20241214" !==
1652516525
isomorphicReactPackageVersion$jscomp$inline_1812
1652616526
)
1652716527
throw Error(
1652816528
formatProdErrorMessage(
1652916529
527,
1653016530
isomorphicReactPackageVersion$jscomp$inline_1812,
16531-
"19.1.0-native-fb-9e2c2331-20241214"
16531+
"19.1.0-native-fb-c80b336d-20241214"
1653216532
)
1653316533
);
1653416534
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16550,10 +16550,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1655016550
};
1655116551
var internals$jscomp$inline_1819 = {
1655216552
bundleType: 0,
16553-
version: "19.1.0-native-fb-9e2c2331-20241214",
16553+
version: "19.1.0-native-fb-c80b336d-20241214",
1655416554
rendererPackageName: "react-dom",
1655516555
currentDispatcherRef: ReactSharedInternals,
16556-
reconcilerVersion: "19.1.0-native-fb-9e2c2331-20241214",
16556+
reconcilerVersion: "19.1.0-native-fb-c80b336d-20241214",
1655716557
getLaneLabelMap: function () {
1655816558
for (
1655916559
var map = new Map(), lane = 1, index$292 = 0;
@@ -16674,4 +16674,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1667416674
listenToAllSupportedEvents(container);
1667516675
return new ReactDOMHydrationRoot(initialChildren);
1667616676
};
16677-
exports.version = "19.1.0-native-fb-9e2c2331-20241214";
16677+
exports.version = "19.1.0-native-fb-c80b336d-20241214";

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

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

1313
/*
@@ -9381,7 +9381,7 @@ __DEV__ &&
93819381
)
93829382
return (
93839383
isSuspenseInstanceFallback(JSCompiler_object_inline_message_2364)
9384-
? (workInProgress.lanes = 16)
9384+
? (workInProgress.lanes = 32)
93859385
: (workInProgress.lanes = 536870912),
93869386
null
93879387
);
@@ -25953,11 +25953,11 @@ __DEV__ &&
2595325953
};
2595425954
(function () {
2595525955
var isomorphicReactPackageVersion = React.version;
25956-
if ("19.1.0-native-fb-9e2c2331-20241214" !== isomorphicReactPackageVersion)
25956+
if ("19.1.0-native-fb-c80b336d-20241214" !== isomorphicReactPackageVersion)
2595725957
throw Error(
2595825958
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2595925959
(isomorphicReactPackageVersion +
25960-
"\n - react-dom: 19.1.0-native-fb-9e2c2331-20241214\nLearn more: https://react.dev/warnings/version-mismatch")
25960+
"\n - react-dom: 19.1.0-native-fb-c80b336d-20241214\nLearn more: https://react.dev/warnings/version-mismatch")
2596125961
);
2596225962
})();
2596325963
("function" === typeof Map &&
@@ -25994,10 +25994,10 @@ __DEV__ &&
2599425994
!(function () {
2599525995
var internals = {
2599625996
bundleType: 1,
25997-
version: "19.1.0-native-fb-9e2c2331-20241214",
25997+
version: "19.1.0-native-fb-c80b336d-20241214",
2599825998
rendererPackageName: "react-dom",
2599925999
currentDispatcherRef: ReactSharedInternals,
26000-
reconcilerVersion: "19.1.0-native-fb-9e2c2331-20241214"
26000+
reconcilerVersion: "19.1.0-native-fb-c80b336d-20241214"
2600126001
};
2600226002
internals.overrideHookState = overrideHookState;
2600326003
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -26459,7 +26459,7 @@ __DEV__ &&
2645926459
exports.useFormStatus = function () {
2646026460
return resolveDispatcher().useHostTransitionStatus();
2646126461
};
26462-
exports.version = "19.1.0-native-fb-9e2c2331-20241214";
26462+
exports.version = "19.1.0-native-fb-c80b336d-20241214";
2646326463
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2646426464
"function" ===
2646526465
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

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

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

1313
/*
@@ -6502,7 +6502,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
65026502
)
65036503
return (
65046504
isSuspenseInstanceFallback(nextInstance)
6505-
? (workInProgress.lanes = 16)
6505+
? (workInProgress.lanes = 32)
65066506
: (workInProgress.lanes = 536870912),
65076507
null
65086508
);
@@ -15879,14 +15879,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1587915879
};
1588015880
var isomorphicReactPackageVersion$jscomp$inline_1723 = React.version;
1588115881
if (
15882-
"19.1.0-native-fb-9e2c2331-20241214" !==
15882+
"19.1.0-native-fb-c80b336d-20241214" !==
1588315883
isomorphicReactPackageVersion$jscomp$inline_1723
1588415884
)
1588515885
throw Error(
1588615886
formatProdErrorMessage(
1588715887
527,
1588815888
isomorphicReactPackageVersion$jscomp$inline_1723,
15889-
"19.1.0-native-fb-9e2c2331-20241214"
15889+
"19.1.0-native-fb-c80b336d-20241214"
1589015890
)
1589115891
);
1589215892
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -15908,10 +15908,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1590815908
};
1590915909
var internals$jscomp$inline_2180 = {
1591015910
bundleType: 0,
15911-
version: "19.1.0-native-fb-9e2c2331-20241214",
15911+
version: "19.1.0-native-fb-c80b336d-20241214",
1591215912
rendererPackageName: "react-dom",
1591315913
currentDispatcherRef: ReactSharedInternals,
15914-
reconcilerVersion: "19.1.0-native-fb-9e2c2331-20241214"
15914+
reconcilerVersion: "19.1.0-native-fb-c80b336d-20241214"
1591515915
};
1591615916
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1591715917
var hook$jscomp$inline_2181 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16171,4 +16171,4 @@ exports.useFormState = function (action, initialState, permalink) {
1617116171
exports.useFormStatus = function () {
1617216172
return ReactSharedInternals.H.useHostTransitionStatus();
1617316173
};
16174-
exports.version = "19.1.0-native-fb-9e2c2331-20241214";
16174+
exports.version = "19.1.0-native-fb-c80b336d-20241214";

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

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

1313
/*
@@ -6677,7 +6677,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) {
66776677
)
66786678
return (
66796679
isSuspenseInstanceFallback(nextInstance)
6680-
? (workInProgress.lanes = 16)
6680+
? (workInProgress.lanes = 32)
66816681
: (workInProgress.lanes = 536870912),
66826682
null
66836683
);
@@ -16536,14 +16536,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1653616536
};
1653716537
var isomorphicReactPackageVersion$jscomp$inline_1813 = React.version;
1653816538
if (
16539-
"19.1.0-native-fb-9e2c2331-20241214" !==
16539+
"19.1.0-native-fb-c80b336d-20241214" !==
1654016540
isomorphicReactPackageVersion$jscomp$inline_1813
1654116541
)
1654216542
throw Error(
1654316543
formatProdErrorMessage(
1654416544
527,
1654516545
isomorphicReactPackageVersion$jscomp$inline_1813,
16546-
"19.1.0-native-fb-9e2c2331-20241214"
16546+
"19.1.0-native-fb-c80b336d-20241214"
1654716547
)
1654816548
);
1654916549
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -16565,10 +16565,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1656516565
};
1656616566
var internals$jscomp$inline_1820 = {
1656716567
bundleType: 0,
16568-
version: "19.1.0-native-fb-9e2c2331-20241214",
16568+
version: "19.1.0-native-fb-c80b336d-20241214",
1656916569
rendererPackageName: "react-dom",
1657016570
currentDispatcherRef: ReactSharedInternals,
16571-
reconcilerVersion: "19.1.0-native-fb-9e2c2331-20241214",
16571+
reconcilerVersion: "19.1.0-native-fb-c80b336d-20241214",
1657216572
getLaneLabelMap: function () {
1657316573
for (
1657416574
var map = new Map(), lane = 1, index$292 = 0;
@@ -16843,7 +16843,7 @@ exports.useFormState = function (action, initialState, permalink) {
1684316843
exports.useFormStatus = function () {
1684416844
return ReactSharedInternals.H.useHostTransitionStatus();
1684516845
};
16846-
exports.version = "19.1.0-native-fb-9e2c2331-20241214";
16846+
exports.version = "19.1.0-native-fb-c80b336d-20241214";
1684716847
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1684816848
"function" ===
1684916849
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)