Commit a6aa2f14 authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Fix DCHECK failure when playing after cancelling an animation.

The implementation of cancel was aligned with the web-animations spec
in:

https://chromium-review.googlesource.com/c/chromium/src/+/1824058

Resolving the ready promise after the reject and reset is not to spec [1].
After the above patch we no longer resolve the ready promise after a cancel,
so it is possible to already have a pending promise when we enter the "pending"
state.

This introduced a DCHECK failure when transitioning from an idle state to a
pending state. Per above this DCHECK is incorrect so we remove it.

Previously, when an animation was cancelled, the destructor for
PlayStateUpdateScope will not only reject and reset the ready promise, but it
will then resolve this new promise. When transitioning from idle to pending, an
additional reset is performed with a check that we do not already have a
pending promise.

Spec: https://drafts.csswg.org/web-animations/#canceling-an-animation-section


Bug: 1012384
Change-Id: Id40fc094f599463a5e3ab67715edde02bbec6720
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1853164
Commit-Queue: Majid Valipour <majidvp@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705094}
parent 35f1dca5
......@@ -1542,6 +1542,8 @@ void Animation::cancel() {
if (pending()) {
// TODO(crbug.com/916117): Rejecting the ready promise should be performed
// inside reset pending tasks once aligned with the spec.
// TODO(crbug.com/1013351): Add test for rejection and reset of cancel
// promise. Requires further cleanup of PlayStateUpdateScope.
if (ready_promise_)
RejectAndResetPromiseMaybeAsync(ready_promise_.Get());
}
......@@ -1692,8 +1694,6 @@ Animation::PlayStateUpdateScope::~PlayStateUpdateScope() {
animation_->ResetPendingTasks();
animation_->ResolvePromiseMaybeAsync(animation_->ready_promise_.Get());
} else if (new_play_state == kPending) {
DCHECK_NE(animation_->ready_promise_->GetState(),
AnimationPromise::kPending);
animation_->ready_promise_->Reset();
}
}
......
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