summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 01:36:44 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 01:36:44 +0000
commit9a961a8ab0fa0e17af39b14620b8ac4bc88ae014 (patch)
tree556252f303aff9559d9a6819cf1ba7540b817ba5
parent3784660319748aed36a0d243969feed846aad380 (diff)
downloadchromium_src-9a961a8ab0fa0e17af39b14620b8ac4bc88ae014.zip
chromium_src-9a961a8ab0fa0e17af39b14620b8ac4bc88ae014.tar.gz
chromium_src-9a961a8ab0fa0e17af39b14620b8ac4bc88ae014.tar.bz2
cc: Fix PictureLayerImpl crash in post-commit init
If the post-commit initialization happens during the first activation, there's a crash when trying to sync to an existing but uninitialized active layer. Fix this by checking for this case. R=danakj@chromium.org BUG=267144 Review URL: https://chromiumcodereview.appspot.com/21632002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215188 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/layers/picture_layer_impl.cc8
-rw-r--r--cc/layers/picture_layer_impl_unittest.cc35
-rw-r--r--cc/test/fake_picture_layer_impl.h7
3 files changed, 49 insertions, 1 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 1e2b5c2..a5c69cc 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -527,6 +527,9 @@ gfx::Size PictureLayerImpl::CalculateTileSize(
}
void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
+ DCHECK(!other->needs_post_commit_initialization_);
+ DCHECK(other->tilings_);
+
UpdateLCDTextStatus(other->is_using_lcd_text_);
if (!DrawsContent()) {
@@ -722,7 +725,10 @@ void PictureLayerImpl::DoPostCommitInitialization() {
if (twin_layer_) {
DCHECK(!twin_layer_->twin_layer_);
twin_layer_->twin_layer_ = this;
- SyncFromActiveLayer(twin_layer_);
+ // If the twin has never been pushed to, do not sync from it.
+ // This can happen if this function is called during activation.
+ if (!twin_layer_->needs_post_commit_initialization_)
+ SyncFromActiveLayer(twin_layer_);
}
needs_post_commit_initialization_ = false;
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index d800123..3272712 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -1006,5 +1006,40 @@ TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) {
EXPECT_GT(num_offscreen, 0);
}
+TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
+ gfx::Size tile_size(100, 100);
+ gfx::Size layer_bounds(400, 400);
+ scoped_refptr<FakePicturePileImpl> pending_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+
+ host_impl_.CreatePendingTree();
+ LayerTreeImpl* pending_tree = host_impl_.pending_tree();
+
+ scoped_ptr<FakePictureLayerImpl> pending_layer =
+ FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pending_pile);
+ pending_layer->SetDrawsContent(true);
+ pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>());
+
+ pending_layer_ = static_cast<FakePictureLayerImpl*>(
+ host_impl_.pending_tree()->LayerById(id_));
+
+ // Set some state on the pending layer, make sure it is not clobbered
+ // by a sync from the active layer. This could happen because if the
+ // pending layer has not been post-commit initialized it will attempt
+ // to sync from the active layer.
+ bool default_lcd_text_setting = pending_layer_->is_using_lcd_text();
+ pending_layer_->force_set_lcd_text(!default_lcd_text_setting);
+ EXPECT_TRUE(pending_layer_->needs_post_commit_initialization());
+
+ host_impl_.ActivatePendingTree();
+
+ active_layer_ = static_cast<FakePictureLayerImpl*>(
+ host_impl_.active_tree()->LayerById(id_));
+
+ EXPECT_EQ(0u, active_layer_->num_tilings());
+ EXPECT_EQ(!default_lcd_text_setting, active_layer_->is_using_lcd_text());
+ EXPECT_FALSE(active_layer_->needs_post_commit_initialization());
+}
+
} // namespace
} // namespace cc
diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h
index 248437b..2eeaeef 100644
--- a/cc/test/fake_picture_layer_impl.h
+++ b/cc/test/fake_picture_layer_impl.h
@@ -34,6 +34,13 @@ class FakePictureLayerImpl : public PictureLayerImpl {
using PictureLayerImpl::MarkVisibleResourcesAsRequired;
using PictureLayerImpl::DoPostCommitInitializationIfNeeded;
+ bool needs_post_commit_initialization() const {
+ return needs_post_commit_initialization_;
+ }
+
+ bool is_using_lcd_text() const { return is_using_lcd_text_; }
+ void force_set_lcd_text(bool enabled) { is_using_lcd_text_ = enabled; }
+
PictureLayerTiling* HighResTiling() const;
PictureLayerTiling* LowResTiling() const;
size_t num_tilings() const { return tilings_->num_tilings(); }