From e05b2b806a318ac3b9ce2856937a6a927aa8e830 Mon Sep 17 00:00:00 2001 From: etkmao Date: Thu, 7 Nov 2024 17:35:34 +0800 Subject: [PATCH] fix(core): fix invalid animation crash (#4117) --- dom/src/dom/animation/animation_manager.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dom/src/dom/animation/animation_manager.cc b/dom/src/dom/animation/animation_manager.cc index 566c0379155..72bd39c9b36 100644 --- a/dom/src/dom/animation/animation_manager.cc +++ b/dom/src/dom/animation/animation_manager.cc @@ -396,9 +396,14 @@ void AnimationManager::UpdateAnimations() { auto now = footstone::time::MonotonicallyIncreasingTime(); std::unordered_map> update_node_map; // xcode crash if we change for to loop - for (std::vector>::size_type i = 0; i < active_animations_.size(); ++i) { - UpdateAnimation(active_animations_[i], now, update_node_map); + std::vector> loop_animations = active_animations_; + for (size_t i = 0; i < loop_animations.size(); ++i) { + auto it = std::find(active_animations_.begin(), active_animations_.end(), loop_animations[i]); + if (it != active_animations_.end()) { + UpdateAnimation(loop_animations[i], now, update_node_map); + } } + loop_animations.clear(); std::vector> update_nodes; update_nodes.reserve(update_node_map.size()); for (const auto& [key, value]: update_node_map) {