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

Unified Diff: Source/platform/graphics/gpu/Extensions3DUtil.cpp

Issue 254453002: Fix WebGL context restoration logic. The retry mechanism was broken when the ownership of the WebGr… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added more safety checks upon context restoration. Created 6 years, 8 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 | « Source/platform/graphics/gpu/Extensions3DUtil.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/gpu/Extensions3DUtil.cpp
diff --git a/Source/platform/graphics/gpu/Extensions3DUtil.cpp b/Source/platform/graphics/gpu/Extensions3DUtil.cpp
index 0a978795439072c8c33bc2e62712c2cffac39019..7da33ee52119079dfc3ca5bbcf657a526ff8d314 100644
--- a/Source/platform/graphics/gpu/Extensions3DUtil.cpp
+++ b/Source/platform/graphics/gpu/Extensions3DUtil.cpp
@@ -23,28 +23,43 @@ void splitStringHelper(const String& str, HashSet<String>& set)
} // anonymous namespace
+PassOwnPtr<Extensions3DUtil> Extensions3DUtil::create(blink::WebGraphicsContext3D* context)
+{
+ OwnPtr<Extensions3DUtil> out = adoptPtr(new Extensions3DUtil(context));
+ if (!out->initializeExtensions())
+ return nullptr;
+ return out.release();
+}
+
Extensions3DUtil::Extensions3DUtil(blink::WebGraphicsContext3D* context)
: m_context(context)
{
- initializeExtensions();
}
Extensions3DUtil::~Extensions3DUtil()
{
}
-void Extensions3DUtil::initializeExtensions()
+bool Extensions3DUtil::initializeExtensions()
{
- bool success = m_context->makeContextCurrent();
- ASSERT(success);
- if (!success)
- return;
+ if (!m_context->makeContextCurrent()) {
+ // Most likely the GPU process exited and the attempt to reconnect to it failed.
+ // Need to try to restore the context again later.
+ return false;
+ }
+
+ if (m_context->isContextLost()) {
+ // Need to try to restore the context again later.
+ return false;
+ }
String extensionsString = m_context->getString(GL_EXTENSIONS);
splitStringHelper(extensionsString, m_enabledExtensions);
String requestableExtensionsString = m_context->getRequestableExtensionsCHROMIUM();
splitStringHelper(requestableExtensionsString, m_requestableExtensions);
+
+ return true;
}
« no previous file with comments | « Source/platform/graphics/gpu/Extensions3DUtil.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698