Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3384d89
add new feature flag for raw jsi values for props
hannojg Dec 2, 2024
4f1b4e7
wip: first version no std variant
hannojg Dec 2, 2024
fd57139
use std::variant
hannojg Dec 2, 2024
65ad0a1
add new feature flag for raw jsi values for props
hannojg Dec 2, 2024
db983f2
fix problems with JSI RawValue
hannojg Dec 2, 2024
5c70b52
RawPropsParser eventually use RawValue from jsi directly based on fea…
hannojg Dec 2, 2024
25c2b4b
fix: undefined values are not expected to be in the map
hannojg Dec 3, 2024
95e996a
constructors are expected to be public
hannojg Dec 3, 2024
94b6575
revert making internal constructors public by moving
hannojg Dec 3, 2024
5ab3b8e
fix android builds
hannojg Dec 3, 2024
032674a
Update packages/react-native/ReactCommon/react/renderer/core/RawValue.h
hannojg Dec 3, 2024
627ce7f
Update packages/react-native/ReactCommon/react/renderer/core/RawValue.h
hannojg Dec 3, 2024
0b4d071
Update packages/react-native/ReactCommon/react/renderer/core/RawValue.h
hannojg Dec 3, 2024
aa3519a
rename JsiPair -> JsiValuePair
hannojg Dec 3, 2024
79507ed
add API to access raw JSI value
hannojg Dec 3, 2024
c6e84cb
fix cast to `JsiValuePair` method
hannojg Dec 3, 2024
490f85e
perf: use emplace + move
hannojg Dec 3, 2024
72b7265
explicit types
hannojg Dec 3, 2024
a05fa9d
cleanup: use as and get jsi values correctly
hannojg Dec 3, 2024
f078147
use explicit types
hannojg Dec 3, 2024
3dc5736
change asX calls to getX as we asserted earlier
hannojg Dec 3, 2024
a2fa883
remove noexcept as std::get and isNull() can throw
hannojg Dec 3, 2024
f7ea9a3
remove untrue doc comment
hannojg Dec 3, 2024
5c7f09d
make runtime first arg, jsiValue second
hannojg Dec 3, 2024
7a2aaf2
fix release build add empty return value
hannojg Dec 3, 2024
70a54ee
add assert statement
hannojg Dec 5, 2024
7b9f817
Merge branch 'main' of github.com:facebook/react-native into feat/jsi…
hannojg Dec 5, 2024
7926707
Update feature flags after merge
hannojg Dec 5, 2024
d3a332f
update changelog
hannojg Dec 5, 2024
a82f082
Revert "update changelog"
hannojg Dec 5, 2024
6203871
prettier
hannojg Dec 5, 2024
078f356
fix missing JSI symbols in react-graphics
hannojg Dec 5, 2024
62ddcc6
rename to getJsiValuePair
hannojg Dec 5, 2024
0a18d3e
fix: casting to JsiValuePair return a const ref (no copy)
hannojg Dec 5, 2024
6160d31
make sure to move jsi::Value
hannojg Dec 5, 2024
d2417fa
add flag to use raw jsi props
hannojg Dec 5, 2024
ea6688c
make the raw prop parser instantiatable
hannojg Dec 5, 2024
f015546
open RawPropsParser so we can pass alternative implementations
hannojg Dec 5, 2024
cc10632
forgot one move
hannojg Dec 5, 2024
2a4084a
use a pointer for RawPropsParser to support inheritance
hannojg Dec 5, 2024
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 @@ -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<<4a219bb47b1b9d988a164bca19eb4fa9>>
* @generated SignedSource<<7ff4983cb507b99b315b38a614b4fd35>>
*/

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

/**
* Instead of using folly::dynamic as internal representation in RawProps and RawValue, use jsi::Value
*/
@JvmStatic
public fun useRawPropsJsiValue(): Boolean = accessor.useRawPropsJsiValue()

/**
* When enabled, cloning shadow nodes within react native will update the reference held by the current JS fiber tree.
*/
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<<d75efd6beee8dd9d38b5d648fbecbcda>>
* @generated SignedSource<<fca0f1509e5cb47c509e44eeb115a2b9>>
*/

