Skip to content

Commit

Permalink
fix(ios): add a null protection to animation target (new anim module)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Jul 10, 2024
1 parent 07d39fe commit 4cd995d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ios/sdk/module/animation2/HippyNextAnimationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,25 @@ - (void)animatorDidAnimate:(HPOPAnimator *)animator inCustomQueue:(dispatch_queu
NSMutableArray<HippyNextAnimation *> *pendingAnims = [strongSelf.pendingStartGroupAnimations objectForKey:queueKey];
[strongSelf.groupAnimSyncLock unlock];

NSMutableArray<HippyNextAnimation *> *resultAnims = nil;
NSMutableArray<id> *targetObjects = [NSMutableArray arrayWithCapacity:pendingAnims.count];
CFTimeInterval now = CACurrentMediaTime();
for (HippyNextAnimation *anim in pendingAnims) {
id target = anim.targetObject;
if (!target) {
if (!resultAnims) {
// only copy when needed
resultAnims = [pendingAnims mutableCopy];
}
[resultAnims removeObject:anim];
continue;
}
anim.beginTime = now + anim.delayTime;
[targetObjects addObject:anim.targetObject];
[targetObjects addObject:target];
}

[[HPOPAnimator sharedAnimator] addAnimations:pendingAnims forObjects:targetObjects andKeys:nil];
[[HPOPAnimator sharedAnimator] addAnimations:resultAnims ?: pendingAnims
forObjects:targetObjects andKeys:nil];
[pendingAnims removeAllObjects];
});
}
Expand Down

0 comments on commit 4cd995d

Please sign in to comment.