Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,31 @@ import {View} from 'react-native';
let root;
let testViews: React.MixedElement;

function createDeepViewHierarchy(depth: number, breadth: number): React.Node {
if (depth === 0) {
return (
<View
collapsable={false}
style={{width: 10, height: 10}}
nativeID="leaf"
/>
);
}
const children = [];
for (let i = 0; i < breadth; i++) {
children.push(
<View
key={i}
collapsable={false}
nativeID={`d${depth.toString()}-${i.toString()}`}
style={{width: depth + 1, height: depth + 1}}>
{createDeepViewHierarchy(depth - 1, breadth)}
</View>,
);
}
return <View collapsable={false}>{children}</View>;
}

function createViewsWithLargeAmountOfPropsAndStyles(count: number): React.Node {
let views: React.Node = null;
for (let i = 0; i < count; i++) {
Expand Down Expand Up @@ -124,4 +149,28 @@ Fantom.unstable_benchmark
root.destroy();
},
}),
)
.test.each(
[
[5, 4],
[7, 3],
[10, 2],
],
([depth, breadth]) =>
`render deep view hierarchy (depth=${depth.toString()}, breadth=${breadth.toString()})`,
() => {
Fantom.runTask(() => root.render(testViews));
},
([depth, breadth]) => ({
beforeAll: () => {
// $FlowExpectedError[incompatible-type]
testViews = createDeepViewHierarchy(depth, breadth);
},
beforeEach: () => {
root = Fantom.createRoot();
},
afterEach: () => {
root.destroy();
},
}),
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<477777b9a795b57f3bb3eaeb030738a9>>
* @generated SignedSource<<4e5ae706df013f43dd19f98cf905a138>>
*/

/**
Expand Down Expand Up @@ -498,6 +498,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun useSharedAnimatedBackend(): Boolean = accessor.useSharedAnimatedBackend()

/**
* Use std::unordered_map instead of TinyMap in the Differentiator for improved lookup performance.
*/
@JvmStatic
public fun useUnorderedMapInDifferentiator(): Boolean = accessor.useUnorderedMapInDifferentiator()

/**
* Use Trait::hidden on Android
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c7b6ea7f1672df7bb3396375378784c5>>
* @generated SignedSource<<6d7e2160c022ae4630f8d3a4b263621f>>
*/

/**
Expand Down Expand Up @@ -98,6 +98,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
private var useNestedScrollViewAndroidCache: Boolean? = null
private var useSharedAnimatedBackendCache: Boolean? = null
private var useUnorderedMapInDifferentiatorCache: Boolean? = null
private var useTraitHiddenOnAndroidCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
Expand Down Expand Up @@ -807,6 +808,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun useUnorderedMapInDifferentiator(): Boolean {
var cached = useUnorderedMapInDifferentiatorCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.useUnorderedMapInDifferentiator()
useUnorderedMapInDifferentiatorCache = cached
}
return cached
}

override fun useTraitHiddenOnAndroid(): Boolean {
var cached = useTraitHiddenOnAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ec036cff49622b8c2b52d2f9eaa59e6c>>
* @generated SignedSource<<be5acfe89b6f852a5910eec7dae4e888>>
*/

/**
Expand Down Expand Up @@ -184,6 +184,8 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun useSharedAnimatedBackend(): Boolean

@DoNotStrip @JvmStatic public external fun useUnorderedMapInDifferentiator(): Boolean

@DoNotStrip @JvmStatic public external fun useTraitHiddenOnAndroid(): Boolean

@DoNotStrip @JvmStatic public external fun useTurboModuleInterop(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<523e3c35d4bd1fc85f2a3bb26b8aad3f>>
* @generated SignedSource<<fa4bdf78bba37dbc514735cc3618efee>>
*/

/**
Expand Down Expand Up @@ -179,6 +179,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun useSharedAnimatedBackend(): Boolean = false

override fun useUnorderedMapInDifferentiator(): Boolean = false

override fun useTraitHiddenOnAndroid(): Boolean = false

override fun useTurboModuleInterop(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<cfd6a4514be320519a57566182b73f69>>
* @generated SignedSource<<c53d8309f47b1fd7845953a5b64c955f>>
*/

/**
Expand Down Expand Up @@ -102,6 +102,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
private var useNestedScrollViewAndroidCache: Boolean? = null
private var useSharedAnimatedBackendCache: Boolean? = null
private var useUnorderedMapInDifferentiatorCache: Boolean? = null
private var useTraitHiddenOnAndroidCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
Expand Down Expand Up @@ -889,6 +890,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}

override fun useUnorderedMapInDifferentiator(): Boolean {
var cached = useUnorderedMapInDifferentiatorCache
if (cached == null) {
cached = currentProvider.useUnorderedMapInDifferentiator()
accessedFeatureFlags.add("useUnorderedMapInDifferentiator")
useUnorderedMapInDifferentiatorCache = cached
}
return cached
}

override fun useTraitHiddenOnAndroid(): Boolean {
var cached = useTraitHiddenOnAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bbaa4d1498f606886341d34a62acb508>>
* @generated SignedSource<<07b19c2cdde81032b3181a658e528b18>>
*/

/**
Expand Down Expand Up @@ -179,6 +179,8 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun useSharedAnimatedBackend(): Boolean

@DoNotStrip public fun useUnorderedMapInDifferentiator(): Boolean

@DoNotStrip public fun useTraitHiddenOnAndroid(): Boolean

@DoNotStrip public fun useTurboModuleInterop(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<45063df01d7ce8726b4a7d901f1b3341>>
* @generated SignedSource<<fda512b00459c5aaffae8738e74afe15>>
*/

/**
Expand Down Expand Up @@ -507,6 +507,12 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}

bool useUnorderedMapInDifferentiator() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useUnorderedMapInDifferentiator");
return method(javaProvider_);
}

bool useTraitHiddenOnAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useTraitHiddenOnAndroid");
Expand Down Expand Up @@ -937,6 +943,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useSharedAnimatedBackend(
return ReactNativeFeatureFlags::useSharedAnimatedBackend();
}

bool JReactNativeFeatureFlagsCxxInterop::useUnorderedMapInDifferentiator(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useUnorderedMapInDifferentiator();
}

bool JReactNativeFeatureFlagsCxxInterop::useTraitHiddenOnAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useTraitHiddenOnAndroid();
Expand Down Expand Up @@ -1232,6 +1243,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"useSharedAnimatedBackend",
JReactNativeFeatureFlagsCxxInterop::useSharedAnimatedBackend),
makeNativeMethod(
"useUnorderedMapInDifferentiator",
JReactNativeFeatureFlagsCxxInterop::useUnorderedMapInDifferentiator),
makeNativeMethod(
"useTraitHiddenOnAndroid",
JReactNativeFeatureFlagsCxxInterop::useTraitHiddenOnAndroid),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<5ac93ed057017f8d1a388b8029614f18>>
* @generated SignedSource<<519ec7b20ed2b4feaf10d1448c68c255>>
*/

/**
Expand Down Expand Up @@ -264,6 +264,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool useSharedAnimatedBackend(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool useUnorderedMapInDifferentiator(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool useTraitHiddenOnAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9d81f74c5926706ee353813e594575e8>>
* @generated SignedSource<<168ae9f867afd3e316d3ba4925ffa07e>>
*/

/**
Expand Down Expand Up @@ -338,6 +338,10 @@ bool ReactNativeFeatureFlags::useSharedAnimatedBackend() {
return getAccessor().useSharedAnimatedBackend();
}

bool ReactNativeFeatureFlags::useUnorderedMapInDifferentiator() {
return getAccessor().useUnorderedMapInDifferentiator();
}

bool ReactNativeFeatureFlags::useTraitHiddenOnAndroid() {
return getAccessor().useTraitHiddenOnAndroid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<84e2800073ffab2313a4e27897c0c246>>
* @generated SignedSource<<88bd716e389c2929f48a4e400170f7fa>>
*/

/**
Expand Down Expand Up @@ -429,6 +429,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool useSharedAnimatedBackend();

/**
* Use std::unordered_map instead of TinyMap in the Differentiator for improved lookup performance.
*/
RN_EXPORT static bool useUnorderedMapInDifferentiator();

/**
* Use Trait::hidden on Android
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<8f9f3ced66040f8275073e5084765356>>
* @generated SignedSource<<5c22b9b03b250ee9b535182780651784>>
*/

/**
Expand Down Expand Up @@ -1433,6 +1433,24 @@ bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() {
return flagValue.value();
}

bool ReactNativeFeatureFlagsAccessor::useUnorderedMapInDifferentiator() {
auto flagValue = useUnorderedMapInDifferentiator_.load();

if (!flagValue.has_value()) {
// This block is not exclusive but it is not necessary.
// If multiple threads try to initialize the feature flag, we would only
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(78, "useUnorderedMapInDifferentiator");

flagValue = currentProvider_->useUnorderedMapInDifferentiator();
useUnorderedMapInDifferentiator_ = flagValue;
}

return flagValue.value();
}

bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() {
auto flagValue = useTraitHiddenOnAndroid_.load();

Expand All @@ -1442,7 +1460,7 @@ bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(78, "useTraitHiddenOnAndroid");
markFlagAsAccessed(79, "useTraitHiddenOnAndroid");

flagValue = currentProvider_->useTraitHiddenOnAndroid();
useTraitHiddenOnAndroid_ = flagValue;
Expand All @@ -1460,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(79, "useTurboModuleInterop");
markFlagAsAccessed(80, "useTurboModuleInterop");

flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
Expand All @@ -1478,7 +1496,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModules() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(80, "useTurboModules");
markFlagAsAccessed(81, "useTurboModules");

flagValue = currentProvider_->useTurboModules();
useTurboModules_ = flagValue;
Expand All @@ -1496,7 +1514,7 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(81, "viewCullingOutsetRatio");
markFlagAsAccessed(82, "viewCullingOutsetRatio");

flagValue = currentProvider_->viewCullingOutsetRatio();
viewCullingOutsetRatio_ = flagValue;
Expand All @@ -1514,7 +1532,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(82, "viewTransitionEnabled");
markFlagAsAccessed(83, "viewTransitionEnabled");

flagValue = currentProvider_->viewTransitionEnabled();
viewTransitionEnabled_ = flagValue;
Expand All @@ -1532,7 +1550,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.

markFlagAsAccessed(83, "virtualViewPrerenderRatio");
markFlagAsAccessed(84, "virtualViewPrerenderRatio");

flagValue = currentProvider_->virtualViewPrerenderRatio();
virtualViewPrerenderRatio_ = flagValue;
Expand Down
Loading
Loading