Skip to content

Commit acdffc0

Browse files
committed
Create Fabric-specific version of ReactNativeAttributesPayload (#28841)
## Summary This PR introduces Fabric-only version of `ReactNativeAttributesPayload`. It is a copy-paste of `ReactNativeAttributesPayload.js`, and is called `ReactNativeAttributesPayloadFabric.js`. The idea behind this change is that certain optimizations in prop diffing may actually be a regression on the old architecture. For example, removing custom diffing may result in larger updateProps payloads. Which is, I guess, fine with JSI, but might be a problem with the bridge. ## How did you test this change? There should be no runtime effect of this change. DiffTrain build for commit 7039834.
1 parent 3e4d97d commit acdffc0

File tree

4 files changed

+43
-154
lines changed

4 files changed

+43
-154
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9b1300209eb00a2d6c645fddf6d2729d67d7b10a
1+
703983426243422d9726ca3a0c7eef54e173a6bb

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js

+4-61
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<92ed224870f6202a614121cda759ff80>>
10+
* @generated SignedSource<<b948a7523c731b45fbc28f4bfeb2bf96>>
1111
*/
1212

1313
'use strict';
@@ -2341,7 +2341,6 @@ var alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries,
23412341
consoleManagedByDevToolsDuringStrictMode = dynamicFlags.consoleManagedByDevToolsDuringStrictMode,
23422342
disableDefaultPropsExceptForClasses = dynamicFlags.disableDefaultPropsExceptForClasses,
23432343
disableStringRefs = dynamicFlags.disableStringRefs,
2344-
enableAddPropertiesFastPath = dynamicFlags.enableAddPropertiesFastPath,
23452344
enableDeferRootSchedulingToMicrotask = dynamicFlags.enableDeferRootSchedulingToMicrotask,
23462345
enableEarlyReturnForPropDiffing = dynamicFlags.enableEarlyReturnForPropDiffing,
23472346
enableInfiniteRenderLoopDetection = dynamicFlags.enableInfiniteRenderLoopDetection,
@@ -3367,70 +3366,14 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
33673366

33683367
return updatePayload;
33693368
}
3370-
3371-
function fastAddProperties(updatePayload, nextProps, validAttributes) {
3372-
var attributeConfig;
3373-
var nextProp;
3374-
3375-
for (var propKey in nextProps) {
3376-
nextProp = nextProps[propKey];
3377-
3378-
if (nextProp === undefined) {
3379-
continue;
3380-
}
3381-
3382-
attributeConfig = validAttributes[propKey];
3383-
3384-
if (attributeConfig === undefined) {
3385-
continue;
3386-
}
3387-
3388-
if (typeof nextProp === 'function') {
3389-
nextProp = true;
3390-
}
3391-
3392-
if (typeof attributeConfig !== 'object') {
3393-
if (!updatePayload) {
3394-
updatePayload = {};
3395-
}
3396-
3397-
updatePayload[propKey] = nextProp;
3398-
continue;
3399-
}
3400-
3401-
if (typeof attributeConfig.process === 'function') {
3402-
if (!updatePayload) {
3403-
updatePayload = {};
3404-
}
3405-
3406-
updatePayload[propKey] = attributeConfig.process(nextProp);
3407-
continue;
3408-
}
3409-
3410-
if (isArray(nextProp)) {
3411-
for (var i = 0; i < nextProp.length; i++) {
3412-
updatePayload = fastAddProperties(updatePayload, nextProp[i], attributeConfig);
3413-
}
3414-
3415-
continue;
3416-
}
3417-
3418-
updatePayload = fastAddProperties(updatePayload, nextProp, attributeConfig);
3419-
}
3420-
3421-
return updatePayload;
3422-
}
34233369
/**
34243370
* addProperties adds all the valid props to the payload after being processed.
34253371
*/
34263372

34273373

