Skip to content

Commit 9f3e8fb

Browse files
committed
[Fiber] track stylesheet preloads when explicitly preloaded (facebook#36386)
Previously stylesheet resources would omit connecting with preloads inserted via `preload` which caused unecessary suspension of commits since the stylsheet resource would attempt to load the stylesheet again and delay the initial commit or commit a fallback (depending on whether the current screen should remain). This missing piece is that if you preload a stylesheet you must be able to use that sheets loading state when determining if the stylesheet is already loaded or not. This adds a pending indicator on client inserted prelaod links. We still assume SSR'd preloads are already loaded. DiffTrain build for [d5736f0](facebook@d5736f0)
1 parent 3e3217d commit 9f3e8fb

21 files changed

Lines changed: 846 additions & 706 deletions

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.3.0-native-fb-561ed529-20260423
1+
19.3.0-native-fb-d5736f09-20260507

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<<63bc63ec9bc514e48b5c6681a0562c19>>
10+
* @generated SignedSource<<97915a97dda9cb945d4b11bb543e9ad0>>
1111
*/
1212

1313
"use strict";
@@ -410,5 +410,5 @@ __DEV__ &&
410410
exports.useFormStatus = function () {
411411
return resolveDispatcher().useHostTransitionStatus();
412412
};
413-
exports.version = "19.3.0-native-fb-561ed529-20260423";
413+
exports.version = "19.3.0-native-fb-d5736f09-20260507";
414414
})();

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<<97062c38fedb156001ff7deb2b863b4b>>
10+
* @generated SignedSource<<0a762e69dc2ae696b02333d8b3b0559f>>
1111
*/
1212