/**
Expand Down Expand Up @@ -64,6 +64,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
private var useOptimisedViewPreallocationOnAndroidCache: Boolean? = null
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
private var useRawPropsJsiValueCache: Boolean? = null
private var useRuntimeShadowNodeReferenceUpdateCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
Expand Down Expand Up @@ -464,6 +465,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

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

override fun useRuntimeShadowNodeReferenceUpdate(): Boolean {
var cached = useRuntimeShadowNodeReferenceUpdateCache
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<<7454ab19a01cfbb0a54f14bd83fc3a90>>
* @generated SignedSource<<4245d2bac6698a5810027490dfaba9cf>>
*/

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

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

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

@DoNotStrip @JvmStatic public external fun useRuntimeShadowNodeReferenceUpdate(): 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<<70d951b2956759280afae4af8f9a2869>>
* @generated SignedSource<<7a5878708fca8e54a0e6c0a4605a58de>>
*/

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

override fun useOptimizedEventBatchingOnAndroid(): Boolean = false

override fun useRawPropsJsiValue(): Boolean = false

override fun useRuntimeShadowNodeReferenceUpdate(): 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<<f60000cb58a9632c3aa193854be3de4e>>
* @generated SignedSource<<0633da2ec3c73f002a0f404a697436f2>>
*/

/**
Expand Down Expand Up @@ -68,6 +68,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
private var useOptimisedViewPreallocationOnAndroidCache: Boolean? = null
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
private var useRawPropsJsiValueCache: Boolean? = null
private var useRuntimeShadowNodeReferenceUpdateCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
Expand Down Expand Up @@ -512,6 +513,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun useRuntimeShadowNodeReferenceUpdate(): Boolean {
var cached = useRuntimeShadowNodeReferenceUpdateCache
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<<d62af893c5d18a2152f098ff305ae41e>>
* @generated SignedSource<<145aa050506193198208ec7601b7da10>>
*/

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

@DoNotStrip public fun useOptimizedEventBatchingOnAndroid(): Boolean

@DoNotStrip public fun useRawPropsJsiValue(): Boolean

@DoNotStrip public fun useRuntimeShadowNodeReferenceUpdate(): 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<<640630d7a40b53f7d507569aa6409f69>>
* @generated SignedSource<<405a3f9a4f596eefb76672b63d18ee4e>>
*/

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

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

bool useRuntimeShadowNodeReferenceUpdate() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useRuntimeShadowNodeReferenceUpdate");
Expand Down Expand Up @@ -545,6 +551,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useOptimizedEventBatchingOnAndroid(
return ReactNativeFeatureFlags::useOptimizedEventBatchingOnAndroid();
}

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

bool JReactNativeFeatureFlagsCxxInterop::useRuntimeShadowNodeReferenceUpdate(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdate();
Expand Down Expand Up @@ -723,6 +734,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"useOptimizedEventBatchingOnAndroid",
JReactNativeFeatureFlagsCxxInterop::useOptimizedEventBatchingOnAndroid),
makeNativeMethod(
"useRawPropsJsiValue",
JReactNativeFeatureFlagsCxxInterop::useRawPropsJsiValue),
makeNativeMethod(
"useRuntimeShadowNodeReferenceUpdate",
JReactNativeFeatureFlagsCxxInterop::useRuntimeShadowNodeReferenceUpdate),
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<<4218168e779a2241d0752771c1f51b12>>
* @generated SignedSource<<491bac04ac8f7326311be2dd04d2eac7>>
*/

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

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

static bool useRuntimeShadowNodeReferenceUpdate(
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<<2409869111055ff0b32c1f40c10042d7>>
* @generated SignedSource<<5feade33af25b7633ab16a68983b0dd7>>
*/

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

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

bool ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdate() {
return getAccessor().useRuntimeShadowNodeReferenceUpdate();
}
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<<e628af8109a1d8bb6425515d824852a3>>
* @generated SignedSource<<1787c33b11b94ad1d1584bee70d2fe27>>
*/

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

/**
* Instead of using folly::dynamic as internal representation in RawProps and RawValue, use jsi::Value
*/
RN_EXPORT static bool useRawPropsJsiValue();

/**
* When enabled, cloning shadow nodes within react native will update the reference held by the current JS fiber tree.
*/
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<<1e5b87b564e880cfb1423a85692092ba>>
* @generated SignedSource<<095951bcdce4c10476c7213948470af7>>
*/

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

bool ReactNativeFeatureFlagsAccessor::useRawPropsJsiValue() {
auto flagValue = useRawPropsJsiValue_.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(44, "useRawPropsJsiValue");

flagValue = currentProvider_->useRawPropsJsiValue();
useRawPropsJsiValue_ = flagValue;
}

return flagValue.value();
}

bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdate() {
auto flagValue = useRuntimeShadowNodeReferenceUpdate_.load();

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

markFlagAsAccessed(44, "useRuntimeShadowNodeReferenceUpdate");
markFlagAsAccessed(45, "useRuntimeShadowNodeReferenceUpdate");

flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate();
useRuntimeShadowNodeReferenceUpdate_ = flagValue;
Expand All @@ -848,7 +866,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(45, "useTurboModuleInterop");
markFlagAsAccessed(46, "useTurboModuleInterop");

flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
Expand All @@ -866,7 +884,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(46, "useTurboModules");
markFlagAsAccessed(47, "useTurboModules");

flagValue = currentProvider_->useTurboModules();
useTurboModules_ = flagValue;
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<<eb44aabe7e352481267aa9a6bf035ff1>>
* @generated SignedSource<<7bd6e40098cb00e2313e9803726ecd64>>
*/

/**
Expand Down Expand Up @@ -76,6 +76,7 @@ class ReactNativeFeatureFlagsAccessor {
bool useNativeViewConfigsInBridgelessMode();
bool useOptimisedViewPreallocationOnAndroid();
bool useOptimizedEventBatchingOnAndroid();
bool useRawPropsJsiValue();
bool useRuntimeShadowNodeReferenceUpdate();
bool useTurboModuleInterop();
bool useTurboModules();
Expand All @@ -90,7 +91,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;

std::array<std::atomic<const char*>, 47> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 48> accessedFeatureFlags_;

std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> completeReactInstanceCreationOnBgThreadOnAndroid_;
Expand Down Expand Up @@ -136,6 +137,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> useNativeViewConfigsInBridgelessMode_;
std::atomic<std::optional<bool>> useOptimisedViewPreallocationOnAndroid_;
std::atomic<std::optional<bool>> useOptimizedEventBatchingOnAndroid_;
std::atomic<std::optional<bool>> useRawPropsJsiValue_;
std::atomic<std::optional<bool>> useRuntimeShadowNodeReferenceUpdate_;
std::atomic<std::optional<bool>> useTurboModuleInterop_;
std::atomic<std::optional<bool>> useTurboModules_;
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<<ee899be30798eb6d386b44bc6bc027ea>>
* @generated SignedSource<<ed01263f6d35571caa544479693e0de9>>
*/

/**
Expand Down Expand Up @@ -203,6 +203,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}

bool useRawPropsJsiValue() override {
return false;
}

bool useRuntimeShadowNodeReferenceUpdate() override {
return 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<<e5d1c60102f7444332bd34627c02eddd>>
* @generated SignedSource<<7f68dc4ffaea04ee5576da6a5ee009df>>
*/

/**
Expand Down Expand Up @@ -69,6 +69,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool useNativeViewConfigsInBridgelessMode() = 0;
virtual bool useOptimisedViewPreallocationOnAndroid() = 0;
virtual bool useOptimizedEventBatchingOnAndroid() = 0;
virtual bool useRawPropsJsiValue() = 0;
virtual bool useRuntimeShadowNodeReferenceUpdate() = 0;
virtual bool useTurboModuleInterop() = 0;
virtual bool useTurboModules() = 0;
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<<4055a9b5e34ff6740a99d4e08853fe7d>>
* @generated SignedSource<<c0b7e6cfe17915c38cb3346845cdaf7d>>
*/

/**
Expand Down Expand Up @@ -264,6 +264,11 @@ bool NativeReactNativeFeatureFlags::useOptimizedEventBatchingOnAndroid(
return ReactNativeFeatureFlags::useOptimizedEventBatchingOnAndroid();
}

bool NativeReactNativeFeatureFlags::useRawPropsJsiValue(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::useRawPropsJsiValue();
}

bool NativeReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdate(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdate();
Expand Down
Loading
Loading