Skip to content

Commit 77beaa1

Browse files
committed
[Fizz] Prevent uncloned large precomputed chunks without relying on render-time assertions (#28568)
A while back we implemented a heuristic that if a chunk was large it was assumed to be produced by the render and thus was safe to stream which results in transferring the underlying object memory. Later we ran into an issue where a precomputed chunk grew large enough to trigger this hueristic and it started causing renders to fail because once a second render had occurred the precomputed chunk would not have an underlying buffer of bytes to send and these bytes would be omitted from the stream. We implemented a technique to detect large precomputed chunks and we enforced that these always be cloned before writing. Unfortunately our test coverage was not perfect and there has been for a very long time now a usage pattern where if you complete a boundary in one flush and then complete a boundary that has stylehsheet dependencies in another flush you can get a large precomputed chunk that was not being cloned to be sent twice causing streaming errors. I've thought about why we even went with this solution in the first place and I think it was a mistake. It relies on a dev only check to catch paired with potentially version specific order of operations on the streaming side. This is too unreliable. Additionally the low limit of view size for Edge is not used in Node.js but there is not real justification for this. In this change I updated the view size for edge streaming to match Node at 2048 bytes which is still relatively small and we have no data one way or another to preference 512 over this. Then I updated the assertion logic to error anytime a precomputed chunk exceeds the size. This eliminates the need to clone these chunks by just making sure our view size is always larger than the largest precomputed chunk we can possibly write. I'm generally in favor of this for a few reasons. First, we'll always know during testing whether we've violated the limit as long as we exercise each stream config because the precomputed chunks are created in module scope. Second, we can always split up large chunks so making sure the precomptued chunk is smaller than whatever view size we actually desire is relatively trivial. DiffTrain build for commit b09e102.
1 parent 85904c9 commit 77beaa1

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25454,7 +25454,7 @@ if (__DEV__) {
2545425454
return root;
2545525455
}
2545625456

25457-
var ReactVersion = "18.3.0-canary-1293047d6-20240315";
25457+
var ReactVersion = "18.3.0-canary-b09e102ff-20240316";
2545825458

2545925459
// Might add PROFILE later.
2546025460

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9175,7 +9175,7 @@ var devToolsConfig$jscomp$inline_1016 = {
91759175
throw Error("TestRenderer does not support findFiberByHostInstance()");
91769176
},
91779177
bundleType: 0,
9178-
version: "18.3.0-canary-1293047d6-20240315",
9178+
version: "18.3.0-canary-b09e102ff-20240316",
91799179
rendererPackageName: "react-test-renderer"
91809180
};
91819181
var internals$jscomp$inline_1194 = {
@@ -9206,7 +9206,7 @@ var internals$jscomp$inline_1194 = {
92069206
scheduleRoot: null,
92079207
setRefreshHandler: null,
92089208
getCurrentFiber: null,
9209-
reconcilerVersion: "18.3.0-canary-1293047d6-20240315"
9209+
reconcilerVersion: "18.3.0-canary-b09e102ff-20240316"
92109210
};
92119211
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
92129212
var hook$jscomp$inline_1195 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9603,7 +9603,7 @@ var devToolsConfig$jscomp$inline_1058 = {
96039603
throw Error("TestRenderer does not support findFiberByHostInstance()");
96049604
},
96059605
bundleType: 0,
9606-
version: "18.3.0-canary-1293047d6-20240315",
9606+
version: "18.3.0-canary-b09e102ff-20240316",
96079607
rendererPackageName: "react-test-renderer"
96089608
};
96099609
var internals$jscomp$inline_1235 = {
@@ -9634,7 +9634,7 @@ var internals$jscomp$inline_1235 = {
96349634
scheduleRoot: null,
96359635
setRefreshHandler: null,
96369636
getCurrentFiber: null,
9637-
reconcilerVersion: "18.3.0-canary-1293047d6-20240315"
9637+
reconcilerVersion: "18.3.0-canary-b09e102ff-20240316"
96389638
};
96399639
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96409640
var hook$jscomp$inline_1236 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (__DEV__) {
2626
}
2727
var dynamicFlags = require("ReactNativeInternalFeatureFlags");
2828

29-
var ReactVersion = "18.3.0-canary-1293047d6-20240315";
29+
var ReactVersion = "18.3.0-canary-b09e102ff-20240316";
3030

3131
// ATTENTION
3232
// When adding new symbols to this file,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,4 +628,4 @@ exports.useSyncExternalStore = function (
628628
exports.useTransition = function () {
629629
return ReactCurrentDispatcher.current.useTransition();
630630
};
631-
exports.version = "18.3.0-canary-1293047d6-20240315";
631+
exports.version = "18.3.0-canary-b09e102ff-20240316";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ exports.useSyncExternalStore = function (
624624
exports.useTransition = function () {
625625
return ReactCurrentDispatcher.current.useTransition();
626626
};
627-
exports.version = "18.3.0-canary-1293047d6-20240315";
627+
exports.version = "18.3.0-canary-b09e102ff-20240316";
628628
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
629629
"function" ===
630630
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1293047d6063f3508af15e68cca916660ded791e
1+
b09e102ff1e2aaaf5eb6585b04609ac7ff54a5c8

0 commit comments

Comments
 (0)