Commit 33ae97cc authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Fix perf regression in queuing duration.

The regression was caused by finished events being queued at the wrong
time in the document lifecycle. With this fix, the finished event is
deferred until the microtask is run rather than synchronously inside
the ApplyUpdates method.

Bug: 1015047
Change-Id: If2917b8aab27c5c98e58d78f4a43b4288b439e8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869389Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707458}
parent ad9f2471
......@@ -505,7 +505,7 @@ bool Animation::PreCommit(
// are waiting on a start time will get updated from NotifyStartTime.
// Finished animations may not trigger an Update call if finished in the same
// frame that they are started. Calling ApplyUpdates for this specific case
// ensures that the finished promise and event are properly triggered.
// ensures the proper propagation of events.
AnimationPlayState play_state = CalculateAnimationPlayState();
bool finished = play_state == kFinished;
if (pending_pause_ || (pending_play_ && (start_time_ || finished))) {
......@@ -1151,12 +1151,8 @@ void Animation::ApplyUpdates(double ready_time) {
ApplyPendingPlaybackRate();
if (pending_finish_notification_)
CommitFinishNotification();
DCHECK(!pending_play_);
DCHECK(!pending_pause_);
DCHECK(!pending_finish_notification_);
DCHECK(!active_playback_rate_);
// TODO(crbug.com/960944): Deprecate.
......
......@@ -52,6 +52,8 @@
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/testing/histogram_tester.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
......@@ -189,7 +191,9 @@ class AnimationAnimationTestNoCompositing : public RenderingTest {
SimulateFrame(last_frame_time);
}
void SimulateMicrotask() { animation->CommitAllUpdatesForTesting(); }
void SimulateMicrotask() {
Microtask::PerformCheckpoint(V8PerIsolateData::MainThreadIsolate());
}
Persistent<DocumentTimeline> timeline;
Persistent<Animation> animation;
......
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