Skip to content

Commit eabed3a

Browse files
committed
[Fiber] Adjust the suspensey image/css timeout based on already elapsed time (#34478)
Currently suspensey images doesn't account for how long we've already been waiting. This means that you can for example wait for 300ms for the throttle + 500ms for the images. If a Transition takes a while to complete you can also wait that time + an additional 500ms for the images. This tracks the start time of a Transition so that we can count the timeout starting from when the user interacted or when the last fallback committed (which is where the 300ms throttle is computed from). Creating a single timeline. This also moves the timeout to a central place which I'll use in a follow up. DiffTrain build for [e3f1918](e3f1918)
1 parent 3a661e1 commit eabed3a

24 files changed

+794
-559
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.2.0-native-fb-e12b0bdc-20250915
1+
19.2.0-native-fb-e3f19180-20250915

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<<60c3717fd26a7b02ec16d1564b8ccf5e>>
10+
* @generated SignedSource<<7843507958dab8de6d8cd79d77778079>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-e12b0bdc-20250915";
407+
exports.version = "19.2.0-native-fb-e3f19180-20250915";
408408
})();

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<<e91814afb6afb27fba6ea14f6a7601e6>>
10+
* @generated SignedSource<<3c9853534e2eba8cfe4d1792a871aad8>>
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.2.0-native-fb-e12b0bdc-20250915";
206+
exports.version = "19.2.0-native-fb-e3f19180-20250915";

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<<e91814afb6afb27fba6ea14f6a7601e6>>
10+
* @generated SignedSource<<3c9853534e2eba8cfe4d1792a871aad8>>
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.2.0-native-fb-e12b0bdc-20250915";
206+
exports.version = "19.2.0-native-fb-e3f19180-20250915";

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

Lines changed: 161 additions & 135 deletions
Large diffs are not rendered by default.

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

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

