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

Unified Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp

Issue 2623973002: Fix crash in 2D canvas caused by failed GPU context restoration (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
index b40311d4c2ae3a679bedba70501a571c3fba5860..f5744863f0a5d7cee0e893a8f4b61c89b5d3cccd 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp
@@ -250,6 +250,36 @@ class Canvas2DLayerBridgeTest : public Test {
bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
}
+ void prepareMailboxWhenContextIsLostWithFailedRestore() {
+ FakeGLES2Interface gl;
+ std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
+ WTF::wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
+ Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(
+ std::move(contextProvider), IntSize(300, 150), 0, NonOpaque,
+ Canvas2DLayerBridge::ForceAccelerationForTesting, nullptr,
+ kN32_SkColorType)));
+
+ // TODO(junov): The PrepareTextureMailbox() method will fail a DCHECK if we
+ // don't do this before calling it the first time when the context is lost.
+ bridge->prepareSurfaceForPaintingIfNeeded();
+
+ // When the context is lost we are not sure if we should still be producing
+ // GL frames for the compositor or not, so fail to generate frames.
+ gl.setIsContextLost(true);
+ EXPECT_FALSE(bridge->checkSurfaceValid());
+
+ // Restoration will fail because
+ // Platform::createSharedOffscreenGraphicsContext3DProvider() is stubbed
+ // in unit tests. This simulates what would happen when attempting to
+ // restore while the GPU process is down.
+ bridge->restoreSurface();
+
+ cc::TextureMailbox textureMailbox;
+ std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
+ EXPECT_FALSE(
+ bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback));
+ }
+
void prepareMailboxAndLoseResourceTest() {
// Prepare a mailbox, then report the resource as lost.
// This test passes by not crashing and not triggering assertions.
@@ -344,6 +374,11 @@ TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhenContextIsLost) {
prepareMailboxWhenContextIsLost();
}
+TEST_F(Canvas2DLayerBridgeTest,
+ PrepareMailboxWhenContextIsLostWithFailedRestore) {
+ prepareMailboxWhenContextIsLostWithFailedRestore();
+}
+
TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxAndLoseResource) {
prepareMailboxAndLoseResourceTest();
}
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698