Skip to content

Commit

Permalink
[Float][Fiber] Assume stylesheets in document are already loaded (#29811
Browse files Browse the repository at this point in the history
)

When we made stylesheets suspend even during high priority updates we
exposed a bug in the loading tracking of stylesheets that are loaded as
part of the preamble. This allowed these stylesheets to put suspense
boundaries into fallback mode more often than expected because cases
where a stylesheet was server rendered could now cause a fallback to
trigger which was never intended to happen.

This fix updates resource construction to evaluate whether the instance
exists in the DOM prior to construction and if so marks the resource as
loaded and inserted.

One ambiguity that needed to be solved still is how to tell whether a
stylesheet rendered as part of a late Suspense boundary reveal is
already loaded. I updated the instruction to clear out the loading
promise after successfully loading. This is useful because later if we
encounter this same resource again we can avoid the microtask if it is
already loaded. It also means that we can concretely understand that if
a stylesheet is in the DOM without this marker then it must have loaded
(or errored) already.

DiffTrain build for commit 20b6f4c.
  • Loading branch information
gnoff committed Jun 7, 2024
1 parent 3ffc777 commit 848ae6c
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-20841f9a62-20240607
19.0.0-native-fb-20b6f4c0e8-20240607
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1e3975bb7b9fe350a36865e6c41276e8>>
* @generated SignedSource<<016b8e5005c3117269d148d069d42a3c>>
*/

'use strict';
Expand Down Expand Up @@ -23586,7 +23586,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-native-fb-20841f9a62-20240607';
var ReactVersion = '19.0.0-native-fb-20b6f4c0e8-20240607';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a11af6f9b212cf2aeebb79b52de06240>>
* @generated SignedSource<<f437fde2b5cc5cf271a2b134492f83ff>>
*/

"use strict";
Expand Down Expand Up @@ -9336,7 +9336,7 @@ var devToolsConfig$jscomp$inline_1048 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-native-fb-20841f9a62-20240607",
version: "19.0.0-native-fb-20b6f4c0e8-20240607",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1235 = {
Expand Down Expand Up @@ -9367,7 +9367,7 @@ var internals$jscomp$inline_1235 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-20841f9a62-20240607"
reconcilerVersion: "19.0.0-native-fb-20b6f4c0e8-20240607"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1236 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d5ac2136799fa3f299d972c903df46a7>>
* @generated SignedSource<<760cde75b26f1ffde19c02e46adb578b>>
*/

"use strict";
Expand Down Expand Up @@ -9958,7 +9958,7 @@ var devToolsConfig$jscomp$inline_1131 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-native-fb-20841f9a62-20240607",
version: "19.0.0-native-fb-20b6f4c0e8-20240607",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
Expand Down Expand Up @@ -10002,7 +10002,7 @@ var devToolsConfig$jscomp$inline_1131 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-20841f9a62-20240607"
reconcilerVersion: "19.0.0-native-fb-20b6f4c0e8-20240607"
});
exports._Scheduler = Scheduler;
exports.act = act;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<ff060bbd88a6beeead57e84d35a86af9>>
* @generated SignedSource<<9cbef442c26efa70ee446da21a60c04a>>
*/

'use strict';
Expand All @@ -24,7 +24,7 @@ if (
}
var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags');

var ReactVersion = '19.0.0-native-fb-20841f9a62-20240607';
var ReactVersion = '19.0.0-native-fb-20b6f4c0e8-20240607';

// Re-export dynamic flags from the internal module.
var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-exporting to avoid a dynamic look-up on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2ffd656ec0297ecbc31dc231e472fdcc>>
* @generated SignedSource<<c219dcd8f45478b8be32095daf648132>>
*/

"use strict";
Expand Down Expand Up @@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-20841f9a62-20240607";
exports.version = "19.0.0-native-fb-20b6f4c0e8-20240607";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f0f71fc7f22a13063a2728358a9bb19f>>
* @generated SignedSource<<6a83e2f57b46ce727606dc77968167b1>>
*/