1313
/*
@@ -3424,6 +3424,7 @@ function releaseIsomorphicIndicator() {
34243424
}
34253425
var prevOnStartTransitionFinish = ReactSharedInternals.S;
34263426
ReactSharedInternals.S = function (transition, returnValue) {
3427+
globalMostRecentTransitionTime = now();
34273428
"object" === typeof returnValue &&
34283429
null !== returnValue &&
34293430
"function" === typeof returnValue.then &&
@@ -11429,6 +11430,7 @@ var DefaultAsyncDispatcher = {
1142911430
workInProgressRootRecoverableErrors = null,
1143011431
workInProgressRootDidIncludeRecursiveRenderUpdate = !1,
1143111432
globalMostRecentFallbackTime = 0,
11433+
globalMostRecentTransitionTime = 0,
1143211434
workInProgressRootRenderTargetTime = Infinity,
1143311435
workInProgressTransitions = null,
1143411436
legacyErrorBoundariesThatAlreadyFailed = null,
@@ -11686,9 +11688,21 @@ function commitRootWhenReady(
1168611688
16785408 === (suspendedCommitReason & 16785408)
1168711689
)
1168811690
if (
11689-
((suspendedState = { stylesheets: null, count: 0, unsuspend: noop$1 }),
11691+
((suspendedState = {
11692+
stylesheets: null,
11693+
count: 0,
11694+
imgCount: 0,
11695+
waitingForImages: !0,
11696+
unsuspend: noop$1
11697+
}),
1169011698
accumulateSuspenseyCommitOnFiber(finishedWork),
11691-
(suspendedCommitReason = waitForCommitToBeReady()),
11699+
(suspendedCommitReason =
11700+
(lanes & 62914560) === lanes
11701+
? globalMostRecentFallbackTime - now()
11702+
: (lanes & 4194048) === lanes
11703+
? globalMostRecentTransitionTime - now()
11704+
: 0),
11705+
(suspendedCommitReason = waitForCommitToBeReady(suspendedCommitReason)),
1169211706
null !== suspendedCommitReason)
1169311707
) {
1169411708
root.cancelPendingCommit = suspendedCommitReason(
@@ -13127,20 +13141,20 @@ function debounceScrollEnd(targetInst, nativeEvent, nativeEventTarget) {
1312713141
(nativeEventTarget[internalScrollTimer] = targetInst));
1312813142
}
1312913143
for (
13130-
var i$jscomp$inline_1663 = 0;
13131-
i$jscomp$inline_1663 < simpleEventPluginEvents.length;
13132-
i$jscomp$inline_1663++
13144+
var i$jscomp$inline_1664 = 0;
13145+
i$jscomp$inline_1664 < simpleEventPluginEvents.length;
13146+
i$jscomp$inline_1664++
1313313147
) {
13134-
var eventName$jscomp$inline_1664 =
13135-
simpleEventPluginEvents[i$jscomp$inline_1663],
13136-
domEventName$jscomp$inline_1665 =
13137-
eventName$jscomp$inline_1664.toLowerCase(),
13138-
capitalizedEvent$jscomp$inline_1666 =
13139-
eventName$jscomp$inline_1664[0].toUpperCase() +
13140-
eventName$jscomp$inline_1664.slice(1);
13148+
var eventName$jscomp$inline_1665 =
13149+
simpleEventPluginEvents[i$jscomp$inline_1664],
13150+
domEventName$jscomp$inline_1666 =
13151+
eventName$jscomp$inline_1665.toLowerCase(),
13152+
capitalizedEvent$jscomp$inline_1667 =
13153+
eventName$jscomp$inline_1665[0].toUpperCase() +
13154+
eventName$jscomp$inline_1665.slice(1);
1314113155
registerSimpleEvent(
13142-
domEventName$jscomp$inline_1665,
13143-
"on" + capitalizedEvent$jscomp$inline_1666
13156+
domEventName$jscomp$inline_1666,
13157+
"on" + capitalizedEvent$jscomp$inline_1667
1314413158
);
1314513159
}
1314613160
registerSimpleEvent(ANIMATION_END, "onAnimationEnd");
@@ -16482,34 +16496,48 @@ function suspendResource(hoistableRoot, resource, props) {
1648216496
hoistableRoot.addEventListener("error", resource));
1648316497
}
1648416498
}
16485-
function waitForCommitToBeReady() {
16499+
function waitForCommitToBeReady(timeoutOffset) {
1648616500
if (null === suspendedState) throw Error(formatProdErrorMessage(475));
1648716501
var state = suspendedState;
1648816502
state.stylesheets &&
1648916503
0 === state.count &&
1649016504
insertSuspendedStylesheets(state, state.stylesheets);
16491-
return 0 < state.count
16505+
return 0 < state.count || 0 < state.imgCount
1649216506
? function (commit) {
1649316507
var stylesheetTimer = setTimeout(function () {
16494-
state.stylesheets &&
16495-
insertSuspendedStylesheets(state, state.stylesheets);
16496-
if (state.unsuspend) {
16497-
var unsuspend = state.unsuspend;
16498-
state.unsuspend = null;
16499-
unsuspend();
16500-
}
16501-
}, 6e4);
16508+
state.stylesheets &&
16509+
insertSuspendedStylesheets(state, state.stylesheets);
16510+
if (state.unsuspend) {
16511+
var unsuspend = state.unsuspend;
16512+
state.unsuspend = null;
16513+
unsuspend();
16514+
}
16515+
}, 6e4 + timeoutOffset),
16516+
imgTimer = setTimeout(function () {
16517+
state.waitingForImages = !1;
16518+
if (
16519+
0 === state.count &&
16520+
(state.stylesheets &&
16521+
insertSuspendedStylesheets(state, state.stylesheets),
16522+
state.unsuspend)
16523+
) {
16524+
var unsuspend = state.unsuspend;
16525+
state.unsuspend = null;
16526+
unsuspend();
16527+
}
16528+
}, 500 + timeoutOffset);
1650216529
state.unsuspend = commit;
1650316530
return function () {
1650416531
state.unsuspend = null;
1650516532
clearTimeout(stylesheetTimer);
16533+
clearTimeout(imgTimer);
1650616534
};
1650716535
}
1650816536
: null;
1650916537
}
1651016538
function onUnsuspend() {
1651116539
this.count--;
16512-
if (0 === this.count)
16540+
if (0 === this.count && (0 === this.imgCount || !this.waitingForImages))
1651316541
if (this.stylesheets) insertSuspendedStylesheets(this, this.stylesheets);
1651416542
else if (this.unsuspend) {
1651516543
var unsuspend = this.unsuspend;
@@ -17386,16 +17414,16 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1738617414
0 === i && attemptExplicitHydrationTarget(target);
1738717415
}
1738817416
};
17389-
var isomorphicReactPackageVersion$jscomp$inline_2069 = React.version;
17417+
var isomorphicReactPackageVersion$jscomp$inline_2073 = React.version;
1739017418
if (
17391-
"19.2.0-native-fb-e12b0bdc-20250915" !==
17392-
isomorphicReactPackageVersion$jscomp$inline_2069
17419+
"19.2.0-native-fb-e3f19180-20250915" !==
17420+
isomorphicReactPackageVersion$jscomp$inline_2073
1739317421
)
1739417422
throw Error(
1739517423
formatProdErrorMessage(
1739617424
527,
17397-
isomorphicReactPackageVersion$jscomp$inline_2069,
17398-
"19.2.0-native-fb-e12b0bdc-20250915"
17425+
isomorphicReactPackageVersion$jscomp$inline_2073,
17426+
"19.2.0-native-fb-e3f19180-20250915"
1739917427
)
1740017428
);
1740117429
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17415,24 +17443,24 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1741517443
null === componentOrElement ? null : componentOrElement.stateNode;
1741617444
return componentOrElement;
1741717445
};
17418-
var internals$jscomp$inline_2642 = {
17446+
var internals$jscomp$inline_2646 = {
1741917447
bundleType: 0,
17420-
version: "19.2.0-native-fb-e12b0bdc-20250915",
17448+
version: "19.2.0-native-fb-e3f19180-20250915",
1742117449
rendererPackageName: "react-dom",
1742217450
currentDispatcherRef: ReactSharedInternals,
17423-
reconcilerVersion: "19.2.0-native-fb-e12b0bdc-20250915"
17451+
reconcilerVersion: "19.2.0-native-fb-e3f19180-20250915"
1742417452
};
1742517453
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
17426-
var hook$jscomp$inline_2643 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
17454+
var hook$jscomp$inline_2647 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
1742717455
if (
17428-
!hook$jscomp$inline_2643.isDisabled &&
17429-
hook$jscomp$inline_2643.supportsFiber
17456+
!hook$jscomp$inline_2647.isDisabled &&
17457+
hook$jscomp$inline_2647.supportsFiber
1743017458
)
1743117459
try {
17432-
(rendererID = hook$jscomp$inline_2643.inject(
17433-
internals$jscomp$inline_2642
17460+
(rendererID = hook$jscomp$inline_2647.inject(
17461+
internals$jscomp$inline_2646
1743417462
)),
17435-
(injectedHook = hook$jscomp$inline_2643);
17463+
(injectedHook = hook$jscomp$inline_2647);
1743617464
} catch (err) {}
1743717465
}
1743817466
exports.createRoot = function (container, options) {
@@ -17527,4 +17555,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1752717555
listenToAllSupportedEvents(container);
1752817556
return new ReactDOMHydrationRoot(initialChildren);
1752917557
};
17530-
exports.version = "19.2.0-native-fb-e12b0bdc-20250915";
17558+
exports.version = "19.2.0-native-fb-e3f19180-20250915";

0 commit comments

Comments
 (0)