Commit ce0d1804 authored by danakj's avatar danakj Committed by Commit bot

cc: Don't try set RenderPasses on active tree after losing context.

DelegatedRendererLayerImpl passes the frame from the pending to the
active tree, but relies on there being a child_id_ on the active
layer that is known to the ResourceProvider. If the context was lost
while the frame was in the pending tree, the frames resources are
released, but we try to tell the resource provider to use the
empty frame with an invalid child id.

When the context is lost and we drop the frame, also unset the bool
saying we have a frame to pass to the active tree.

R=piman@chromium.org
BUG=488366

Review URL: https://codereview.chromium.org/1128043008

Cr-Commit-Position: refs/heads/master@{#330256}
parent 8d046462
......@@ -78,6 +78,7 @@ void DelegatedRendererLayerImpl::PushPropertiesTo(LayerImpl* layer) {
own_child_id_ = false;
if (have_render_passes_to_push_) {
DCHECK(child_id_);
// This passes ownership of the render passes to the active tree.
delegated_layer->SetRenderPasses(&render_passes_in_draw_order_);
// Once resources are on the active tree, give them to the ResourceProvider
......@@ -216,6 +217,7 @@ scoped_ptr<LayerImpl> DelegatedRendererLayerImpl::CreateLayerImpl(
void DelegatedRendererLayerImpl::ReleaseResources() {
ClearRenderPasses();
ClearChildId();
have_render_passes_to_push_ = false;
}
static inline int IndexToId(int index) { return index + 1; }
......
......@@ -404,6 +404,37 @@ class LayerTreeHostDelegatedTestCreateChildId
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestCreateChildId);
class LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit
: public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
protected:
void BeginTest() override {
SetFrameData(CreateFrameData(gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)));
LayerTreeHostDelegatedTestCaseSingleDelegatedLayer::BeginTest();
}
void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
// Act like the context was lost while the layer is in the pending tree.
LayerImpl* root_impl = host_impl->sync_tree()->root_layer();
FakeDelegatedRendererLayerImpl* delegated_impl =
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
delegated_impl->ReleaseResources();
}
void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override {
LayerImpl* root_impl = host_impl->active_tree()->root_layer();
FakeDelegatedRendererLayerImpl* delegated_impl =
static_cast<FakeDelegatedRendererLayerImpl*>(root_impl->children()[0]);
// Should not try to activate a frame without a child id. If we did try to
// activate we would crash.
EXPECT_FALSE(delegated_impl->ChildId());
EndTest();
}
};
MULTI_THREAD_IMPL_TEST_F(
LayerTreeHostDelegatedTestDontUseLostChildIdAfterCommit);
// Test that we can gracefully handle invalid frames after the context was lost.
// For example, we might be trying to use the previous frame in that case and
// have to make sure we don't crash because our resource accounting goes wrong.
......
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