34283374
function addProperties(updatePayload, props, validAttributes) {
3429-
if (enableAddPropertiesFastPath) {
3430-
return fastAddProperties(updatePayload, props, validAttributes);
3431-
} else {
3432-
return diffProperties(updatePayload, emptyObject$1, props, validAttributes);
3433-
}
3375+
// TODO: Fast path
3376+
return diffProperties(updatePayload, emptyObject$1, props, validAttributes);
34343377
}
34353378
/**
34363379
* clearProperties clears all the previous props by adding a null sentinel
@@ -26502,7 +26445,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
2650226445
return root;
2650326446
}
2650426447

26505-
var ReactVersion = '19.0.0-beta-80fbc2d8';
26448+
var ReactVersion = '19.0.0-beta-303370bf';
2650626449

2650726450
/*
2650826451
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js

+19-46
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<6ac902add05453f485e7c7713caf3bde>>
10+
* @generated SignedSource<<9218133e45a38bee509673d882f7b469>>
1111
*/
1212

1313
"use strict";
@@ -1116,7 +1116,6 @@ var alwaysThrottleRetries = dynamicFlagsUntyped.alwaysThrottleRetries,
11161116
disableDefaultPropsExceptForClasses =
11171117
dynamicFlagsUntyped.disableDefaultPropsExceptForClasses,
11181118
disableStringRefs = dynamicFlagsUntyped.disableStringRefs,
1119-
enableAddPropertiesFastPath = dynamicFlagsUntyped.enableAddPropertiesFastPath,
11201119
enableDeferRootSchedulingToMicrotask =
11211120
dynamicFlagsUntyped.enableDeferRootSchedulingToMicrotask,
11221121
enableEarlyReturnForPropDiffing =
@@ -1480,7 +1479,12 @@ function diffNestedProperty(
14801479
function addNestedProperty(updatePayload, nextProp, validAttributes) {
14811480
if (!nextProp) return updatePayload;
14821481
if (!isArrayImpl(nextProp))
1483-
return addProperties(updatePayload, nextProp, validAttributes);
1482+
return diffProperties(
1483+
updatePayload,
1484+
emptyObject$1,
1485+
nextProp,
1486+
validAttributes
1487+
);
14841488
for (var i = 0; i < nextProp.length; i++)
14851489
updatePayload = addNestedProperty(
14861490
updatePayload,
@@ -1590,44 +1594,6 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
15901594
)))));
15911595
return updatePayload;
15921596
}
1593-
function fastAddProperties(updatePayload, nextProps, validAttributes) {
1594-
var propKey;
1595-
for (propKey in nextProps) {
1596-
var nextProp = nextProps[propKey];
1597-
if (void 0 !== nextProp) {
1598-
var attributeConfig = validAttributes[propKey];
1599-
if (void 0 !== attributeConfig)
1600-
if (
1601-
("function" === typeof nextProp && (nextProp = !0),
1602-
"object" !== typeof attributeConfig)
1603-
)
1604-
updatePayload || (updatePayload = {}),
1605-
(updatePayload[propKey] = nextProp);
1606-
else if ("function" === typeof attributeConfig.process)
1607-
updatePayload || (updatePayload = {}),
1608-
(updatePayload[propKey] = attributeConfig.process(nextProp));
1609-
else if (isArrayImpl(nextProp))
1610-
for (var i = 0; i < nextProp.length; i++)
1611-
updatePayload = fastAddProperties(
1612-
updatePayload,
1613-
nextProp[i],
1614-
attributeConfig
1615-
);
1616-
else
1617-
updatePayload = fastAddProperties(
1618-
updatePayload,
1619-
nextProp,
1620-
attributeConfig
1621-
);
1622-
}
1623-
}
1624-
return updatePayload;
1625-
}
1626-
function addProperties(updatePayload, props, validAttributes) {
1627-
return enableAddPropertiesFastPath
1628-
? fastAddProperties(updatePayload, props, validAttributes)
1629-
: diffProperties(updatePayload, emptyObject$1, props, validAttributes);
1630-
}
16311597
function mountSafeCallback_NOT_REALLY_SAFE(context, callback) {
16321598
return function () {
16331599
if (
@@ -1678,8 +1644,9 @@ var ReactNativeFiberHostComponent = (function () {
16781644
);
16791645
};
16801646
_proto.setNativeProps = function (nativeProps) {
1681-
nativeProps = addProperties(
1647+
nativeProps = diffProperties(
16821648
null,
1649+
emptyObject$1,
16831650
nativeProps,
16841651
this.viewConfig.validAttributes
16851652
);
@@ -7240,7 +7207,12 @@ function completeWork(current, workInProgress, renderLanes) {
72407207
renderLanes = rootInstanceStackCursor.current;
72417208
current = allocateTag();
72427209
type = getViewConfigForType(type);
7243-
var updatePayload = addProperties(null, newProps, type.validAttributes);
7210+
var updatePayload = diffProperties(
7211+
null,
7212+
emptyObject$1,
7213+
newProps,
7214+
type.validAttributes
7215+
);
72447216
ReactNativePrivateInterface.UIManager.createView(
72457217
current,
72467218
type.uiViewClassName,
@@ -8435,8 +8407,9 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
84358407
try {
84368408
if (((newProps = root.stateNode), viewConfig)) {
84378409
var viewConfig$jscomp$0 = newProps.viewConfig;
8438-
var updatePayload$jscomp$0 = addProperties(
8410+
var updatePayload$jscomp$0 = diffProperties(
84398411
null,
8412+
emptyObject$1,
84408413
{ style: { display: "none" } },
84418414
viewConfig$jscomp$0.validAttributes
84428415
);
@@ -10808,7 +10781,7 @@ var roots = new Map(),
1080810781
devToolsConfig$jscomp$inline_1192 = {
1080910782
findFiberByHostInstance: getInstanceFromTag,
1081010783
bundleType: 0,
10811-
version: "19.0.0-beta-7fb39fd3",
10784+
version: "19.0.0-beta-11cf708a",
1081210785
rendererPackageName: "react-native-renderer",
1081310786
rendererConfig: {
1081410787
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -10851,7 +10824,7 @@ var internals$jscomp$inline_1441 = {
1085110824
scheduleRoot: null,
1085210825
setRefreshHandler: null,
1085310826
getCurrentFiber: null,
10854-
reconcilerVersion: "19.0.0-beta-7fb39fd3"
10827+
reconcilerVersion: "19.0.0-beta-11cf708a"
1085510828
};
1085610829
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1085710830
var hook$jscomp$inline_1442 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js

+19-46
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b6bd74ab5e48f155b9407635d6f44e66>>
10+
* @generated SignedSource<<7ec40d981bbcdacc39e55becc570911b>>
1111
*/
1212

1313
"use strict";
@@ -1120,7 +1120,6 @@ var alwaysThrottleRetries = dynamicFlagsUntyped.alwaysThrottleRetries,
11201120
disableDefaultPropsExceptForClasses =
11211121
dynamicFlagsUntyped.disableDefaultPropsExceptForClasses,
11221122
disableStringRefs = dynamicFlagsUntyped.disableStringRefs,
1123-
enableAddPropertiesFastPath = dynamicFlagsUntyped.enableAddPropertiesFastPath,
11241123
enableDeferRootSchedulingToMicrotask =
11251124
dynamicFlagsUntyped.enableDeferRootSchedulingToMicrotask,
11261125
enableEarlyReturnForPropDiffing =
@@ -1484,7 +1483,12 @@ function diffNestedProperty(
14841483
function addNestedProperty(updatePayload, nextProp, validAttributes) {
14851484
if (!nextProp) return updatePayload;
14861485
if (!isArrayImpl(nextProp))
1487-
return addProperties(updatePayload, nextProp, validAttributes);
1486+
return diffProperties(
1487+
updatePayload,
1488+
emptyObject$1,
1489+
nextProp,
1490+
validAttributes
1491+
);
14881492
for (var i = 0; i < nextProp.length; i++)
14891493
updatePayload = addNestedProperty(
14901494
updatePayload,
@@ -1594,44 +1598,6 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
15941598
)))));
15951599
return updatePayload;
15961600
}
1597-
function fastAddProperties(updatePayload, nextProps, validAttributes) {
1598-
var propKey;
1599-
for (propKey in nextProps) {
1600-
var nextProp = nextProps[propKey];
1601-
if (void 0 !== nextProp) {
1602-
var attributeConfig = validAttributes[propKey];
1603-
if (void 0 !== attributeConfig)
1604-
if (
1605-
("function" === typeof nextProp && (nextProp = !0),
1606-
"object" !== typeof attributeConfig)
1607-
)
1608-
updatePayload || (updatePayload = {}),
1609-
(updatePayload[propKey] = nextProp);
1610-
else if ("function" === typeof attributeConfig.process)
1611-
updatePayload || (updatePayload = {}),
1612-
(updatePayload[propKey] = attributeConfig.process(nextProp));
1613-
else if (isArrayImpl(nextProp))
1614-
for (var i = 0; i < nextProp.length; i++)
1615-
updatePayload = fastAddProperties(
1616-
updatePayload,
1617-
nextProp[i],
1618-
attributeConfig
1619-
);
1620-
else
1621-
updatePayload = fastAddProperties(
1622-
updatePayload,
1623-
nextProp,
1624-
attributeConfig
1625-
);
1626-
}
1627-
}
1628-
return updatePayload;
1629-
}
1630-
function addProperties(updatePayload, props, validAttributes) {
1631-
return enableAddPropertiesFastPath
1632-
? fastAddProperties(updatePayload, props, validAttributes)
1633-
: diffProperties(updatePayload, emptyObject$1, props, validAttributes);
1634-
}
16351601
function mountSafeCallback_NOT_REALLY_SAFE(context, callback) {
16361602
return function () {
16371603
if (
@@ -1682,8 +1648,9 @@ var ReactNativeFiberHostComponent = (function () {
16821648
);
16831649
};
16841650
_proto.setNativeProps = function (nativeProps) {
1685-
nativeProps = addProperties(
1651+
nativeProps = diffProperties(
16861652
null,
1653+
emptyObject$1,
16871654
nativeProps,
16881655
this.viewConfig.validAttributes
16891656
);
@@ -7506,7 +7473,12 @@ function completeWork(current, workInProgress, renderLanes) {
75067473
renderLanes = rootInstanceStackCursor.current;
75077474
current = allocateTag();
75087475
type = getViewConfigForType(type);
7509-
var updatePayload = addProperties(null, newProps, type.validAttributes);
7476+
var updatePayload = diffProperties(
7477+
null,
7478+
emptyObject$1,
7479+
newProps,
7480+
type.validAttributes
7481+
);
75107482
ReactNativePrivateInterface.UIManager.createView(
75117483
current,
75127484
type.uiViewClassName,
@@ -8918,8 +8890,9 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
89188890
try {
89198891
if (((newProps = root.stateNode), viewConfig)) {
89208892
var viewConfig$jscomp$0 = newProps.viewConfig;
8921-
var updatePayload$jscomp$0 = addProperties(
8893+
var updatePayload$jscomp$0 = diffProperties(
89228894
null,
8895+
emptyObject$1,
89238896
{ style: { display: "none" } },
89248897
viewConfig$jscomp$0.validAttributes
89258898
);
@@ -11514,7 +11487,7 @@ var roots = new Map(),
1151411487
devToolsConfig$jscomp$inline_1272 = {
1151511488
findFiberByHostInstance: getInstanceFromTag,
1151611489
bundleType: 0,
11517-
version: "19.0.0-beta-350ccbc3",
11490+
version: "19.0.0-beta-fa7474ba",
1151811491
rendererPackageName: "react-native-renderer",
1151911492
rendererConfig: {
1152011493
getInspectorDataForInstance: getInspectorDataForInstance,
@@ -11570,7 +11543,7 @@ var roots = new Map(),
1157011543
scheduleRoot: null,
1157111544
setRefreshHandler: null,
1157211545
getCurrentFiber: null,
11573-
reconcilerVersion: "19.0.0-beta-350ccbc3"
11546+
reconcilerVersion: "19.0.0-beta-fa7474ba"
1157411547
});
1157511548
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
1157611549
computeComponentStackForErrorReporting: function (reactTag) {

0 commit comments

Comments
 (0)