Commit ce7fd8ee authored by chaopeng's avatar chaopeng Committed by Commit Bot

Ignore root scrolling when layer_list in active_tree is empty

This crash is because we have root layer is null and we don't handle it properly.
Root layer is null can happen if a scroll occurs before the root layer is attached.

In this patch, we return SCROLL_IGNORED with kNoScrollingLayer reason, same as what
we did in ScrollBegin.

Bug: 895817
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I9937ae2d494f4466018a3ee9a35e787e5e745bd6
Reviewed-on: https://chromium-review.googlesource.com/c/1289437Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601345}
parent 0b3c5cb7
...@@ -1022,6 +1022,20 @@ TEST_F(CommitToPendingTreeLayerTreeHostImplTest, ...@@ -1022,6 +1022,20 @@ TEST_F(CommitToPendingTreeLayerTreeHostImplTest,
"Compositing.Renderer.GPUMemoryForTilingsInKb", 1); "Compositing.Renderer.GPUMemoryForTilingsInKb", 1);
} }
TEST_F(LayerTreeHostImplTest, ScrollBeforeRootLayerAttached) {
InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
BeginState(gfx::Point()).get(), InputHandler::WHEEL);
EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
status.main_thread_scrolling_reasons);
status = host_impl_->RootScrollBegin(BeginState(gfx::Point()).get(),
InputHandler::WHEEL);
EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
status.main_thread_scrolling_reasons);
}
TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) {
SetupScrollAndContentsLayers(gfx::Size(100, 100)); SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->active_tree()->BuildPropertyTreesForTesting(); host_impl_->active_tree()->BuildPropertyTreesForTesting();
......
...@@ -2116,8 +2116,11 @@ struct FindScrollingLayerOrScrollbarFunctor { ...@@ -2116,8 +2116,11 @@ struct FindScrollingLayerOrScrollbarFunctor {
LayerImpl* LayerTreeImpl::FindFirstScrollingLayerOrScrollbarThatIsHitByPoint( LayerImpl* LayerTreeImpl::FindFirstScrollingLayerOrScrollbarThatIsHitByPoint(
const gfx::PointF& screen_space_point) { const gfx::PointF& screen_space_point) {
if (layer_list_.empty())
return nullptr;
FindClosestMatchingLayerState state; FindClosestMatchingLayerState state;
LayerImpl* root_layer = layer_list_.empty() ? nullptr : layer_list_[0]; LayerImpl* root_layer = layer_list_[0];
FindClosestMatchingLayer(screen_space_point, root_layer, FindClosestMatchingLayer(screen_space_point, root_layer,
FindScrollingLayerOrScrollbarFunctor(), &state); FindScrollingLayerOrScrollbarFunctor(), &state);
return state.closest_match; return state.closest_match;
......
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