mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Inline onTransitionAnimationEnd and fix iterator invalidation in ViewTransitionModule (#56104)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56104 `startViewTransitionEnd` was removing entries from `nameRegistry_` while iterating over it via `onTransitionAnimationEnd`, which is undefined behavior. This diff improves the fix by: - Inlining `onTransitionAnimationEnd` (private, single call site) - Clearing `nameRegistry_` after the loop instead of erasing during iteration, removing the need for a copy ## Changelog: [Internal] [Fixed] - Inline onTransitionAnimationEnd and fix iterator invalidation in ViewTransitionModule Reviewed By: christophpurrer Differential Revision: D96085815 fbshipit-source-id: b8e425d1166421cd10b27ea5d366d9fdef58d468
This commit is contained in:
1 parent
44ac8c26c2
commit
670d769577
2 files changed
+6
-21
No files matched your search
+6
-19
@@ -131,9 +131,13 @@ void ViewTransitionModule::startViewTransition(
|
||||
}
|
||||
|
||||
void ViewTransitionModule::startViewTransitionEnd() {
|
||||
for (const auto& it : nameRegistry_) {
|
||||
onTransitionAnimationEnd(it.second, it.first, 0);
|
||||
for (const auto& [tag, names] : nameRegistry_) {
|
||||
for (const auto& name : names) {
|
||||
oldLayout_.erase(name);
|
||||
newLayout_.erase(name);
|
||||
}
|
||||
}
|
||||
nameRegistry_.clear();
|
||||
|
||||
transitionStarted_ = false;
|
||||
}
|
||||
@@ -170,21 +174,4 @@ ViewTransitionModule::getViewTransitionInstance(
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void ViewTransitionModule::onTransitionAnimationEnd(
|
||||
const std::unordered_set<std::string>& names,
|
||||
Tag newTag,
|
||||
Tag oldTag) {
|
||||
for (const auto& name : names) {
|
||||
oldLayout_.erase(name);
|
||||
newLayout_.erase(name);
|
||||
}
|
||||
|
||||
if (newTag != 0) {
|
||||
nameRegistry_.erase(newTag);
|
||||
}
|
||||
if (oldTag != 0) {
|
||||
nameRegistry_.erase(oldTag);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -62,8 +62,6 @@ class ViewTransitionModule : public UIManagerViewTransitionDelegate {
|
||||
};
|
||||
|
||||
private:
|
||||
void onTransitionAnimationEnd(const std::unordered_set<std::string> &names, Tag newTag, Tag oldTag);
|
||||
|
||||
// registry of layout of old/new views
|
||||
std::unordered_map<std::string, AnimationKeyFrameView> oldLayout_{};
|
||||
std::unordered_map<std::string, AnimationKeyFrameView> newLayout_{};
|
||||
|
||||
Reference in new issue
Block a user