react-native-reanimated 3.17.1 → 3.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +27 -0
- package/Common/cpp/reanimated/Fabric/PropsRegistry.h +9 -0
- package/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +11 -6
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +48 -46
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +10 -4
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +31 -0
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +10 -0
- package/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +8 -0
- package/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +1 -3
- package/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +1 -1
- package/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +1 -5
- package/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +25 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +14 -2
- package/android/src/fabric/java/com/swmansion/reanimated/ReaCompatibility.java +0 -5
- package/android/src/main/cpp/reanimated/android/NativeProxy.cpp +2 -23
- package/android/src/main/cpp/reanimated/android/NativeProxy.h +0 -6
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +0 -4
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +0 -6
- package/android/src/main/java/com/swmansion/worklets/WorkletsModule.java +16 -5
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +14 -2
- package/android/src/paper/java/com/swmansion/reanimated/ReaCompatibility.java +0 -3
- package/apple/reanimated/apple/REAModule.mm +15 -0
- package/apple/reanimated/apple/REANodesManager.h +0 -1
- package/apple/reanimated/apple/REANodesManager.mm +1 -20
- package/apple/reanimated/apple/native/PlatformDepMethodsHolderImpl.h +0 -3
- package/apple/reanimated/apple/native/PlatformDepMethodsHolderImpl.mm +1 -20
- package/lib/module/Colors.js +5 -1
- package/lib/module/Colors.js.map +1 -1
- package/lib/module/Easing.js.map +1 -1
- package/lib/module/ReanimatedModule/NativeReanimated.js +46 -2
- package/lib/module/ReanimatedModule/NativeReanimated.js.map +1 -1
- package/lib/module/ReanimatedModule/js-reanimated/JSReanimated.js +6 -0
- package/lib/module/ReanimatedModule/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/UpdateProps.js +3 -3
- package/lib/module/UpdateProps.js.map +1 -1
- package/lib/module/animation/styleAnimation.js +9 -3
- package/lib/module/animation/styleAnimation.js.map +1 -1
- package/lib/module/animation/util.js +31 -10
- package/lib/module/animation/util.js.map +1 -1
- package/lib/module/commonTypes.js.map +1 -1
- package/lib/module/component/FlatList.js +8 -17
- package/lib/module/component/FlatList.js.map +1 -1
- package/lib/module/component/LayoutAnimationConfig.js +6 -10
- package/lib/module/component/LayoutAnimationConfig.js.map +1 -1
- package/lib/module/component/PerformanceMonitor.js +10 -21
- package/lib/module/component/PerformanceMonitor.js.map +1 -1
- package/lib/module/component/ScrollView.js +1 -4
- package/lib/module/component/ScrollView.js.map +1 -1
- package/lib/module/core.js +6 -0
- package/lib/module/core.js.map +1 -1
- package/lib/module/createAnimatedComponent/PropsFilter.js +3 -2
- package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +47 -24
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/hook/useAnimatedStyle.js +7 -7
- package/lib/module/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/jestUtils.js +40 -20
- package/lib/module/jestUtils.js.map +1 -1
- package/lib/module/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/platform-specific/findHostInstance.js +1 -1
- package/lib/module/platform-specific/findHostInstance.js.map +1 -1
- package/lib/module/platform-specific/jsVersion.js +1 -1
- package/lib/module/processBoxShadow.js +1 -0
- package/lib/module/processBoxShadow.js.map +1 -1
- package/lib/module/reactUtils.js +1 -1
- package/lib/module/reactUtils.js.map +1 -1
- package/lib/typescript/Colors.d.ts.map +1 -1
- package/lib/typescript/Easing.d.ts +1 -3
- package/lib/typescript/Easing.d.ts.map +1 -1
- package/lib/typescript/ReanimatedModule/NativeReanimated.d.ts.map +1 -1
- package/lib/typescript/ReanimatedModule/js-reanimated/JSReanimated.d.ts.map +1 -1
- package/lib/typescript/ReanimatedModule/reanimatedModuleProxy.d.ts +2 -0
- package/lib/typescript/ReanimatedModule/reanimatedModuleProxy.d.ts.map +1 -1
- package/lib/typescript/UpdateProps.d.ts +1 -1
- package/lib/typescript/UpdateProps.d.ts.map +1 -1
- package/lib/typescript/animation/styleAnimation.d.ts.map +1 -1
- package/lib/typescript/animation/util.d.ts +3 -1
- package/lib/typescript/animation/util.d.ts.map +1 -1
- package/lib/typescript/commonTypes.d.ts +3 -2
- package/lib/typescript/commonTypes.d.ts.map +1 -1
- package/lib/typescript/core.d.ts +3 -1
- package/lib/typescript/core.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/PropsFilter.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/commonTypes.d.ts +6 -2
- package/lib/typescript/createAnimatedComponent/commonTypes.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/createAnimatedComponent.d.ts.map +1 -1
- package/lib/typescript/hook/commonTypes.d.ts +4 -3
- package/lib/typescript/hook/commonTypes.d.ts.map +1 -1
- package/lib/typescript/hook/useAnimatedStyle.d.ts.map +1 -1
- package/lib/typescript/jestUtils.d.ts +1 -0
- package/lib/typescript/jestUtils.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +4 -3
- package/lib/typescript/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/animationBuilder/Keyframe.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +13 -12
- package/lib/typescript/layoutReanimation/defaultTransitions/CurvedTransition.d.ts.map +1 -1
- package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/processBoxShadow.d.ts.map +1 -1
- package/package.json +3 -3
- package/plugin/index.js +2 -2
- package/src/Colors.ts +5 -1
- package/src/Easing.ts +1 -1
- package/src/ReanimatedModule/NativeReanimated.ts +56 -2
- package/src/ReanimatedModule/js-reanimated/JSReanimated.ts +13 -0
- package/src/ReanimatedModule/reanimatedModuleProxy.ts +3 -0
- package/src/UpdateProps.ts +3 -3
- package/src/animation/styleAnimation.ts +18 -7
- package/src/animation/util.ts +37 -9
- package/src/commonTypes.ts +3 -2
- package/src/core.ts +9 -0
- package/src/createAnimatedComponent/PropsFilter.tsx +3 -3
- package/src/createAnimatedComponent/commonTypes.ts +4 -2
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +58 -21
- package/src/hook/commonTypes.ts +6 -3
- package/src/hook/useAnimatedStyle.ts +27 -10
- package/src/jestUtils.ts +75 -26
- package/src/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -3
- package/src/layoutReanimation/animationBuilder/Keyframe.ts +3 -2
- package/src/layoutReanimation/defaultTransitions/CurvedTransition.ts +27 -12
- package/src/platform-specific/findHostInstance.ts +1 -1
- package/src/platform-specific/jsVersion.ts +1 -1
- package/src/privateGlobals.d.ts +1 -1
- package/src/processBoxShadow.ts +1 -0
- package/lib/module/PropsRegistry.js +0 -25
- package/lib/module/PropsRegistry.js.map +0 -1
- package/lib/typescript/PropsRegistry.d.ts +0 -2
- package/lib/typescript/PropsRegistry.d.ts.map +0 -1
- package/src/PropsRegistry.ts +0 -26
|
@@ -32,6 +32,33 @@ void PropsRegistry::for_each(std::function<void(
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
void PropsRegistry::markNodeAsRemovable(const ShadowNode::Shared &shadowNode) {
|
|
36
|
+
removableShadowNodes_[shadowNode->getTag()] = shadowNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void PropsRegistry::unmarkNodeAsRemovable(Tag viewTag) {
|
|
40
|
+
removableShadowNodes_.erase(viewTag);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void PropsRegistry::handleNodeRemovals(const RootShadowNode &rootShadowNode) {
|
|
44
|
+
for (auto it = removableShadowNodes_.begin();
|
|
45
|
+
it != removableShadowNodes_.end();) {
|
|
46
|
+
const auto &shadowNode = it->second;
|
|
47
|
+
const auto &family = shadowNode->getFamily();
|
|
48
|
+
const auto &ancestors = family.getAncestors(rootShadowNode);
|
|
49
|
+
|
|
50
|
+
// Skip if the node hasn't been removed
|
|
51
|
+
if (!ancestors.empty()) {
|
|
52
|
+
++it;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const auto tag = shadowNode->getTag();
|
|
57
|
+
map_.erase(tag);
|
|
58
|
+
it = removableShadowNodes_.erase(it);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
35
62
|
void PropsRegistry::remove(const Tag tag) {
|
|
36
63
|
map_.erase(tag);
|
|
37
64
|
}
|
|
@@ -45,8 +45,17 @@ class PropsRegistry {
|
|
|
45
45
|
return shouldCommitAfterPause_.exchange(false);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
bool isEmpty() {
|
|
49
|
+
return map_.empty();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void markNodeAsRemovable(const ShadowNode::Shared &shadowNode);
|
|
53
|
+
void unmarkNodeAsRemovable(Tag viewTag);
|
|
54
|
+
void handleNodeRemovals(const RootShadowNode &rootShadowNode);
|
|
55
|
+
|
|
48
56
|
private:
|
|
49
57
|
std::unordered_map<Tag, std::pair<ShadowNode::Shared, folly::dynamic>> map_;
|
|
58
|
+
std::unordered_map<Tag, ShadowNode::Shared> removableShadowNodes_;
|
|
50
59
|
|
|
51
60
|
mutable std::mutex mutex_; // Protects `map_`.
|
|
52
61
|
|
|
@@ -17,7 +17,7 @@ ReanimatedMountHook::~ReanimatedMountHook() noexcept {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
void ReanimatedMountHook::shadowTreeDidMount(
|
|
20
|
-
RootShadowNode::Shared
|
|
20
|
+
const RootShadowNode::Shared &rootShadowNode,
|
|
21
21
|
double) noexcept {
|
|
22
22
|
auto reaShadowNode =
|
|
23
23
|
std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
|
|
@@ -32,11 +32,16 @@ void ReanimatedMountHook::shadowTreeDidMount(
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
{
|
|
36
|
+
auto lock = propsRegistry_->createLock();
|
|
37
|
+
propsRegistry_->handleNodeRemovals(*rootShadowNode);
|
|
38
|
+
|
|
39
|
+
// When commit from React Native has finished, we reset the skip commit flag
|
|
40
|
+
// in order to allow Reanimated to commit its tree
|
|
41
|
+
propsRegistry_->unpauseReanimatedCommits();
|
|
42
|
+
if (!propsRegistry_->shouldCommitAfterPause()) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
const auto &shadowTreeRegistry = uiManager_->getShadowTreeRegistry();
|
|
@@ -64,8 +64,6 @@ ReanimatedModuleProxy::ReanimatedModuleProxy(
|
|
|
64
64
|
layoutAnimationsManager_(
|
|
65
65
|
std::make_shared<LayoutAnimationsManager>(jsLogger_)),
|
|
66
66
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
67
|
-
synchronouslyUpdateUIPropsFunction_(
|
|
68
|
-
platformDepMethodsHolder.synchronouslyUpdateUIPropsFunction),
|
|
69
67
|
propsRegistry_(std::make_shared<PropsRegistry>()),
|
|
70
68
|
#else
|
|
71
69
|
obtainPropFunction_(platformDepMethodsHolder.obtainPropFunction),
|
|
@@ -205,7 +203,6 @@ void ReanimatedModuleProxy::init(
|
|
|
205
203
|
UIRuntimeDecorator::decorate(
|
|
206
204
|
uiRuntime,
|
|
207
205
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
208
|
-
removeFromPropsRegistry,
|
|
209
206
|
obtainProp,
|
|
210
207
|
updateProps,
|
|
211
208
|
measure,
|
|
@@ -489,7 +486,6 @@ jsi::Value ReanimatedModuleProxy::configureProps(
|
|
|
489
486
|
auto nativePropsArray = nativeProps.asObject(rt).asArray(rt);
|
|
490
487
|
for (size_t i = 0; i < nativePropsArray.size(rt); ++i) {
|
|
491
488
|
auto name = nativePropsArray.getValueAtIndex(rt, i).asString(rt).utf8(rt);
|
|
492
|
-
nativePropNames_.insert(name);
|
|
493
489
|
animatablePropNames_.insert(name);
|
|
494
490
|
}
|
|
495
491
|
#else
|
|
@@ -600,20 +596,18 @@ void ReanimatedModuleProxy::cleanupSensors() {
|
|
|
600
596
|
}
|
|
601
597
|
|
|
602
598
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
603
|
-
|
|
599
|
+
|
|
600
|
+
void ReanimatedModuleProxy::markNodeAsRemovable(
|
|
604
601
|
jsi::Runtime &rt,
|
|
605
|
-
const jsi::
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
return false;
|
|
602
|
+
const jsi::Value &shadowNodeWrapper) {
|
|
603
|
+
auto shadowNode = shadowNodeFromValue(rt, shadowNodeWrapper);
|
|
604
|
+
propsRegistry_->markNodeAsRemovable(shadowNode);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
void ReanimatedModuleProxy::unmarkNodeAsRemovable(
|
|
608
|
+
jsi::Runtime &rt,
|
|
609
|
+
const jsi::Value &viewTag) {
|
|
610
|
+
propsRegistry_->unmarkNodeAsRemovable(viewTag.asNumber());
|
|
617
611
|
}
|
|
618
612
|
|
|
619
613
|
jsi::Value ReanimatedModuleProxy::filterNonAnimatableProps(
|
|
@@ -760,25 +754,6 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
760
754
|
jsPropsUpdater.call(rt, viewTag, nonAnimatableProps);
|
|
761
755
|
}
|
|
762
756
|
|
|
763
|
-
bool hasLayoutUpdates = false;
|
|
764
|
-
|
|
765
|
-
for (const auto &[shadowNode, props] : copiedOperationsQueue) {
|
|
766
|
-
if (isThereAnyLayoutProp(rt, props->asObject(rt))) {
|
|
767
|
-
hasLayoutUpdates = true;
|
|
768
|
-
break;
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
if (!hasLayoutUpdates) {
|
|
773
|
-
// If there's no layout props to be updated, we can apply the updates
|
|
774
|
-
// directly onto the components and skip the commit.
|
|
775
|
-
for (const auto &[shadowNode, props] : copiedOperationsQueue) {
|
|
776
|
-
Tag tag = shadowNode->getTag();
|
|
777
|
-
synchronouslyUpdateUIPropsFunction_(rt, tag, props->asObject(rt));
|
|
778
|
-
}
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
757
|
if (propsRegistry_->shouldReanimatedSkipCommit()) {
|
|
783
758
|
// It may happen that `performOperations` is called on the UI thread
|
|
784
759
|
// while React Native tries to commit a new tree on the JS thread.
|
|
@@ -829,15 +804,6 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
829
804
|
}
|
|
830
805
|
}
|
|
831
806
|
|
|
832
|
-
void ReanimatedModuleProxy::removeFromPropsRegistry(
|
|
833
|
-
jsi::Runtime &rt,
|
|
834
|
-
const jsi::Value &viewTags) {
|
|
835
|
-
auto array = viewTags.asObject(rt).asArray(rt);
|
|
836
|
-
for (size_t i = 0, size = array.size(rt); i < size; ++i) {
|
|
837
|
-
tagsToRemove_.push_back(array.getValueAtIndex(rt, i).asNumber());
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
|
|
841
807
|
void ReanimatedModuleProxy::dispatchCommand(
|
|
842
808
|
jsi::Runtime &rt,
|
|
843
809
|
const jsi::Value &shadowNodeValue,
|
|
@@ -846,7 +812,19 @@ void ReanimatedModuleProxy::dispatchCommand(
|
|
|
846
812
|
ShadowNode::Shared shadowNode = shadowNodeFromValue(rt, shadowNodeValue);
|
|
847
813
|
std::string commandName = stringFromValue(rt, commandNameValue);
|
|
848
814
|
folly::dynamic args = commandArgsFromValue(rt, argsValue);
|
|
849
|
-
uiManager_->
|
|
815
|
+
const auto &scheduler = static_cast<Scheduler *>(uiManager_->getDelegate());
|
|
816
|
+
|
|
817
|
+
if (!scheduler) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
const auto &schedulerDelegate = scheduler->getDelegate();
|
|
822
|
+
|
|
823
|
+
if (schedulerDelegate) {
|
|
824
|
+
const auto shadowView = ShadowView(*shadowNode);
|
|
825
|
+
schedulerDelegate->schedulerDidDispatchCommand(
|
|
826
|
+
shadowView, commandName, args);
|
|
827
|
+
}
|
|
850
828
|
}
|
|
851
829
|
|
|
852
830
|
jsi::String ReanimatedModuleProxy::obtainProp(
|
|
@@ -936,6 +914,30 @@ void ReanimatedModuleProxy::initializeLayoutAnimationsProxy() {
|
|
|
936
914
|
}
|
|
937
915
|
}
|
|
938
916
|
|
|
917
|
+
#ifdef IS_REANIMATED_EXAMPLE_APP
|
|
918
|
+
|
|
919
|
+
std::string format(bool b) {
|
|
920
|
+
return b ? "✅" : "❌";
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
std::function<std::string()>
|
|
924
|
+
ReanimatedModuleProxy::createRegistriesLeakCheck() {
|
|
925
|
+
return [weakThis = weak_from_this()]() {
|
|
926
|
+
auto strongThis = weakThis.lock();
|
|
927
|
+
if (!strongThis) {
|
|
928
|
+
return std::string("");
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
std::string result = "";
|
|
932
|
+
|
|
933
|
+
result += "PropsRegistry: " + format(strongThis->propsRegistry_->isEmpty());
|
|
934
|
+
|
|
935
|
+
return result;
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
#endif // IS_REANIMATED_EXAMPLE_APP
|
|
940
|
+
|
|
939
941
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
940
942
|
|
|
941
943
|
jsi::Value ReanimatedModuleProxy::subscribeForKeyboardEvents(
|
|
@@ -124,6 +124,12 @@ class ReanimatedModuleProxy
|
|
|
124
124
|
|
|
125
125
|
void performOperations();
|
|
126
126
|
|
|
127
|
+
void markNodeAsRemovable(
|
|
128
|
+
jsi::Runtime &rt,
|
|
129
|
+
const jsi::Value &shadowNodeWrapper) override;
|
|
130
|
+
void unmarkNodeAsRemovable(jsi::Runtime &rt, const jsi::Value &viewTag)
|
|
131
|
+
override;
|
|
132
|
+
|
|
127
133
|
void dispatchCommand(
|
|
128
134
|
jsi::Runtime &rt,
|
|
129
135
|
const jsi::Value &shadowNodeValue,
|
|
@@ -145,6 +151,10 @@ class ReanimatedModuleProxy
|
|
|
145
151
|
jsi::Runtime &rt,
|
|
146
152
|
const std::string &propName,
|
|
147
153
|
const ShadowNode::Shared &shadowNode);
|
|
154
|
+
|
|
155
|
+
#ifdef IS_REANIMATED_EXAMPLE_APP
|
|
156
|
+
std::function<std::string()> createRegistriesLeakCheck();
|
|
157
|
+
#endif // IS_REANIMATED_EXAMPLE_APP
|
|
148
158
|
#endif
|
|
149
159
|
|
|
150
160
|
jsi::Value registerSensor(
|
|
@@ -191,7 +201,6 @@ class ReanimatedModuleProxy
|
|
|
191
201
|
void requestAnimationFrame(jsi::Runtime &rt, const jsi::Value &callback);
|
|
192
202
|
|
|
193
203
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
194
|
-
bool isThereAnyLayoutProp(jsi::Runtime &rt, const jsi::Object &props);
|
|
195
204
|
jsi::Value filterNonAnimatableProps(
|
|
196
205
|
jsi::Runtime &rt,
|
|
197
206
|
const jsi::Value &props);
|
|
@@ -213,9 +222,6 @@ class ReanimatedModuleProxy
|
|
|
213
222
|
std::shared_ptr<LayoutAnimationsManager> layoutAnimationsManager_;
|
|
214
223
|
|
|
215
224
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
216
|
-
const SynchronouslyUpdateUIPropsFunction synchronouslyUpdateUIPropsFunction_;
|
|
217
|
-
|
|
218
|
-
std::unordered_set<std::string> nativePropNames_; // filled by configureProps
|
|
219
225
|
std::unordered_set<std::string>
|
|
220
226
|
animatablePropNames_; // filled by configureProps
|
|
221
227
|
std::shared_ptr<UIManager> uiManager_;
|
|
@@ -160,6 +160,30 @@ static jsi::Value REANIMATED_SPEC_PREFIX(setShouldAnimateExiting)(
|
|
|
160
160
|
return jsi::Value::undefined();
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
164
|
+
|
|
165
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(markNodeAsRemovable)(
|
|
166
|
+
jsi::Runtime &rt,
|
|
167
|
+
TurboModule &turboModule,
|
|
168
|
+
const jsi::Value *args,
|
|
169
|
+
size_t) {
|
|
170
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
171
|
+
->markNodeAsRemovable(rt, std::move(args[0]));
|
|
172
|
+
return jsi::Value::undefined();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static jsi::Value REANIMATED_SPEC_PREFIX(unmarkNodeAsRemovable)(
|
|
176
|
+
jsi::Runtime &rt,
|
|
177
|
+
TurboModule &turboModule,
|
|
178
|
+
const jsi::Value *args,
|
|
179
|
+
size_t) {
|
|
180
|
+
static_cast<ReanimatedModuleProxySpec *>(&turboModule)
|
|
181
|
+
->unmarkNodeAsRemovable(rt, std::move(args[0]));
|
|
182
|
+
return jsi::Value::undefined();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
186
|
+
|
|
163
187
|
ReanimatedModuleProxySpec::ReanimatedModuleProxySpec(
|
|
164
188
|
const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
165
189
|
: TurboModule("NativeReanimated", jsInvoker) {
|
|
@@ -196,5 +220,12 @@ ReanimatedModuleProxySpec::ReanimatedModuleProxySpec(
|
|
|
196
220
|
MethodMetadata{1, REANIMATED_SPEC_PREFIX(configureLayoutAnimationBatch)};
|
|
197
221
|
methodMap_["setShouldAnimateExitingForTag"] =
|
|
198
222
|
MethodMetadata{2, REANIMATED_SPEC_PREFIX(setShouldAnimateExiting)};
|
|
223
|
+
|
|
224
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
225
|
+
methodMap_["markNodeAsRemovable"] =
|
|
226
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(markNodeAsRemovable)};
|
|
227
|
+
methodMap_["unmarkNodeAsRemovable"] =
|
|
228
|
+
MethodMetadata{1, REANIMATED_SPEC_PREFIX(unmarkNodeAsRemovable)};
|
|
229
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
199
230
|
}
|
|
200
231
|
} // namespace reanimated
|
|
@@ -94,6 +94,16 @@ class JSI_EXPORT ReanimatedModuleProxySpec : public TurboModule {
|
|
|
94
94
|
jsi::Runtime &rt,
|
|
95
95
|
const jsi::Value &viewTag,
|
|
96
96
|
const jsi::Value &shouldAnimate) = 0;
|
|
97
|
+
|
|
98
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
99
|
+
// Cleanup
|
|
100
|
+
virtual void markNodeAsRemovable(
|
|
101
|
+
jsi::Runtime &rt,
|
|
102
|
+
const jsi::Value &shadowNodeWrapper) = 0;
|
|
103
|
+
virtual void unmarkNodeAsRemovable(
|
|
104
|
+
jsi::Runtime &rt,
|
|
105
|
+
const jsi::Value &viewTag) = 0;
|
|
106
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
97
107
|
};
|
|
98
108
|
|
|
99
109
|
} // namespace reanimated
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include <reanimated/RuntimeDecorators/RNRuntimeDecorator.h>
|
|
2
|
+
#include <worklets/Tools/ReanimatedJSIUtils.h>
|
|
2
3
|
#include <worklets/Tools/ReanimatedVersion.h>
|
|
3
4
|
|
|
4
5
|
namespace reanimated {
|
|
@@ -32,6 +33,13 @@ void RNRuntimeDecorator::decorate(
|
|
|
32
33
|
#ifndef NDEBUG
|
|
33
34
|
checkJSVersion(rnRuntime, reanimatedModuleProxy->getJSLogger());
|
|
34
35
|
#endif // NDEBUG
|
|
36
|
+
|
|
37
|
+
#if defined(IS_REANIMATED_EXAMPLE_APP) && defined(RCT_NEW_ARCH_ENABLED)
|
|
38
|
+
jsi_utils::installJsiFunction(
|
|
39
|
+
rnRuntime,
|
|
40
|
+
"_registriesLeakCheck",
|
|
41
|
+
reanimatedModuleProxy->createRegistriesLeakCheck());
|
|
42
|
+
#endif // defined(IS_REANIMATED_EXAMPLE_APP) && defined(RCT_NEW_ARCH_ENABLED)
|
|
35
43
|
injectReanimatedCppVersion(rnRuntime);
|
|
36
44
|
|
|
37
45
|
rnRuntime.global().setProperty(
|
|
@@ -8,7 +8,7 @@ using namespace worklets;
|
|
|
8
8
|
void UIRuntimeDecorator::decorate(
|
|
9
9
|
jsi::Runtime &uiRuntime,
|
|
10
10
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
|
-
|
|
11
|
+
// nothing
|
|
12
12
|
#else
|
|
13
13
|
const ScrollToFunction scrollTo,
|
|
14
14
|
#endif
|
|
@@ -26,8 +26,6 @@ void UIRuntimeDecorator::decorate(
|
|
|
26
26
|
|
|
27
27
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
28
28
|
jsi_utils::installJsiFunction(uiRuntime, "_updatePropsFabric", updateProps);
|
|
29
|
-
jsi_utils::installJsiFunction(
|
|
30
|
-
uiRuntime, "_removeFromPropsRegistry", removeFromPropsRegistry);
|
|
31
29
|
jsi_utils::installJsiFunction(
|
|
32
30
|
uiRuntime, "_dispatchCommandFabric", dispatchCommand);
|
|
33
31
|
jsi_utils::installJsiFunction(uiRuntime, "_measureFabric", measure);
|
|
@@ -20,12 +20,8 @@ namespace reanimated {
|
|
|
20
20
|
|
|
21
21
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
22
22
|
|
|
23
|
-
using SynchronouslyUpdateUIPropsFunction =
|
|
24
|
-
std::function<void(jsi::Runtime &rt, Tag tag, const jsi::Object &props)>;
|
|
25
23
|
using UpdatePropsFunction =
|
|
26
24
|
std::function<void(jsi::Runtime &rt, const jsi::Value &operations)>;
|
|
27
|
-
using RemoveFromPropsRegistryFunction =
|
|
28
|
-
std::function<void(jsi::Runtime &rt, const jsi::Value &viewTags)>;
|
|
29
25
|
using ObtainPropFunction = std::function<jsi::Value(
|
|
30
26
|
jsi::Runtime &rt,
|
|
31
27
|
const jsi::Value &shadowNodeWrapper,
|
|
@@ -79,7 +75,7 @@ using MaybeFlushUIUpdatesQueueFunction = std::function<void()>;
|
|
|
79
75
|
struct PlatformDepMethodsHolder {
|
|
80
76
|
RequestRenderFunction requestRender;
|
|
81
77
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
82
|
-
|
|
78
|
+
// nothing
|
|
83
79
|
#else
|
|
84
80
|
UpdatePropsFunction updatePropsFunction;
|
|
85
81
|
ScrollToFunction scrollToFunction;
|
|
@@ -108,6 +108,16 @@ inline jsi::Value apply(
|
|
|
108
108
|
return std::apply(function, std::move(args));
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
// calls string-returning `function` with `args`,
|
|
112
|
+
// and returns the string
|
|
113
|
+
template <typename... Args>
|
|
114
|
+
inline jsi::Value apply(
|
|
115
|
+
jsi::Runtime &rt,
|
|
116
|
+
std::function<std::string(Args...)> function,
|
|
117
|
+
std::tuple<Args...> args) {
|
|
118
|
+
return jsi::String::createFromUtf8(rt, std::apply(function, std::move(args)));
|
|
119
|
+
}
|
|
120
|
+
|
|
111
121
|
// calls void-returning `function` with `args`,
|
|
112
122
|
// and returns `undefined`
|
|
113
123
|
template <typename... Args>
|
|
@@ -132,6 +142,21 @@ jsi::HostFunctionType createHostFunction(Fun function) {
|
|
|
132
142
|
};
|
|
133
143
|
}
|
|
134
144
|
|
|
145
|
+
// returns a function with JSI calling convention
|
|
146
|
+
// from a native function `function` returning a string
|
|
147
|
+
template <typename... Args>
|
|
148
|
+
jsi::HostFunctionType createHostFunction(
|
|
149
|
+
std::function<std::string(Args...)> function) {
|
|
150
|
+
return [function](
|
|
151
|
+
jsi::Runtime &rt,
|
|
152
|
+
const jsi::Value &,
|
|
153
|
+
const jsi::Value *args,
|
|
154
|
+
const size_t count) {
|
|
155
|
+
auto argz = getArgsForFunction(function, rt, args, count);
|
|
156
|
+
return apply(rt, function, std::move(argz));
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
135
160
|
// used to determine if `function<Ret(Args...)>`
|
|
136
161
|
// takes `Runtime &` as its first argument
|
|
137
162
|
template <typename... Args>
|
|
@@ -16,6 +16,7 @@ import com.swmansion.worklets.JSCallInvokerResolver;
|
|
|
16
16
|
import com.swmansion.worklets.WorkletsModule;
|
|
17
17
|
import java.util.HashMap;
|
|
18
18
|
import java.util.Objects;
|
|
19
|
+
import java.util.concurrent.atomic.AtomicBoolean;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* @noinspection JavaJniMissingFunction
|
|
@@ -25,6 +26,12 @@ public class NativeProxy extends NativeProxyCommon {
|
|
|
25
26
|
@SuppressWarnings("unused")
|
|
26
27
|
private final HybridData mHybridData;
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Invalidating concurrently could be fatal. It shouldn't happen in a normal flow, but it doesn't
|
|
31
|
+
* cost us much to add synchronization for extra safety.
|
|
32
|
+
*/
|
|
33
|
+
private final AtomicBoolean mInvalidated = new AtomicBoolean(false);
|
|
34
|
+
|
|
28
35
|
public @OptIn(markerClass = FrameworkAPI.class) NativeProxy(
|
|
29
36
|
ReactApplicationContext context, WorkletsModule workletsModule) {
|
|
30
37
|
super(context);
|
|
@@ -72,8 +79,13 @@ public class NativeProxy extends NativeProxyCommon {
|
|
|
72
79
|
|
|
73
80
|
private native void invalidateCpp();
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
protected void invalidate() {
|
|
83
|
+
if (mInvalidated.getAndSet(true)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (mHybridData != null && mHybridData.isValid()) {
|
|
87
|
+
invalidateCpp();
|
|
88
|
+
}
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
public static NativeMethodsHolder createNativeMethodsHolder(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.swmansion.reanimated;
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
5
4
|
import com.facebook.react.fabric.FabricUIManager;
|
|
6
5
|
import com.facebook.react.uimanager.UIManagerHelper;
|
|
7
6
|
import com.facebook.react.uimanager.common.UIManagerType;
|
|
@@ -26,8 +25,4 @@ class ReaCompatibility {
|
|
|
26
25
|
fabricUIManager.getEventDispatcher().removeListener(nodesManager);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
public void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
|
|
31
|
-
fabricUIManager.synchronouslyUpdateViewOnUIThread(viewTag, uiProps);
|
|
32
|
-
}
|
|
33
28
|
}
|
|
@@ -318,26 +318,6 @@ std::vector<std::pair<std::string, double>> NativeProxy::measure(int viewTag) {
|
|
|
318
318
|
}
|
|
319
319
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
320
320
|
|
|
321
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
322
|
-
inline jni::local_ref<ReadableMap::javaobject> castReadableMap(
|
|
323
|
-
jni::local_ref<ReadableNativeMap::javaobject> const &nativeMap) {
|
|
324
|
-
return make_local(reinterpret_cast<ReadableMap::javaobject>(nativeMap.get()));
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
void NativeProxy::synchronouslyUpdateUIProps(
|
|
328
|
-
jsi::Runtime &rt,
|
|
329
|
-
Tag tag,
|
|
330
|
-
const jsi::Object &props) {
|
|
331
|
-
static const auto method =
|
|
332
|
-
getJniMethod<void(int, jni::local_ref<ReadableMap::javaobject>)>(
|
|
333
|
-
"synchronouslyUpdateUIProps");
|
|
334
|
-
jni::local_ref<ReadableMap::javaobject> uiProps =
|
|
335
|
-
castReadableMap(ReadableNativeMap::newObjectCxxArgs(
|
|
336
|
-
jsi::dynamicFromValue(rt, jsi::Value(rt, props))));
|
|
337
|
-
method(javaPart_.get(), tag, uiProps);
|
|
338
|
-
}
|
|
339
|
-
#endif
|
|
340
|
-
|
|
341
321
|
int NativeProxy::registerSensor(
|
|
342
322
|
int sensorType,
|
|
343
323
|
int interval,
|
|
@@ -456,8 +436,7 @@ PlatformDepMethodsHolder NativeProxy::getPlatformDependentMethods() {
|
|
|
456
436
|
auto requestRender = bindThis(&NativeProxy::requestRender);
|
|
457
437
|
|
|
458
438
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
459
|
-
|
|
460
|
-
bindThis(&NativeProxy::synchronouslyUpdateUIProps);
|
|
439
|
+
// nothing
|
|
461
440
|
#else
|
|
462
441
|
auto configurePropsFunction = bindThis(&NativeProxy::configureProps);
|
|
463
442
|
#endif
|
|
@@ -491,7 +470,7 @@ PlatformDepMethodsHolder NativeProxy::getPlatformDependentMethods() {
|
|
|
491
470
|
return {
|
|
492
471
|
requestRender,
|
|
493
472
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
494
|
-
|
|
473
|
+
// nothing
|
|
495
474
|
#else
|
|
496
475
|
updatePropsFunction,
|
|
497
476
|
scrollToFunction,
|
|
@@ -181,12 +181,6 @@ class NativeProxy : public jni::HybridClass<NativeProxy>,
|
|
|
181
181
|
// std::shared_ptr<EventListener> eventListener_;
|
|
182
182
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
183
183
|
void installJSIBindings();
|
|
184
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
185
|
-
void synchronouslyUpdateUIProps(
|
|
186
|
-
jsi::Runtime &rt,
|
|
187
|
-
Tag viewTag,
|
|
188
|
-
const jsi::Object &props);
|
|
189
|
-
#endif
|
|
190
184
|
PlatformDepMethodsHolder getPlatformDependentMethods();
|
|
191
185
|
void setupLayoutAnimations();
|
|
192
186
|
|
|
@@ -440,10 +440,6 @@ public class NodesManager implements EventDispatcherListener {
|
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
public void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
|
|
444
|
-
compatibility.synchronouslyUpdateUIProps(viewTag, uiProps);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
443
|
public String obtainProp(int viewTag, String propName) {
|
|
448
444
|
View view;
|
|
449
445
|
try {
|
|
@@ -9,7 +9,6 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
|
|
9
9
|
import com.facebook.react.bridge.NativeModule;
|
|
10
10
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
11
|
import com.facebook.react.bridge.ReadableArray;
|
|
12
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
13
12
|
import com.facebook.react.bridge.ReadableNativeArray;
|
|
14
13
|
import com.facebook.soloader.SoLoader;
|
|
15
14
|
import com.swmansion.common.GestureHandlerStateManager;
|
|
@@ -129,11 +128,6 @@ public abstract class NativeProxyCommon {
|
|
|
129
128
|
mNodesManager.updateProps(viewTag, props);
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
@DoNotStrip
|
|
133
|
-
public void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
|
|
134
|
-
mNodesManager.synchronouslyUpdateUIProps(viewTag, uiProps);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
131
|
@DoNotStrip
|
|
138
132
|
public String obtainProp(int viewTag, String propName) {
|
|
139
133
|
return mNodesManager.obtainProp(viewTag, propName);
|
|
@@ -12,6 +12,7 @@ import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
|
|
|
12
12
|
import com.facebook.soloader.SoLoader;
|
|
13
13
|
import com.swmansion.reanimated.NativeWorkletsModuleSpec;
|
|
14
14
|
import java.util.Objects;
|
|
15
|
+
import java.util.concurrent.atomic.AtomicBoolean;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* @noinspection JavaJniMissingFunction
|
|
@@ -38,6 +39,12 @@ public class WorkletsModule extends NativeWorkletsModuleSpec {
|
|
|
38
39
|
return mAndroidUIScheduler;
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Invalidating concurrently could be fatal. It shouldn't happen in a normal flow, but it doesn't
|
|
44
|
+
* cost us much to add synchronization for extra safety.
|
|
45
|
+
*/
|
|
46
|
+
private final AtomicBoolean mInvalidated = new AtomicBoolean(false);
|
|
47
|
+
|
|
41
48
|
@OptIn(markerClass = FrameworkAPI.class)
|
|
42
49
|
private native HybridData initHybrid(
|
|
43
50
|
long jsContext,
|
|
@@ -69,11 +76,15 @@ public class WorkletsModule extends NativeWorkletsModuleSpec {
|
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
public void invalidate() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
if (mInvalidated.getAndSet(true)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (mHybridData != null && mHybridData.isValid()) {
|
|
83
|
+
// We have to destroy extra runtimes when invalidate is called. If we clean
|
|
84
|
+
// it up later instead there's a chance the runtime will retain references
|
|
85
|
+
// to invalidated memory and will crash on its destruction.
|
|
86
|
+
invalidateCpp();
|
|
87
|
+
}
|
|
77
88
|
mAndroidUIScheduler.deactivate();
|
|
78
89
|
}
|
|
79
90
|
|
|
@@ -16,6 +16,7 @@ import com.swmansion.worklets.WorkletsModule;
|
|
|
16
16
|
import java.lang.ref.WeakReference;
|
|
17
17
|
import java.util.HashMap;
|
|
18
18
|
import java.util.Objects;
|
|
19
|
+
import java.util.concurrent.atomic.AtomicBoolean;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* @noinspection JavaJniMissingFunction
|
|
@@ -25,6 +26,12 @@ public class NativeProxy extends NativeProxyCommon {
|
|
|
25
26
|
@SuppressWarnings("unused")
|
|
26
27
|
private final HybridData mHybridData;
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Invalidating concurrently could be fatal. It shouldn't happen in a normal flow, but it doesn't
|
|
31
|
+
* cost us much to add synchronization for extra safety.
|
|
32
|
+
*/
|
|
33
|
+
private final AtomicBoolean mInvalidated = new AtomicBoolean(false);
|
|
34
|
+
|
|
28
35
|
@OptIn(markerClass = FrameworkAPI.class)
|
|
29
36
|
public NativeProxy(ReactApplicationContext context, WorkletsModule workletsModule) {
|
|
30
37
|
super(context);
|
|
@@ -63,8 +70,13 @@ public class NativeProxy extends NativeProxyCommon {
|
|
|
63
70
|
|
|
64
71
|
private native void invalidateCpp();
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
protected void invalidate() {
|
|
74
|
+
if (mInvalidated.getAndSet(true)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (mHybridData != null && mHybridData.isValid()) {
|
|
78
|
+
invalidateCpp();
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
public static NativeMethodsHolder createNativeMethodsHolder(LayoutAnimations layoutAnimations) {
|