summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sally Qi <sallyqi@google.com> 2024-03-15 13:07:40 -0700
committer Sally Qi <sallyqi@google.com> 2024-03-15 17:15:54 -0700
commitf3a0ee5c848da0f8cb57b42991e21ec2dad3b2d4 (patch)
treee9a24175004705d73da6619f952b067ae1287a98
parent370ec60a11a07d9dfc4ff8df8694d506de6644c0 (diff)
Fix the crash in AnimatorManager.
If we have >1 mAnimators and also the animator target changes, `onAnimatorTargetChanged` function will erase mAnimators vector, while in AnimatorManager::pushStaging, the process still does the loop for mAnimators. Thus the crash happens. Bug: 327666562 Test: n/a Change-Id: I928185a2654b49660e226dcc89a2bc116cec870f
-rw-r--r--libs/hwui/AnimatorManager.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp
index 078041411a21..8645995e3df1 100644
--- a/libs/hwui/AnimatorManager.cpp
+++ b/libs/hwui/AnimatorManager.cpp
@@ -90,7 +90,13 @@ void AnimatorManager::pushStaging() {
}
mCancelAllAnimators = false;
} else {
- for (auto& animator : mAnimators) {
+ // create a copy of mAnimators as onAnimatorTargetChanged can erase mAnimators.
+ FatVector<sp<BaseRenderNodeAnimator>> animators;
+ animators.reserve(mAnimators.size());
+ for (const auto& animator : mAnimators) {
+ animators.push_back(animator);
+ }
+ for (auto& animator : animators) {
animator->pushStaging(mAnimationHandle->context());
}
}