"use strict";
Expand Down Expand Up @@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-20841f9a62-20240607";
exports.version = "19.0.0-native-fb-20b6f4c0e8-20240607";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20841f9a6205a633e6d08a274db974481daaca23
20b6f4c0e8a1f40ee61735201645e0395ff08f94
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<296800793d2a2f729d1bff6f79a75838>>
* @generated SignedSource<<4f525e82c9094381536a076a2645ab79>>
*/

'use strict';
Expand Down Expand Up @@ -26322,7 +26322,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-native-fb-20841f9a62-20240607';
var ReactVersion = '19.0.0-native-fb-20b6f4c0e8-20240607';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2e93e3cb365a6be9a8ee47867dac0398>>
* @generated SignedSource<<7a96adf78698dcde93c8ad299e54be2b>>
*/

"use strict";
Expand Down Expand Up @@ -10591,7 +10591,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1125 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-native-fb-20841f9a62-20240607",
version: "19.0.0-native-fb-20b6f4c0e8-20240607",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10634,7 +10634,7 @@ var internals$jscomp$inline_1351 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-20841f9a62-20240607"
reconcilerVersion: "19.0.0-native-fb-20b6f4c0e8-20240607"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1352 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<194089cf930db3dabf7c433122d32db4>>
* @generated SignedSource<<7ac37d27a4198431b2b746eb7d1d5ab8>>
*/

"use strict";
Expand Down Expand Up @@ -11297,7 +11297,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1206 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-native-fb-20841f9a62-20240607",
version: "19.0.0-native-fb-20b6f4c0e8-20240607",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11353,7 +11353,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-20841f9a62-20240607"
reconcilerVersion: "19.0.0-native-fb-20b6f4c0e8-20240607"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d31e095df678856e2bbc86c140e909de>>
* @generated SignedSource<<c3e62bede61614a6946c25f568fb53ba>>
*/

'use strict';
Expand Down Expand Up @@ -26677,7 +26677,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-native-fb-20841f9a62-20240607';
var ReactVersion = '19.0.0-native-fb-20b6f4c0e8-20240607';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b7610a64cf4a6f65902a28874cb860a1>>
* @generated SignedSource<<884b6db437cfb8f0d1cce5e8240b4b72>>
*/

"use strict";
Expand Down Expand Up @@ -10734,11 +10734,11 @@ function traverseOwnerTreeUp(hierarchy, instance) {
traverseOwnerTreeUp(hierarchy, instance);
}
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-20841f9a62-20240607" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-20b6f4c0e8-20240607" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-native-fb-20841f9a62-20240607\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-native-fb-20b6f4c0e8-20240607\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
Expand Down Expand Up @@ -10788,7 +10788,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1193 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "19.0.0-native-fb-20841f9a62-20240607",
version: "19.0.0-native-fb-20b6f4c0e8-20240607",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10831,7 +10831,7 @@ var internals$jscomp$inline_1440 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-20841f9a62-20240607"
reconcilerVersion: "19.0.0-native-fb-20b6f4c0e8-20240607"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1441 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<0decd91232e7efab69bf0bafe80583e9>>
* @generated SignedSource<<c0b5a3fafeea8705ed777b3e03855efe>>
*/

"use strict";
Expand Down Expand Up @@ -11441,11 +11441,11 @@ function traverseOwnerTreeUp(hierarchy, instance) {
traverseOwnerTreeUp(hierarchy, instance);
}
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-20841f9a62-20240607" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-20b6f4c0e8-20240607" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-native-fb-20841f9a62-20240607\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-native-fb-20b6f4c0e8-20240607\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
Expand Down Expand Up @@ -11495,7 +11495,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1274 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "19.0.0-native-fb-20841f9a62-20240607",
version: "19.0.0-native-fb-20b6f4c0e8-20240607",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11551,7 +11551,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-20841f9a62-20240607"
reconcilerVersion: "19.0.0-native-fb-20b6f4c0e8-20240607"
});
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
computeComponentStackForErrorReporting: function (reactTag) {
Expand Down

0 comments on commit 848ae6c

Please sign in to comment.