1313
"use strict";
@@ -209,4 +209,4 @@ exports.useFormState = function (action, initialState, permalink) {
209209
exports.useFormStatus = function () {
210210
return ReactSharedInternals.H.useHostTransitionStatus();
211211
};
212-
exports.version = "19.3.0-native-fb-561ed529-20260423";
212+
exports.version = "19.3.0-native-fb-d5736f09-20260507";

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<<97062c38fedb156001ff7deb2b863b4b>>
10+
* @generated SignedSource<<0a762e69dc2ae696b02333d8b3b0559f>>
1111
*/
1212

1313
"use strict";
@@ -209,4 +209,4 @@ exports.useFormState = function (action, initialState, permalink) {
209209
exports.useFormStatus = function () {
210210
return ReactSharedInternals.H.useHostTransitionStatus();
211211
};
212-
exports.version = "19.3.0-native-fb-561ed529-20260423";
212+
exports.version = "19.3.0-native-fb-d5736f09-20260507";

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

Lines changed: 207 additions & 187 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: 99 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b44db23fb9f3f540b2f23709190fe99e>>
10+
* @generated SignedSource<<aa77cbbbeffad2e80b0e7267b8215139>>
1111
*/
1212

1313
/*
@@ -1029,7 +1029,8 @@ var randomKey = Math.random().toString(36).slice(2),
10291029
internalEventHandlesSetKey = "__reactHandles$" + randomKey,
10301030
internalRootNodeResourcesKey = "__reactResources$" + randomKey,
10311031
internalHoistableMarker = "__reactMarker$" + randomKey,
1032-
internalScrollTimer = "__reactScroll$" + randomKey;
1032+
internalScrollTimer = "__reactScroll$" + randomKey,
1033+
internalLoadPendingKey = "__reactLoad$" + randomKey;
10331034
function detachDeletedInstance(node) {
10341035
delete node[internalInstanceKey];
10351036
delete node[internalPropsKey];
@@ -1099,6 +1100,9 @@ function getResourcesFromRoot(root) {
10991100
function markNodeAsHoistable(node) {
11001101
node[internalHoistableMarker] = !0;
11011102
}
1103+
function clearPendingLoadOnNode(node) {
1104+
node[internalLoadPendingKey] = void 0;
1105+
}
11021106
var allNativeEvents = new Set(),
11031107
registrationNameDependencies = {};
11041108
function registerTwoPhaseEvent(registrationName, dependencies) {
@@ -17554,26 +17558,37 @@ function preload(href, as, options) {
1755417558
case "script":
1755517559
key = getScriptKey(href);
1755617560
}
17557-
preloadPropsMap.has(key) ||
17558-
((href = assign(
17559-
{
17560-
rel: "preload",
17561-
href:
17562-
"image" === as && options && options.imageSrcSet ? void 0 : href,
17563-
as: as
17564-
},
17565-
options
17566-
)),
17567-
preloadPropsMap.set(key, href),
17568-
null !== ownerDocument.querySelector(preloadSelector) ||
17569-
("style" === as &&
17570-
ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) ||
17571-
("script" === as &&
17572-
ownerDocument.querySelector(getScriptSelectorFromKey(key))) ||
17573-
((as = ownerDocument.createElement("link")),
17574-
setInitialProperties(as, "link", href),
17575-
markNodeAsHoistable(as),
17576-
ownerDocument.head.appendChild(as)));
17561+
if (
17562+
!(
17563+
preloadPropsMap.has(key) ||
17564+
((href = assign(
17565+
{
17566+
rel: "preload",
17567+
href:
17568+
"image" === as && options && options.imageSrcSet ? void 0 : href,
17569+
as: as
17570+
},
17571+
options
17572+
)),
17573+
preloadPropsMap.set(key, href),
17574+
null !== ownerDocument.querySelector(preloadSelector) ||
17575+
("style" === as &&
17576+
ownerDocument.querySelector(getStylesheetSelectorFromKey(key))) ||
17577+
("script" === as &&
17578+
ownerDocument.querySelector(getScriptSelectorFromKey(key))))
17579+
)
17580+
) {
17581+
var instance = ownerDocument.createElement("link");
17582+
setInitialProperties(instance, "link", href);
17583+
"style" === as &&
17584+
((instance[internalLoadPendingKey] = !0),
17585+
(instance.onload = instance.onerror =
17586+
function () {
17587+
clearPendingLoadOnNode(instance);
17588+
}));
17589+
markNodeAsHoistable(instance);
17590+
ownerDocument.head.appendChild(instance);
17591+
}
1757717592
}
1757817593
}
1757917594
function preloadModule(href, options) {
@@ -17734,19 +17749,19 @@ function getResource(type, currentProps, pendingProps, currentResource) {
1773417749
case "style":
1773517750
return "string" === typeof pendingProps.precedence &&
1773617751
"string" === typeof pendingProps.href
17737-
? ((currentProps = getStyleKey(pendingProps.href)),
17738-
(pendingProps = getResourcesFromRoot(
17752+
? ((pendingProps = getStyleKey(pendingProps.href)),
17753+
(currentProps = getResourcesFromRoot(
1773917754
JSCompiler_inline_result
1774017755
).hoistableStyles),
17741-
(currentResource = pendingProps.get(currentProps)),
17756+
(currentResource = currentProps.get(pendingProps)),
1774217757
currentResource ||
1774317758
((currentResource = {
1774417759
type: "style",
1774517760
instance: null,
1774617761
count: 0,
1774717762
state: null
1774817763
}),
17749-
pendingProps.set(currentProps, currentResource)),
17764+
currentProps.set(pendingProps, currentResource)),
1775017765
currentResource)
1775117766
: { type: "void", instance: null, count: 0, state: null };
1775217767
case "link":
@@ -17772,27 +17787,27 @@ function getResource(type, currentProps, pendingProps, currentResource) {
1777217787
styles$280.set(type, resource$281),
1777317788
(styles$280 = JSCompiler_inline_result.querySelector(
1777417789
getStylesheetSelectorFromKey(type)
17775-
)) &&
17776-
!styles$280._p &&
17777-
((resource$281.instance = styles$280),
17778-
(resource$281.state.loading = 5)),
17779-
preloadPropsMap.has(type) ||
17780-
((pendingProps = {
17781-
rel: "preload",
17782-
as: "style",
17783-
href: pendingProps.href,
17784-
crossOrigin: pendingProps.crossOrigin,
17785-
integrity: pendingProps.integrity,
17786-
media: pendingProps.media,
17787-
hrefLang: pendingProps.hrefLang,
17788-
referrerPolicy: pendingProps.referrerPolicy
17789-
}),
17790-
preloadPropsMap.set(type, pendingProps),
17791-
styles$280 ||
17790+
))
17791+
? styles$280._p ||
17792+
((resource$281.instance = styles$280),
17793+
(resource$281.state.loading = 5))
17794+
: ((styles$280 = preloadPropsMap.get(type)),
17795+
styles$280 ||
17796+
((styles$280 = {
17797+
rel: "preload",
17798+
as: "style",
17799+
href: pendingProps.href,
17800+
crossOrigin: pendingProps.crossOrigin,
17801+
integrity: pendingProps.integrity,
17802+
media: pendingProps.media,
17803+
hrefLang: pendingProps.hrefLang,
17804+
referrerPolicy: pendingProps.referrerPolicy
17805+
}),
17806+
preloadPropsMap.set(type, styles$280)),
1779217807
preloadStylesheet(
1779317808
JSCompiler_inline_result,
1779417809
type,
17795-
pendingProps,
17810+
styles$280,
1779617811
resource$281.state
1779717812
)));
1779817813
if (currentProps && null === currentResource)
@@ -17810,19 +17825,19 @@ function getResource(type, currentProps, pendingProps, currentResource) {
1781017825
currentProps &&
1781117826
"function" !== typeof currentProps &&
1781217827
"symbol" !== typeof currentProps
17813-
? ((currentProps = getScriptKey(pendingProps)),
17814-
(pendingProps = getResourcesFromRoot(
17828+
? ((pendingProps = getScriptKey(pendingProps)),
17829+
(currentProps = getResourcesFromRoot(
1781517830
JSCompiler_inline_result
1781617831
).hoistableScripts),
17817-
(currentResource = pendingProps.get(currentProps)),
17832+
(currentResource = currentProps.get(pendingProps)),
1781817833
currentResource ||
1781917834
((currentResource = {
1782017835
type: "script",
1782117836
instance: null,
1782217837
count: 0,
1782317838
state: null
1782417839
}),
17825-
pendingProps.set(currentProps, currentResource)),
17840+
currentProps.set(pendingProps, currentResource)),
1782617841
currentResource)
1782717842
: { type: "void", instance: null, count: 0, state: null }
1782817843
);
@@ -17843,19 +17858,29 @@ function stylesheetPropsFromRawProps(rawProps) {
1784317858
});
1784417859
}
1784517860
function preloadStylesheet(ownerDocument, key, preloadProps, state) {
17846-
ownerDocument.querySelector('link[rel="preload"][as="style"][' + key + "]")
17847-
? (state.loading = 1)
17848-
: ((key = ownerDocument.createElement("link")),
17849-
(state.preload = key),
17850-
key.addEventListener("load", function () {
17851-
return (state.loading |= 1);
17852-
}),
17853-
key.addEventListener("error", function () {
17854-
return (state.loading |= 2);
17855-
}),
17861+
if (
17862+
(key = ownerDocument.querySelector(
17863+
'link[rel="preload"][as="style"][' + key + "]"
17864+
))
17865+
) {
17866+
if (!0 !== key[internalLoadPendingKey]) {
17867+
state.loading = 1;
17868+
return;
17869+
}
17870+
} else
17871+
(key = ownerDocument.createElement("link")),
17872+
(key[internalLoadPendingKey] = !0),
17873+
(key.onload = key.onerror = clearPendingLoadOnNode.bind(null, key)),
1785617874
setInitialProperties(key, "link", preloadProps),
1785717875
markNodeAsHoistable(key),
17858-
ownerDocument.head.appendChild(key));
17876+
ownerDocument.head.appendChild(key);
17877+
state.preload = key;
17878+
key.addEventListener("load", function () {
17879+
return (state.loading |= 1);
17880+
});
17881+
key.addEventListener("error", function () {
17882+
return (state.loading |= 2);
17883+
});
1785917884
}
1786017885
function getScriptKey(src) {
1786117886
return '[src="' + escapeSelectorAttributeValueInsideDoubleQuotes(src) + '"]';
@@ -19087,16 +19112,16 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1908719112
0 === i && attemptExplicitHydrationTarget(target);
1908819113
}
1908919114
};
19090-
var isomorphicReactPackageVersion$jscomp$inline_2130 = React.version;
19115+
var isomorphicReactPackageVersion$jscomp$inline_2134 = React.version;
1909119116
if (
19092-
"19.3.0-native-fb-561ed529-20260423" !==
19093-
isomorphicReactPackageVersion$jscomp$inline_2130
19117+
"19.3.0-native-fb-d5736f09-20260507" !==
19118+
isomorphicReactPackageVersion$jscomp$inline_2134
1909419119
)
1909519120
throw Error(
1909619121
formatProdErrorMessage(
1909719122
527,
19098-
isomorphicReactPackageVersion$jscomp$inline_2130,
19099-
"19.3.0-native-fb-561ed529-20260423"
19123+
isomorphicReactPackageVersion$jscomp$inline_2134,
19124+
"19.3.0-native-fb-d5736f09-20260507"
1910019125
)
1910119126
);
1910219127
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19116,24 +19141,24 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1911619141
null === componentOrElement ? null : componentOrElement.stateNode;
1911719142
return componentOrElement;
1911819143
};
19119-
var internals$jscomp$inline_2726 = {
19144+
var internals$jscomp$inline_2730 = {
1912019145
bundleType: 0,
19121-
version: "19.3.0-native-fb-561ed529-20260423",
19146+
version: "19.3.0-native-fb-d5736f09-20260507",
1912219147
rendererPackageName: "react-dom",
1912319148
currentDispatcherRef: ReactSharedInternals,
19124-
reconcilerVersion: "19.3.0-native-fb-561ed529-20260423"
19149+
reconcilerVersion: "19.3.0-native-fb-d5736f09-20260507"
1912519150
};
1912619151
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
19127-
var hook$jscomp$inline_2727 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
19152+
var hook$jscomp$inline_2731 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
1912819153
if (
19129-
!hook$jscomp$inline_2727.isDisabled &&
19130-
hook$jscomp$inline_2727.supportsFiber
19154+
!hook$jscomp$inline_2731.isDisabled &&
19155+
hook$jscomp$inline_2731.supportsFiber
1913119156
)
1913219157
try {
19133-
(rendererID = hook$jscomp$inline_2727.inject(
19134-
internals$jscomp$inline_2726
19158+
(rendererID = hook$jscomp$inline_2731.inject(
19159+
internals$jscomp$inline_2730
1913519160
)),
19136-
(injectedHook = hook$jscomp$inline_2727);
19161+
(injectedHook = hook$jscomp$inline_2731);
1913719162
} catch (err) {}
1913819163
}
1913919164
exports.createRoot = function (container, options) {
@@ -19228,4 +19253,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1922819253
listenToAllSupportedEvents(container);
1922919254
return new ReactDOMHydrationRoot(initialChildren);
1923019255
};
19231-
exports.version = "19.3.0-native-fb-561ed529-20260423";
19256+
exports.version = "19.3.0-native-fb-d5736f09-20260507";

0 commit comments

Comments
 (0)