Commit 17c90686 authored by David Black's avatar David Black Committed by Commit Bot

Fix crash in Assistant's AnimatedContainerView.

Crash was caused by overlapping animate-out animations.

Bug: b:157521638, b:151979172, b:145136105
Change-Id: I71787905346a29a3d238d172a5660e252d3c4f01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216617
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarJeroen Dhollander <jeroendh@google.com>
Cr-Commit-Position: refs/heads/master@{#772418}
parent 062e4d3a
...@@ -177,10 +177,10 @@ void AnimatedContainerView::ChangeResponse( ...@@ -177,10 +177,10 @@ void AnimatedContainerView::ChangeResponse(
// view hierarchy can be removed before the underlying views are destroyed. // view hierarchy can be removed before the underlying views are destroyed.
queued_response_ = response; queued_response_ = response;
// If we are currently fading out the old content, don't interrupt it. // If we are currently animating-/fading-out the old content, don't interrupt
// When the fading out is completed, it will detect we've got a queued // it. When the animating-/fading-out is completed, it will detect we've got a
// response and animate it in. // queued response and animate it in.
if (fade_out_in_progress_) if (animate_out_in_progress_ || fade_out_in_progress_)
return; return;
// If we don't have any pre-existing content, there is nothing to animate off // If we don't have any pre-existing content, there is nothing to animate off
...@@ -190,6 +190,8 @@ void AnimatedContainerView::ChangeResponse( ...@@ -190,6 +190,8 @@ void AnimatedContainerView::ChangeResponse(
return; return;
} }
animate_out_in_progress_ = true;
// There is a previous response on stage, so we'll animate it off before // There is a previous response on stage, so we'll animate it off before
// adding the new response. The new response will be added upon invocation // adding the new response. The new response will be added upon invocation
// of the exit animation ended callback. // of the exit animation ended callback.
...@@ -332,6 +334,8 @@ bool AnimatedContainerView::AnimateOutObserverCallback( ...@@ -332,6 +334,8 @@ bool AnimatedContainerView::AnimateOutObserverCallback(
if (!weak_ptr) if (!weak_ptr)
return true; return true;
weak_ptr->animate_out_in_progress_ = false;
// If the exit animation was aborted, we just return true to delete our // If the exit animation was aborted, we just return true to delete our
// observer. No further action is needed. // observer. No further action is needed.
if (observer.aborted_count()) if (observer.aborted_count())
......
...@@ -151,6 +151,9 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AnimatedContainerView ...@@ -151,6 +151,9 @@ class COMPONENT_EXPORT(ASSISTANT_UI) AnimatedContainerView
// reduces layout passes. // reduces layout passes.
bool propagate_preferred_size_changed_ = true; bool propagate_preferred_size_changed_ = true;
// Whether the animate-out animation is in progress.
bool animate_out_in_progress_ = false;
// Whether the fade-out animation is in progress. // Whether the fade-out animation is in progress.
bool fade_out_in_progress_ = false; bool fade_out_in_progress_ = false;
......
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