Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1577)

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2251933002: Fix smooth scroll animation flake on janky pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UpdateTarget while animation is not started Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 696e1de46515963d207e030c8e428e56a0406bdb..e93ee17d84f002b44f60d8bb6e8cdde7d6e93677 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -9809,6 +9809,57 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
host_impl_->DidFinishImplFrame();
}
+// Verfify that a smooth scroll animation doesn't jump when UpdateTarget gets
+// called before the animation is started.
+TEST_F(LayerTreeHostImplTest, AnimatedScrollUpdateTargetBeforeStarting) {
+ const gfx::Size content_size(1000, 1000);
+ const gfx::Size viewport_size(50, 100);
+ CreateBasicVirtualViewportLayers(viewport_size, content_size);
+
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(200);
+
+ BeginFrameArgs begin_frame_args =
+ CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
+ begin_frame_args.frame_time = start_time;
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->UpdateAnimationState(true);
+ host_impl_->DidFinishImplFrame();
+
+ EXPECT_EQ(
+ InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread);
+ // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation
+ // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and
+ // doesn't have a start time.
+ EXPECT_EQ(
+ InputHandler::SCROLL_ON_IMPL_THREAD,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread);
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(250);
+ // This is when the animation above gets promoted to STARTING.
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->UpdateAnimationState(true);
+ host_impl_->DidFinishImplFrame();
+
+ begin_frame_args.frame_time =
+ start_time + base::TimeDelta::FromMilliseconds(300);
+ // This is when the animation above gets ticked.
+ host_impl_->WillBeginImplFrame(begin_frame_args);
+ host_impl_->UpdateAnimationState(true);
+ host_impl_->DidFinishImplFrame();
+
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+ EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer);
+
+ // Verify no jump.
+ float y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 1 && y < 49);
+}
+
// Test that a smooth scroll offset animation is aborted when followed by a
// non-smooth scroll offset animation.
TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
« cc/animation/scroll_offset_animations_impl.cc ('K') | « cc/test/animation_test_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698