Commit 5c53878e authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Stop animating without completion for new scroll events.

The completion blocks of the property animator is not guaranteed to be
called in the synchronously from |-finishAnimationAtPosition:|, so
despite previous safeguards put in place, the animator was still
sometimes deallocated when the state was active.  This CL updates
StopAnimating() to no longer perform property animator completion
blocks.

Bug: 793623
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I5d6d08c229d5fabe78f2ff79ab69560f79532d21
Reviewed-on: https://chromium-review.googlesource.com/835790Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525362}
parent fdb2f3ae
...@@ -67,8 +67,7 @@ void FullscreenMediator::FullscreenModelScrollEventEnded( ...@@ -67,8 +67,7 @@ void FullscreenMediator::FullscreenModelScrollEventEnded(
animator_ = [[FullscreenScrollEndAnimator alloc] animator_ = [[FullscreenScrollEndAnimator alloc]
initWithStartProgress:model_->progress()]; initWithStartProgress:model_->progress()];
[animator_ addCompletion:^(UIViewAnimatingPosition finalPosition) { [animator_ addCompletion:^(UIViewAnimatingPosition finalPosition) {
DCHECK(finalPosition == UIViewAnimatingPositionEnd || DCHECK_EQ(finalPosition, UIViewAnimatingPositionEnd);
finalPosition == UIViewAnimatingPositionCurrent);
model_->AnimationEndedWithProgress( model_->AnimationEndedWithProgress(
[animator_ progressForAnimatingPosition:finalPosition]); [animator_ progressForAnimatingPosition:finalPosition]);
animator_ = nil; animator_ = nil;
...@@ -84,14 +83,7 @@ void FullscreenMediator::StopAnimating() { ...@@ -84,14 +83,7 @@ void FullscreenMediator::StopAnimating() {
return; return;
DCHECK_EQ(animator_.state, UIViewAnimatingStateActive); DCHECK_EQ(animator_.state, UIViewAnimatingStateActive);
[animator_ stopAnimation:NO]; model_->AnimationEndedWithProgress(animator_.currentProgress);
[animator_ stopAnimation:YES];
// Property animators throw exceptions if they are deallocated in the animator_ = nil;
// UIViewAnimatingStateStopped state. Since the cleanup occurring in the
// animator's completion block occurs before |-finishAnimationAtPosition:|
// resets the state to UIViewAnimatingStateInactive, the animator is retained
// here so that it can be deallocated when reset to inactive.
FullscreenScrollEndAnimator* animator = animator_;
[animator_ finishAnimationAtPosition:UIViewAnimatingPositionCurrent];
animator = nil;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment