react-native-reanimated 4.7.0 → 4.7.2
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/CSS/common/values/CSSNumber.cpp +5 -9
- package/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +2 -6
- package/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +34 -2
- package/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +15 -1
- package/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +9 -0
- package/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +3 -0
- package/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +135 -33
- package/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +37 -3
- package/Common/cpp/reanimated/Fabric/updates/SynchronousWritesTracker.cpp +103 -0
- package/Common/cpp/reanimated/Fabric/updates/SynchronousWritesTracker.h +74 -0
- package/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +43 -0
- package/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +13 -0
- package/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +14 -1
- package/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +3 -0
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +318 -134
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +27 -6
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +32 -17
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +17 -1
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +14 -13
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +5 -2
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +57 -9
- package/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.h +2 -2
- package/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +11 -11
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +114 -11
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +12 -2
- package/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +17 -1
- package/Common/cpp/reanimated/Tools/TextMetrics.h +22 -0
- package/android/src/main/cpp/reanimated/android/NativeProxy.cpp +32 -3
- package/android/src/main/cpp/reanimated/android/NativeProxy.h +3 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.kt +108 -9
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.kt +2 -4
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.kt +4 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.kt +1 -1
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.kt +44 -33
- package/apple/reanimated/apple/REAReducedMotion.h +1 -3
- package/apple/reanimated/apple/REASynchronousPropsRewriter.h +18 -0
- package/apple/reanimated/apple/REASynchronousPropsRewriter.mm +37 -0
- package/apple/reanimated/apple/ReanimatedModule.mm +7 -0
- package/apple/reanimated/apple/keyboardObserver/REAKeyboardEventObserver.mm +20 -3
- package/apple/reanimated/apple/native/PlatformDepMethodsHolderImpl.mm +52 -1
- package/jest/resolver.js +4 -1
- package/lib/module/PropsRegistryGarbageCollector.js +43 -25
- package/lib/module/PropsRegistryGarbageCollector.js.map +1 -1
- package/lib/module/ReanimatedModule/NativeReanimated.js +2 -2
- package/lib/module/ReanimatedModule/NativeReanimated.js.map +1 -1
- package/lib/module/animation/timing.js +15 -2
- package/lib/module/animation/timing.js.map +1 -1
- package/lib/module/commonTypes.js.map +1 -1
- package/lib/module/createAnimatedComponent/AnimatedComponent.js +1 -1
- package/lib/module/createAnimatedComponent/AnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/AnimatedComponent.native.js +10 -34
- package/lib/module/createAnimatedComponent/AnimatedComponent.native.js.map +1 -1
- package/lib/module/platform-specific/jsVersion.js +1 -1
- package/lib/module/platformFunctions/setNativeProps.native.js +2 -1
- package/lib/module/platformFunctions/setNativeProps.native.js.map +1 -1
- package/lib/module/updateProps/updateProps.native.js +5 -4
- package/lib/module/updateProps/updateProps.native.js.map +1 -1
- package/lib/typescript/PropsRegistryGarbageCollector.d.ts +2 -2
- package/lib/typescript/PropsRegistryGarbageCollector.d.ts.map +1 -1
- package/lib/typescript/ReanimatedModule/reanimatedModuleProxy.d.ts +1 -1
- package/lib/typescript/ReanimatedModule/reanimatedModuleProxy.d.ts.map +1 -1
- package/lib/typescript/animation/timing.d.ts.map +1 -1
- package/lib/typescript/commonTypes.d.ts +3 -1
- package/lib/typescript/commonTypes.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/AnimatedComponent.d.ts +1 -1
- package/lib/typescript/createAnimatedComponent/AnimatedComponent.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/AnimatedComponent.native.d.ts +1 -1
- package/lib/typescript/createAnimatedComponent/AnimatedComponent.native.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/commonTypes.d.ts +1 -1
- package/lib/typescript/createAnimatedComponent/commonTypes.d.ts.map +1 -1
- package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/updateProps/updateProps.native.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/PropsRegistryGarbageCollector.ts +46 -25
- package/src/ReanimatedModule/NativeReanimated.ts +2 -2
- package/src/ReanimatedModule/reanimatedModuleProxy.ts +1 -1
- package/src/animation/timing.ts +20 -2
- package/src/commonTypes.ts +3 -1
- package/src/createAnimatedComponent/AnimatedComponent.native.tsx +5 -30
- package/src/createAnimatedComponent/AnimatedComponent.tsx +1 -1
- package/src/createAnimatedComponent/commonTypes.ts +1 -1
- package/src/platform-specific/jsVersion.ts +1 -1
- package/src/platformFunctions/setNativeProps.native.ts +3 -1
- package/src/privateGlobals.d.ts +1 -0
- package/src/updateProps/updateProps.native.ts +10 -3
|
@@ -33,6 +33,7 @@ struct StartAnimationsRecursivelyConfig {
|
|
|
33
33
|
bool shouldRemoveSubviewsWithoutAnimations;
|
|
34
34
|
bool shouldAnimate;
|
|
35
35
|
bool isScreenPop;
|
|
36
|
+
bool defersTeardown;
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
struct PendingNodeAnimation {
|
|
@@ -87,12 +88,19 @@ struct TransactionMeta {
|
|
|
87
88
|
std::vector<std::shared_ptr<LightNode>> nodesToRestore;
|
|
88
89
|
std::vector<std::shared_ptr<LightNode>> containersToRemove;
|
|
89
90
|
std::unordered_map<Tag, Tag> staleSnapshots;
|
|
91
|
+
std::unordered_set<Tag> dueRemovals;
|
|
92
|
+
std::unordered_set<Tag> recreatedTags;
|
|
93
|
+
// Whatever changes a node's children or their exiting states during updateLightTree must reset its cursors.
|
|
94
|
+
std::unordered_map<Tag, IndexCursors> indexCursors;
|
|
90
95
|
};
|
|
91
96
|
|
|
92
97
|
struct LayoutAnimationsProxy : public LayoutAnimationsProxyCommon {
|
|
93
98
|
mutable std::optional<ProgressTransition> transition_;
|
|
94
99
|
mutable std::optional<UncommittedScreenPop> uncommittedScreenPop_;
|
|
95
100
|
mutable std::shared_ptr<LightNode> topScreen_;
|
|
101
|
+
// screens that forceScreenSnapshot_ switched to snapshots after updates; React Native Screens never switches them
|
|
102
|
+
// back
|
|
103
|
+
mutable std::unordered_set<Tag> snapshottedScreens_;
|
|
96
104
|
mutable std::unordered_map<Tag, SharedContainer> sharedContainers_;
|
|
97
105
|
mutable std::unordered_set<Tag> hiddenViewTags_;
|
|
98
106
|
std::shared_ptr<SharedTransitionManager> sharedTransitionManager_;
|
|
@@ -101,6 +109,8 @@ struct LayoutAnimationsProxy : public LayoutAnimationsProxyCommon {
|
|
|
101
109
|
mutable bool surfaceToRemove_ = false;
|
|
102
110
|
#ifdef ANDROID
|
|
103
111
|
mutable bool cleanupPullScheduled_ = false;
|
|
112
|
+
// tags of JS-thread batches that are not in the mount queue yet
|
|
113
|
+
mutable std::unordered_map<Tag, int> unqueuedBatchTags_;
|
|
104
114
|
#endif
|
|
105
115
|
|
|
106
116
|
#ifdef __APPLE__
|
|
@@ -143,6 +153,7 @@ struct LayoutAnimationsProxy : public LayoutAnimationsProxyCommon {
|
|
|
143
153
|
|
|
144
154
|
std::optional<ShadowView>
|
|
145
155
|
reparentLayoutAnimation(Tag tag, Tag parentTag, const ShadowView &newView, react::Point offset) const;
|
|
156
|
+
const ShadowView &mountedView(const std::shared_ptr<LightNode> &node) const;
|
|
146
157
|
|
|
147
158
|
void applyInitialMutationsToLightTree(const ShadowViewMutationList &mutations) const;
|
|
148
159
|
void updateLightNodeProps(
|
|
@@ -157,8 +168,16 @@ struct LayoutAnimationsProxy : public LayoutAnimationsProxyCommon {
|
|
|
157
168
|
|
|
158
169
|
void applySynchronousProps(const UpdatesBatch &updatesBatch, bool trackInLightTree) const override;
|
|
159
170
|
|
|
160
|
-
void reconcileContradictedRemovals(
|
|
161
|
-
|
|
171
|
+
void reconcileContradictedRemovals(
|
|
172
|
+
ShadowViewMutationList &mutations,
|
|
173
|
+
TransactionMeta &transaction,
|
|
174
|
+
const PropsParserContext &propsParserContext) const;
|
|
175
|
+
#ifdef ANDROID
|
|
176
|
+
ShadowView resetPropsMissingFrom(
|
|
177
|
+
const ShadowView &view,
|
|
178
|
+
const ShadowView &mounted,
|
|
179
|
+
const PropsParserContext &propsParserContext) const;
|
|
180
|
+
#endif
|
|
162
181
|
|
|
163
182
|
void handleSharedTransitionsStart(
|
|
164
183
|
const std::shared_ptr<LightNode> &afterTopScreen,
|
|
@@ -176,6 +195,8 @@ struct LayoutAnimationsProxy : public LayoutAnimationsProxyCommon {
|
|
|
176
195
|
#ifdef ANDROID
|
|
177
196
|
bool hasPendingStructuralCleanup() const;
|
|
178
197
|
void maybeScheduleCleanupPull(bool flushedStructuralMutations) const;
|
|
198
|
+
void holdFramesUntilBatchIsQueued(const ShadowViewMutationList &mutations) const;
|
|
199
|
+
void releaseFramesOfQueuedBatch(const std::vector<Tag> &tags) const;
|
|
179
200
|
#endif
|
|
180
201
|
|
|
181
202
|
void hideTransitioningViews(
|
|
@@ -244,11 +265,12 @@ struct LayoutAnimationsProxy : public LayoutAnimationsProxyCommon {
|
|
|
244
265
|
void handleSubtreeRemoval(
|
|
245
266
|
const std::shared_ptr<LightNode> &node,
|
|
246
267
|
const std::shared_ptr<LightNode> &parent,
|
|
247
|
-
int hostIndex,
|
|
248
268
|
TransactionMeta &transaction) const;
|
|
249
|
-
|
|
269
|
+
bool holdsSnapshottedScreen(const std::shared_ptr<LightNode> &node) const;
|
|
270
|
+
void collectDueRemovals(TransactionMeta &transaction) const;
|
|
271
|
+
void tearDown(const std::unordered_set<Tag> &removals, ShadowViewMutationList &mutations) const;
|
|
250
272
|
|
|
251
|
-
void addOngoingAnimations(
|
|
273
|
+
void addOngoingAnimations(TransactionMeta &transaction) const;
|
|
252
274
|
ShadowView cloneViewWithoutOpacity(const ShadowView &shadowView, const PropsParserContext &propsParserContext) const;
|
|
253
275
|
|
|
254
276
|
bool startAnimationsRecursively(
|
|
@@ -257,7 +279,6 @@ struct LayoutAnimationsProxy : public LayoutAnimationsProxyCommon {
|
|
|
257
279
|
StartAnimationsRecursivelyConfig config) const;
|
|
258
280
|
void endAnimationsRecursively(const std::shared_ptr<LightNode> &node, int index, ShadowViewMutationList &mutations)
|
|
259
281
|
const;
|
|
260
|
-
void maybeDropAncestors(const std::shared_ptr<LightNode> &node, ShadowViewMutationList &cleanupMutations) const;
|
|
261
282
|
|
|
262
283
|
// MountingOverrideDelegate
|
|
263
284
|
|
|
@@ -80,12 +80,10 @@ std::optional<SurfaceId> LayoutAnimationsProxyCommon::progressLayoutAnimation(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
auto &layoutAnimation = layoutAnimationIt->second;
|
|
83
|
-
|
|
84
|
-
layoutAnimation.opacity.reset();
|
|
85
|
-
}
|
|
83
|
+
const bool animatesOpacity = newStyle.hasProperty(uiRuntime_, "opacity");
|
|
86
84
|
|
|
87
85
|
auto rawProps = std::make_shared<RawProps>(uiRuntime_, jsi::Value(uiRuntime_, newStyle));
|
|
88
|
-
if (layoutAnimation.opacity) {
|
|
86
|
+
if (layoutAnimation.opacity && !animatesOpacity) {
|
|
89
87
|
auto props = (folly::dynamic)*rawProps;
|
|
90
88
|
props["opacity"] = *layoutAnimation.opacity;
|
|
91
89
|
rawProps = std::make_shared<RawProps>(std::move(props));
|
|
@@ -97,7 +95,7 @@ std::optional<SurfaceId> LayoutAnimationsProxyCommon::progressLayoutAnimation(
|
|
|
97
95
|
#endif
|
|
98
96
|
auto newProps = componentDescriptorRegistry_->at(layoutAnimation.finalView.componentHandle)
|
|
99
97
|
.cloneProps(propsParserContext, layoutAnimation.finalView.props, std::move(*rawProps));
|
|
100
|
-
updateMap_.insert_or_assign(tag, UpdateValues{newProps, Frame(uiRuntime_, newStyle)});
|
|
98
|
+
updateMap_.insert_or_assign(tag, UpdateValues{newProps, Frame(uiRuntime_, newStyle), animatesOpacity});
|
|
101
99
|
|
|
102
100
|
return surfaceId_;
|
|
103
101
|
}
|
|
@@ -156,6 +154,25 @@ void LayoutAnimationsProxyCommon::flushLayoutAnimationOperations(std::unique_loc
|
|
|
156
154
|
flushLayoutAnimationOperationsLocked();
|
|
157
155
|
}
|
|
158
156
|
|
|
157
|
+
// iOS, and Android with accumulated raw props, write the props of an Insert to the view. The shadow props of a view
|
|
158
|
+
// that only moves lack the values that were written synchronously.
|
|
159
|
+
Props::Shared LayoutAnimationsProxyCommon::propsOfMountedView(const ShadowView &view) const {
|
|
160
|
+
#ifdef __APPLE__
|
|
161
|
+
if (readMountedViewProps_) {
|
|
162
|
+
if (auto mountedProps = readMountedViewProps_(view.tag)) {
|
|
163
|
+
return mountedProps;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
#elif defined(ANDROID)
|
|
167
|
+
if (readSynchronousProps_) {
|
|
168
|
+
if (const auto synchronousProps = readSynchronousProps_(view.tag); !synchronousProps.empty()) {
|
|
169
|
+
return mergeSynchronousProps(view, synchronousProps);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
#endif
|
|
173
|
+
return view.props;
|
|
174
|
+
}
|
|
175
|
+
|
|
159
176
|
Props::Shared LayoutAnimationsProxyCommon::mergeSynchronousProps(const ShadowView &view, const folly::dynamic &props)
|
|
160
177
|
const {
|
|
161
178
|
auto rawProps = props;
|
|
@@ -204,7 +221,7 @@ void LayoutAnimationsProxyCommon::applySynchronousPropsToLayoutAnimation(const T
|
|
|
204
221
|
start.after.props = mergeSynchronousProps(start.after, props);
|
|
205
222
|
if constexpr (std::is_same_v<Start, ManagedLayoutAnimationStart>) {
|
|
206
223
|
if (propsIncludeOpacity && start.opacity) {
|
|
207
|
-
start.opacity =
|
|
224
|
+
start.opacity = getViewProps(start.after).opacity;
|
|
208
225
|
}
|
|
209
226
|
}
|
|
210
227
|
}
|
|
@@ -226,7 +243,7 @@ void LayoutAnimationsProxyCommon::applySynchronousPropsToLayoutAnimation(const T
|
|
|
226
243
|
animation->finalView.props = mergeSynchronousProps(animation->finalView, props);
|
|
227
244
|
animation->currentView.props = mergeSynchronousProps(animation->currentView, props);
|
|
228
245
|
if (propsIncludeOpacity && animation->opacity) {
|
|
229
|
-
animation->opacity =
|
|
246
|
+
animation->opacity = getViewProps(animation->finalView).opacity;
|
|
230
247
|
}
|
|
231
248
|
if (const auto it = updateMap_.find(tag); it != updateMap_.end() && it->second.newProps) {
|
|
232
249
|
auto pendingView = animation->finalView;
|
|
@@ -245,13 +262,12 @@ ShadowView LayoutAnimationsProxyCommon::materializeLayoutAnimation(
|
|
|
245
262
|
const std::shared_ptr<Serializable> &config) const {
|
|
246
263
|
auto currentView = before;
|
|
247
264
|
const auto activeAnimationIt = layoutAnimations_.find(tag);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (!completedAnimationIt->second.shouldRemove) {
|
|
265
|
+
// An entering view starts from the view that the Insert mounted.
|
|
266
|
+
if (type != LayoutAnimationType::ENTERING) {
|
|
267
|
+
if (activeAnimationIt != layoutAnimations_.end()) {
|
|
268
|
+
currentView = activeAnimationIt->second.currentView;
|
|
269
|
+
} else if (const auto completedAnimationIt = completedAnimations_.find(tag);
|
|
270
|
+
completedAnimationIt != completedAnimations_.end() && !completedAnimationIt->second.shouldRemove) {
|
|
255
271
|
currentView = completedAnimationIt->second.animation.currentView;
|
|
256
272
|
}
|
|
257
273
|
}
|
|
@@ -506,7 +522,6 @@ std::shared_ptr<Serializable> LayoutAnimationsProxyCommon::getRetargetLayoutAnim
|
|
|
506
522
|
|
|
507
523
|
bool LayoutAnimationsProxyCommon::updateEnteringAnimationTarget(const Tag tag, const ShadowView &finalView) const {
|
|
508
524
|
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
509
|
-
const auto opacity = static_cast<const ViewProps &>(*finalView.props).opacity;
|
|
510
525
|
if (const auto pendingIt = pendingLayoutAnimations_.find(tag); pendingIt != pendingLayoutAnimations_.end()) {
|
|
511
526
|
if (pendingIt->second.type != LayoutAnimationType::ENTERING) {
|
|
512
527
|
return false;
|
|
@@ -515,7 +530,7 @@ bool LayoutAnimationsProxyCommon::updateEnteringAnimationTarget(const Tag tag, c
|
|
|
515
530
|
react_native_assert(operationIndex < layoutAnimationOperations_.size());
|
|
516
531
|
if (auto *start = std::get_if<ManagedLayoutAnimationStart>(&layoutAnimationOperations_[operationIndex])) {
|
|
517
532
|
start->after = finalView;
|
|
518
|
-
start->opacity = opacity;
|
|
533
|
+
start->opacity = getViewProps(finalView).opacity;
|
|
519
534
|
return true;
|
|
520
535
|
}
|
|
521
536
|
react_native_assert(false && "Pending managed layout animation not found");
|
|
@@ -524,7 +539,7 @@ bool LayoutAnimationsProxyCommon::updateEnteringAnimationTarget(const Tag tag, c
|
|
|
524
539
|
animationIt != layoutAnimations_.end() && animationIt->second.type == LayoutAnimationType::ENTERING) {
|
|
525
540
|
animationIt->second.finalView = finalView;
|
|
526
541
|
if (animationIt->second.opacity) {
|
|
527
|
-
animationIt->second.opacity = opacity;
|
|
542
|
+
animationIt->second.opacity = getViewProps(finalView).opacity;
|
|
528
543
|
}
|
|
529
544
|
return true;
|
|
530
545
|
}
|
|
@@ -63,6 +63,10 @@ struct LayoutAnimationCancellation {
|
|
|
63
63
|
using LayoutAnimationOperation =
|
|
64
64
|
std::variant<ManagedLayoutAnimationStart, ProgressLayoutAnimationStart, LayoutAnimationCancellation>;
|
|
65
65
|
|
|
66
|
+
#ifdef ANDROID
|
|
67
|
+
using SynchronousPropsReader = std::function<folly::dynamic(Tag tag)>;
|
|
68
|
+
#endif
|
|
69
|
+
|
|
66
70
|
struct LayoutAnimationsProxyDependencies {
|
|
67
71
|
std::shared_ptr<LayoutAnimationsManager> layoutAnimationsManager;
|
|
68
72
|
SharedComponentDescriptorRegistry componentDescriptorRegistry;
|
|
@@ -74,9 +78,11 @@ struct LayoutAnimationsProxyDependencies {
|
|
|
74
78
|
#ifdef ANDROID
|
|
75
79
|
PreserveMountedTagsFunction filterUnmountedTagsFunction;
|
|
76
80
|
std::shared_ptr<facebook::react::CallInvoker> jsInvoker;
|
|
81
|
+
SynchronousPropsReader readSynchronousProps;
|
|
77
82
|
#endif
|
|
78
83
|
#ifdef __APPLE__
|
|
79
84
|
ForceScreenSnapshotFunction forceScreenSnapshot;
|
|
85
|
+
ReadMountedViewPropsFunction readMountedViewProps;
|
|
80
86
|
#endif
|
|
81
87
|
};
|
|
82
88
|
|
|
@@ -95,7 +101,12 @@ class LayoutAnimationsProxyCommon : public facebook::react::MountingOverrideDele
|
|
|
95
101
|
#ifdef ANDROID
|
|
96
102
|
,
|
|
97
103
|
preserveMountedTags_(dependencies.filterUnmountedTagsFunction),
|
|
98
|
-
jsInvoker_(dependencies.jsInvoker)
|
|
104
|
+
jsInvoker_(dependencies.jsInvoker),
|
|
105
|
+
readSynchronousProps_(dependencies.readSynchronousProps)
|
|
106
|
+
#endif
|
|
107
|
+
#ifdef __APPLE__
|
|
108
|
+
,
|
|
109
|
+
readMountedViewProps_(dependencies.readMountedViewProps)
|
|
99
110
|
#endif
|
|
100
111
|
{
|
|
101
112
|
}
|
|
@@ -115,6 +126,7 @@ class LayoutAnimationsProxyCommon : public facebook::react::MountingOverrideDele
|
|
|
115
126
|
void flushLayoutAnimationOperations() const;
|
|
116
127
|
|
|
117
128
|
protected:
|
|
129
|
+
Props::Shared propsOfMountedView(const ShadowView &view) const;
|
|
118
130
|
Props::Shared mergeSynchronousProps(const ShadowView &view, const folly::dynamic &props) const;
|
|
119
131
|
bool hasLayoutAnimationRecords() const;
|
|
120
132
|
void applySynchronousPropsToLayoutAnimation(Tag tag, const folly::dynamic &props) const;
|
|
@@ -169,6 +181,10 @@ class LayoutAnimationsProxyCommon : public facebook::react::MountingOverrideDele
|
|
|
169
181
|
#ifdef ANDROID
|
|
170
182
|
PreserveMountedTagsFunction preserveMountedTags_;
|
|
171
183
|
std::shared_ptr<facebook::react::CallInvoker> jsInvoker_;
|
|
184
|
+
SynchronousPropsReader readSynchronousProps_;
|
|
185
|
+
#endif
|
|
186
|
+
#ifdef __APPLE__
|
|
187
|
+
ReadMountedViewPropsFunction readMountedViewProps_;
|
|
172
188
|
#endif
|
|
173
189
|
|
|
174
190
|
private:
|
|
@@ -134,12 +134,12 @@ void LayoutAnimationsProxy_Legacy::reconcileContradictedRemovals(
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
137
|
+
// With Android's push model, structural mutations from the JS thread may still be waiting to mount when a UI-thread
|
|
138
|
+
// pull runs, so dead nodes must be cleaned up on the JS thread. The pull model mounts transactions on the UI thread,
|
|
139
|
+
// where cleanup is safe. A dropped surface can also be cleaned up immediately.
|
|
140
140
|
bool LayoutAnimationsProxy_Legacy::shouldFlushDeadNodes([[maybe_unused]] const bool surfaceDropped) const {
|
|
141
141
|
#ifdef ANDROID
|
|
142
|
-
return surfaceDropped || !worklets::isOnUIThread(uiScheduler_);
|
|
142
|
+
return surfaceDropped || isMountingCoordinatorPullModelEnabled() || !worklets::isOnUIThread(uiScheduler_);
|
|
143
143
|
#else
|
|
144
144
|
return true;
|
|
145
145
|
#endif
|
|
@@ -356,18 +356,18 @@ void LayoutAnimationsProxy_Legacy::handleUpdatesAndEnterings(
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
transferConfigFromNativeID(mutation.newChildShadowView.props->nativeId, mutation.newChildShadowView.tag);
|
|
359
|
-
const auto enteringConfig =
|
|
360
|
-
layoutAnimationsManager_->getLayoutAnimationConfig(tag, LayoutAnimationType::ENTERING)
|
|
359
|
+
const auto enteringConfig = isViewKind(mutation.newChildShadowView)
|
|
360
|
+
? layoutAnimationsManager_->getLayoutAnimationConfig(tag, LayoutAnimationType::ENTERING)
|
|
361
|
+
: nullptr;
|
|
361
362
|
if (!enteringConfig) {
|
|
362
363
|
filteredMutations.push_back(mutation);
|
|
363
364
|
continue;
|
|
364
365
|
}
|
|
365
366
|
|
|
366
|
-
startEnteringAnimation(tag, mutation, enteringConfig);
|
|
367
|
-
filteredMutations.push_back(mutation);
|
|
368
|
-
|
|
369
367
|
// temporarily set opacity to 0 to prevent flickering on android
|
|
370
368
|
std::shared_ptr<ShadowView> newView = cloneViewWithoutOpacity(mutation, propsParserContext);
|
|
369
|
+
startEnteringAnimation(tag, mutation, *newView, enteringConfig);
|
|
370
|
+
filteredMutations.push_back(mutation);
|
|
371
371
|
|
|
372
372
|
filteredMutations.push_back(
|
|
373
373
|
ShadowViewMutation::UpdateMutation(mutation.newChildShadowView, *newView, parentTag));
|
|
@@ -470,7 +470,8 @@ void LayoutAnimationsProxy_Legacy::addOngoingAnimations(ShadowViewMutationList &
|
|
|
470
470
|
mutations.push_back(
|
|
471
471
|
ShadowViewMutation::UpdateMutation(layoutAnimation.currentView, newView, layoutAnimation.parentTag));
|
|
472
472
|
layoutAnimation.currentView = newView;
|
|
473
|
-
if (layoutAnimation.opacity &&
|
|
473
|
+
if (layoutAnimation.opacity &&
|
|
474
|
+
(updateValues.animatesOpacity || getViewProps(newView).opacity == *layoutAnimation.opacity)) {
|
|
474
475
|
layoutAnimation.opacity.reset();
|
|
475
476
|
}
|
|
476
477
|
}
|
|
@@ -649,18 +650,18 @@ bool LayoutAnimationsProxy_Legacy::shouldOverridePullTransaction() const {
|
|
|
649
650
|
void LayoutAnimationsProxy_Legacy::startEnteringAnimation(
|
|
650
651
|
const int tag,
|
|
651
652
|
ShadowViewMutation &mutation,
|
|
653
|
+
const ShadowView &hiddenView,
|
|
652
654
|
const std::shared_ptr<Serializable> &config) const {
|
|
653
655
|
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
654
656
|
LOG(INFO) << "start entering animation for tag " << tag << std::endl;
|
|
655
657
|
#endif
|
|
656
|
-
auto &viewProps = static_cast<const ViewProps &>(*mutation.newChildShadowView.props);
|
|
657
658
|
enqueueLayoutAnimation(ManagedLayoutAnimationStart{
|
|
658
659
|
.tag = tag,
|
|
659
660
|
.type = LayoutAnimationType::ENTERING,
|
|
660
|
-
.before =
|
|
661
|
+
.before = hiddenView,
|
|
661
662
|
.after = mutation.newChildShadowView,
|
|
662
663
|
.parentTag = mutation.parentTag,
|
|
663
|
-
.opacity =
|
|
664
|
+
.opacity = getViewProps(mutation.newChildShadowView).opacity,
|
|
664
665
|
.config = config,
|
|
665
666
|
});
|
|
666
667
|
}
|
|
@@ -111,8 +111,11 @@ struct LayoutAnimationsProxy_Legacy : public LayoutAnimationsProxyCommon {
|
|
|
111
111
|
LayoutAnimationsProxy_Legacy(const SurfaceId surfaceId, const LayoutAnimationsProxyDependencies &dependencies)
|
|
112
112
|
: LayoutAnimationsProxyCommon(surfaceId, dependencies) {}
|
|
113
113
|
|
|
114
|
-
void startEnteringAnimation(
|
|
115
|
-
const
|
|
114
|
+
void startEnteringAnimation(
|
|
115
|
+
const int tag,
|
|
116
|
+
ShadowViewMutation &mutation,
|
|
117
|
+
const ShadowView &hiddenView,
|
|
118
|
+
const std::shared_ptr<Serializable> &config) const;
|
|
116
119
|
void startExitingAnimation(const int tag, ShadowViewMutation &mutation, const std::shared_ptr<Serializable> &config)
|
|
117
120
|
const;
|
|
118
121
|
void startLayoutAnimation(
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <folly/dynamic.h>
|
|
4
4
|
#include <react/debug/react_native_assert.h>
|
|
5
5
|
#include <react/renderer/components/rnreanimated/Props.h>
|
|
6
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
6
7
|
#include <react/renderer/mounting/MountingOverrideDelegate.h>
|
|
7
8
|
#include <react/renderer/mounting/ShadowView.h>
|
|
8
9
|
#include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
#include <cstring>
|
|
12
13
|
#include <memory>
|
|
13
14
|
#include <optional>
|
|
15
|
+
#include <unordered_set>
|
|
14
16
|
#include <vector>
|
|
15
17
|
|
|
16
18
|
namespace reanimated {
|
|
@@ -43,6 +45,7 @@ struct Frame {
|
|
|
43
45
|
struct UpdateValues {
|
|
44
46
|
Props::Shared newProps;
|
|
45
47
|
Frame frame;
|
|
48
|
+
bool animatesOpacity = false;
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
struct Snapshot {
|
|
@@ -59,11 +62,18 @@ struct Snapshot {
|
|
|
59
62
|
};
|
|
60
63
|
|
|
61
64
|
typedef enum class ExitingState : std::uint8_t {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// React still renders the view
|
|
66
|
+
LIVE = 1,
|
|
67
|
+
// React deletes the view in the current transaction and the proxy has not decided how it exits yet
|
|
68
|
+
DECISION_PENDING = 2,
|
|
69
|
+
// withheld until its exiting descendants finish
|
|
70
|
+
WAITING = 3,
|
|
71
|
+
// withheld while its own exiting animation runs
|
|
72
|
+
ANIMATING = 4,
|
|
73
|
+
// its exiting animation finished, it is torn down at the next flush
|
|
74
|
+
COMPLETED = 5,
|
|
75
|
+
// the proxy has emitted its Remove and Delete
|
|
76
|
+
TORN_DOWN = 6,
|
|
67
77
|
} ExitingState;
|
|
68
78
|
|
|
69
79
|
struct MutationNode;
|
|
@@ -102,17 +112,18 @@ struct LightNode {
|
|
|
102
112
|
folly::dynamic accumulatedRawProps = nullptr;
|
|
103
113
|
bool propsNeedResolve = false;
|
|
104
114
|
#endif
|
|
105
|
-
ExitingState state = ExitingState::
|
|
115
|
+
ExitingState state = ExitingState::LIVE;
|
|
106
116
|
std::weak_ptr<LightNode> parent;
|
|
107
117
|
std::vector<std::shared_ptr<LightNode>> children;
|
|
108
118
|
int exitingChildrenCount = 0;
|
|
109
119
|
|
|
110
120
|
bool isExiting() const {
|
|
111
|
-
return state != ExitingState::
|
|
121
|
+
return state != ExitingState::LIVE;
|
|
112
122
|
}
|
|
113
123
|
|
|
114
124
|
void setExitingState(ExitingState newState) {
|
|
115
|
-
|
|
125
|
+
react_native_assert(newState != ExitingState::LIVE && "A light node never becomes live again");
|
|
126
|
+
const bool startsExiting = !isExiting();
|
|
116
127
|
state = newState;
|
|
117
128
|
if (!startsExiting) {
|
|
118
129
|
return;
|
|
@@ -142,7 +153,8 @@ struct LightNode {
|
|
|
142
153
|
|
|
143
154
|
// A new child goes after the exiting children at its shadow position. The differ sends a
|
|
144
155
|
// parent's Removes in descending order and its Inserts in ascending order, so the cursors
|
|
145
|
-
// resume the previous scan; a query out of order falls back to a full scan.
|
|
156
|
+
// resume the previous scan; a query out of order falls back to a full scan. A change of the
|
|
157
|
+
// children outside that sequence must reset the cursors. Order source:
|
|
146
158
|
// https://github.com/facebook/react-native/blob/v0.87.0/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.cpp#L1328-L1357
|
|
147
159
|
int toHostIndexForRemove(const int shadowIndex, IndexCursors &cursors) const {
|
|
148
160
|
validateExitingChildrenCount(cursors);
|
|
@@ -157,6 +169,8 @@ struct LightNode {
|
|
|
157
169
|
int liveChildrenBelow = cursor.shadowIndex;
|
|
158
170
|
for (int hostIndex = cursor.hostIndex - 1; hostIndex >= 0; hostIndex--) {
|
|
159
171
|
if (!children[hostIndex]->isExiting() && --liveChildrenBelow == shadowIndex) {
|
|
172
|
+
react_native_assert(
|
|
173
|
+
hostIndex == scanToHostIndex(shadowIndex, 0, 0) && "A stale index cursor gave a wrong host index");
|
|
160
174
|
cursor = {shadowIndex, hostIndex};
|
|
161
175
|
return hostIndex;
|
|
162
176
|
}
|
|
@@ -179,6 +193,8 @@ struct LightNode {
|
|
|
179
193
|
int hostIndex = 0;
|
|
180
194
|
if (cursor.hostIndex != -1 && shadowIndex > cursor.shadowIndex) {
|
|
181
195
|
hostIndex = scanToHostIndex(shadowIndex, cursor.hostIndex + 1, cursor.shadowIndex + 1);
|
|
196
|
+
react_native_assert(
|
|
197
|
+
hostIndex == scanToHostIndex(shadowIndex, 0, 0) && "A stale index cursor gave a wrong host index");
|
|
182
198
|
} else {
|
|
183
199
|
hostIndex = scanToHostIndex(shadowIndex, 0, 0);
|
|
184
200
|
}
|
|
@@ -255,6 +271,15 @@ static inline std::shared_ptr<LightNode> findParentRNSScreen(const std::shared_p
|
|
|
255
271
|
return current;
|
|
256
272
|
}
|
|
257
273
|
|
|
274
|
+
static inline bool isInSubtree(std::shared_ptr<LightNode> node, const std::shared_ptr<LightNode> &root) {
|
|
275
|
+
for (; node; node = node->parent.lock()) {
|
|
276
|
+
if (node == root) {
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
|
|
258
283
|
static inline bool isSETBoundary(const std::shared_ptr<LightNode> &node) {
|
|
259
284
|
return !std::strcmp(node->current.componentName, "REASharedTransitionBoundary");
|
|
260
285
|
}
|
|
@@ -283,4 +308,27 @@ static inline bool hasLayoutChanged(const ShadowViewMutation &mutation) {
|
|
|
283
308
|
return mutation.oldChildShadowView.layoutMetrics.frame != mutation.newChildShadowView.layoutMetrics.frame;
|
|
284
309
|
}
|
|
285
310
|
|
|
311
|
+
static inline bool isViewKind(const ShadowView &view) {
|
|
312
|
+
return view.traits.check(ShadowNodeTraits::Trait::ViewKind);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static inline const ViewProps &getViewProps(const ShadowView &view) {
|
|
316
|
+
react_native_assert(isViewKind(view) && "Only ViewKind views have ViewProps");
|
|
317
|
+
return static_cast<const ViewProps &>(*view.props);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Android mounts the Deletes of a transaction after its Creates, so a transaction that deletes and
|
|
321
|
+
// creates one tag loses the created view.
|
|
322
|
+
static inline bool deletesCreatedTag(const ShadowViewMutationList &mutations) {
|
|
323
|
+
std::unordered_set<Tag> created;
|
|
324
|
+
for (const auto &mutation : mutations) {
|
|
325
|
+
if (mutation.type == ShadowViewMutation::Create) {
|
|
326
|
+
created.insert(mutation.newChildShadowView.tag);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return std::ranges::any_of(mutations, [&created](const auto &mutation) {
|
|
330
|
+
return mutation.type == ShadowViewMutation::Delete && created.contains(mutation.oldChildShadowView.tag);
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
286
334
|
} // namespace reanimated
|
|
@@ -90,8 +90,8 @@ class PropsDiffer {
|
|
|
90
90
|
explicit PropsDiffer(jsi::Runtime &rt, const ShadowView &sourceView, const ShadowView &targetView)
|
|
91
91
|
: sourceView_(sourceView),
|
|
92
92
|
targetView_(targetView),
|
|
93
|
-
sourceViewProps_(
|
|
94
|
-
targetViewProps_(
|
|
93
|
+
sourceViewProps_(getViewProps(sourceView)),
|
|
94
|
+
targetViewProps_(getViewProps(targetView)),
|
|
95
95
|
sourceValues_(rt),
|
|
96
96
|
targetValues_(rt) {}
|
|
97
97
|
|
|
@@ -59,7 +59,7 @@ void LayoutAnimationsProxy::findSharedElementsOnScreen(
|
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
std::optional<SharedTag> sharedTag;
|
|
62
|
-
{
|
|
62
|
+
if (node->current.traits.check(ShadowNodeTraits::Trait::ViewKind)) {
|
|
63
63
|
auto lock = std::unique_lock<std::mutex>(sharedTransitionManager_->mutex_);
|
|
64
64
|
const auto it = sharedTransitionManager_->tagToName_.find(node->current.tag);
|
|
65
65
|
if (it != sharedTransitionManager_->tagToName_.end()) {
|
|
@@ -316,6 +316,7 @@ void LayoutAnimationsProxy::overrideTransform(
|
|
|
316
316
|
if (!transform) {
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
|
+
react_native_assert(isViewKind(shadowView) && "Only ViewKind views have ViewProps");
|
|
319
320
|
#ifdef ANDROID
|
|
320
321
|
auto array = folly::dynamic::array(folly::dynamic::object("matrix", transform->operator folly::dynamic()));
|
|
321
322
|
const folly::dynamic newTransformDynamic = folly::dynamic::object("transform", array);
|
|
@@ -492,9 +493,10 @@ void LayoutAnimationsProxy::hideTransitioningViews(
|
|
|
492
493
|
}
|
|
493
494
|
|
|
494
495
|
// The hide in hideTransitioningViews is not stored in the light tree, so a
|
|
495
|
-
// later Update for the same view carries full opacity and would show
|
|
496
|
-
// again. Force opacity 0 on every outgoing Update for a
|
|
497
|
-
// restore in cleanupSharedTransitions removes its tag
|
|
496
|
+
// later Update or Insert for the same view carries full opacity and would show
|
|
497
|
+
// the view again. Force opacity 0 on every outgoing Update and Insert for a
|
|
498
|
+
// hidden view until the restore in cleanupSharedTransitions removes its tag
|
|
499
|
+
// from hiddenViewTags_.
|
|
498
500
|
void LayoutAnimationsProxy::keepTransitioningViewsHidden(
|
|
499
501
|
ShadowViewMutationList &filteredMutations,
|
|
500
502
|
const PropsParserContext &propsParserContext) const {
|
|
@@ -502,11 +504,9 @@ void LayoutAnimationsProxy::keepTransitioningViewsHidden(
|
|
|
502
504
|
return;
|
|
503
505
|
}
|
|
504
506
|
for (auto &mutation : filteredMutations) {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
cloneViewWithoutOpacity(mutation.newChildShadowView, propsParserContext),
|
|
509
|
-
mutation.parentTag);
|
|
507
|
+
const bool writesProps = mutation.type == ShadowViewMutation::Update || mutation.type == ShadowViewMutation::Insert;
|
|
508
|
+
if (writesProps && hiddenViewTags_.contains(mutation.newChildShadowView.tag)) {
|
|
509
|
+
mutation.newChildShadowView = cloneViewWithoutOpacity(mutation.newChildShadowView, propsParserContext);
|
|
510
510
|
}
|
|
511
511
|
}
|
|
512
512
|
}
|
|
@@ -642,7 +642,7 @@ void LayoutAnimationsProxy::cleanupSharedTransitions(
|
|
|
642
642
|
if (!parent) {
|
|
643
643
|
continue;
|
|
644
644
|
}
|
|
645
|
-
const auto opacity =
|
|
645
|
+
const auto opacity = getViewProps(view).opacity;
|
|
646
646
|
filteredMutations.push_back(ShadowViewMutation::UpdateMutation(
|
|
647
647
|
cloneViewWithoutOpacity(view, propsParserContext),
|
|
648
648
|
cloneViewWithOpacity(view, opacity, propsParserContext),
|
|
@@ -721,7 +721,7 @@ std::optional<Transform> LayoutAnimationsProxy::parseParentTransforms(
|
|
|
721
721
|
while (currentNode) {
|
|
722
722
|
resolveLightNodeProps(currentNode);
|
|
723
723
|
const auto &view = useViewsOnScreen ? viewOnScreen(currentNode) : currentNode->current;
|
|
724
|
-
const auto &props =
|
|
724
|
+
const auto &props = getViewProps(view);
|
|
725
725
|
auto origin = props.transformOrigin;
|
|
726
726
|
const auto &viewSize = view.layoutMetrics.frame.size;
|
|
727
727
|
if (origin.xy[0].unit == facebook::react::UnitType::Percent) {
|