- Revision
- 116979
- Author
- [email protected]
- Date
- 2012-05-14 12:10:19 -0700 (Mon, 14 May 2012)
Log Message
[chromium] Add compositor debug asserts for blocked main thread
https://bugs.webkit.org/show_bug.cgi?id=86384
Reviewed by James Robinson.
Source/WebCore:
Where we depend for thread-safety that the main thread is blocked,
assert that this is actually the case.
* platform/graphics/chromium/cc/CCProxy.cpp:
(WebCore):
(WebCore::CCProxy::isMainThreadBlocked):
(WebCore::CCProxy::setMainThreadBlocked):
* platform/graphics/chromium/cc/CCProxy.h:
(CCProxy):
(WebCore):
(DebugScopedSetMainThreadBlocked):
(WebCore::DebugScopedSetMainThreadBlocked::DebugScopedSetMainThreadBlocked):
(WebCore::DebugScopedSetMainThreadBlocked::~DebugScopedSetMainThreadBlocked):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::doCommit):
(WebCore::CCSingleThreadProxy::stop):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::stop):
(WebCore::CCThreadProxy::beginFrame):
* platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
(WebCore::CCVideoLayerImpl::CCVideoLayerImpl):
(WebCore::CCVideoLayerImpl::~CCVideoLayerImpl):
Source/WebKit/chromium:
For tests that are just on the impl tree, pretend that the main thread
is always blocked.
* tests/CCLayerTreeHostImplTest.cpp:
(CCLayerTreeHostImplTest):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (116978 => 116979)
--- trunk/Source/WebCore/ChangeLog 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebCore/ChangeLog 2012-05-14 19:10:19 UTC (rev 116979)
@@ -1,3 +1,33 @@
+2012-05-14 Adrienne Walker <[email protected]>
+
+ [chromium] Add compositor debug asserts for blocked main thread
+ https://bugs.webkit.org/show_bug.cgi?id=86384
+
+ Reviewed by James Robinson.
+
+ Where we depend for thread-safety that the main thread is blocked,
+ assert that this is actually the case.
+
+ * platform/graphics/chromium/cc/CCProxy.cpp:
+ (WebCore):
+ (WebCore::CCProxy::isMainThreadBlocked):
+ (WebCore::CCProxy::setMainThreadBlocked):
+ * platform/graphics/chromium/cc/CCProxy.h:
+ (CCProxy):
+ (WebCore):
+ (DebugScopedSetMainThreadBlocked):
+ (WebCore::DebugScopedSetMainThreadBlocked::DebugScopedSetMainThreadBlocked):
+ (WebCore::DebugScopedSetMainThreadBlocked::~DebugScopedSetMainThreadBlocked):
+ * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+ (WebCore::CCSingleThreadProxy::doCommit):
+ (WebCore::CCSingleThreadProxy::stop):
+ * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+ (WebCore::CCThreadProxy::stop):
+ (WebCore::CCThreadProxy::beginFrame):
+ * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
+ (WebCore::CCVideoLayerImpl::CCVideoLayerImpl):
+ (WebCore::CCVideoLayerImpl::~CCVideoLayerImpl):
+
2012-05-14 Swapna P <[email protected]>
Reviewed by Eric Seidel.
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.cpp (116978 => 116979)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.cpp 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.cpp 2012-05-14 19:10:19 UTC (rev 116979)
@@ -38,6 +38,7 @@
namespace {
#ifndef NDEBUG
bool implThreadIsOverridden = false;
+bool s_isMainThreadBlocked = false;
ThreadIdentifier threadIDOverridenToBeImplThread;
#endif
CCThread* s_mainThread = 0;
@@ -102,6 +103,16 @@
if (isImplThread)
threadIDOverridenToBeImplThread = WTF::currentThread();
}
+
+bool CCProxy::isMainThreadBlocked()
+{
+ return s_isMainThreadBlocked;
+}
+
+void CCProxy::setMainThreadBlocked(bool isMainThreadBlocked)
+{
+ s_isMainThreadBlocked = isMainThreadBlocked;
+}
#endif
CCProxy::CCProxy()
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h (116978 => 116979)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h 2012-05-14 19:10:19 UTC (rev 116979)
@@ -106,6 +106,8 @@
#ifndef NDEBUG
static bool isMainThread();
static bool isImplThread();
+ static bool isMainThreadBlocked();
+ static void setMainThreadBlocked(bool);
#endif
// Temporary hack while render_widget still does scheduling for CCLayerTreeHostMainThreadI
@@ -121,8 +123,27 @@
protected:
CCProxy();
friend class DebugScopedSetImplThread;
+ friend class DebugScopedSetMainThreadBlocked;
};
+class DebugScopedSetMainThreadBlocked {
+public:
+ DebugScopedSetMainThreadBlocked()
+ {
+#if !ASSERT_DISABLED
+ ASSERT(!CCProxy::isMainThreadBlocked());
+ CCProxy::setMainThreadBlocked(true);
+#endif
+ }
+ ~DebugScopedSetMainThreadBlocked()
+ {
+#if !ASSERT_DISABLED
+ ASSERT(CCProxy::isMainThreadBlocked());
+ CCProxy::setMainThreadBlocked(false);
+#endif
+ }
+};
+
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (116978 => 116979)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-05-14 19:10:19 UTC (rev 116979)
@@ -198,7 +198,9 @@
ASSERT(CCProxy::isMainThread());
// Commit immediately
{
+ DebugScopedSetMainThreadBlocked mainThreadBlocked;
DebugScopedSetImplThread impl;
+
m_layerTreeHostImpl->beginCommit();
m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
@@ -263,7 +265,9 @@
TRACE_EVENT("CCSingleThreadProxy::stop", this, 0);
ASSERT(CCProxy::isMainThread());
{
+ DebugScopedSetMainThreadBlocked mainThreadBlocked;
DebugScopedSetImplThread impl;
+
m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator());
m_layerTreeHostImpl.clear();
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (116978 => 116979)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2012-05-14 19:10:19 UTC (rev 116979)
@@ -397,10 +397,14 @@
ASSERT(m_started);
// Synchronously deletes the impl.
- CCCompletionEvent completion;
- CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::layerTreeHostClosedOnImplThread, AllowCrossThreadAccess(&completion)));
- completion.wait();
+ {
+ DebugScopedSetMainThreadBlocked mainThreadBlocked;
+ CCCompletionEvent completion;
+ CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::layerTreeHostClosedOnImplThread, AllowCrossThreadAccess(&completion)));
+ completion.wait();
+ }
+
m_mainThreadProxy->shutdown(); // Stop running tasks posted to us.
ASSERT(!m_layerTreeHostImpl); // verify that the impl deleted.
@@ -529,6 +533,8 @@
// coordinated by the CCScheduler.
{
TRACE_EVENT("commit", this, 0);
+ DebugScopedSetMainThreadBlocked mainThreadBlocked;
+
CCCompletionEvent completion;
CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameCompleteOnImplThread, AllowCrossThreadAccess(&completion)));
completion.wait();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp (116978 => 116979)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp 2012-05-14 19:10:19 UTC (rev 116979)
@@ -85,12 +85,14 @@
// thread is blocked. That makes this a thread-safe call to set the video
// frame provider client that does not require a lock. The same is true of
// the call in the destructor.
+ ASSERT(CCProxy::isMainThreadBlocked());
m_provider->setVideoFrameProviderClient(this);
}
CCVideoLayerImpl::~CCVideoLayerImpl()
{
// See comment in constructor for why this doesn't need a lock.
+ ASSERT(CCProxy::isMainThreadBlocked());
if (m_provider) {
m_provider->setVideoFrameProviderClient(0);
m_provider = 0;
Modified: trunk/Source/WebKit/chromium/ChangeLog (116978 => 116979)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-05-14 19:10:19 UTC (rev 116979)
@@ -1,3 +1,16 @@
+2012-05-14 Adrienne Walker <[email protected]>
+
+ [chromium] Add compositor debug asserts for blocked main thread
+ https://bugs.webkit.org/show_bug.cgi?id=86384
+
+ Reviewed by James Robinson.
+
+ For tests that are just on the impl tree, pretend that the main thread
+ is always blocked.
+
+ * tests/CCLayerTreeHostImplTest.cpp:
+ (CCLayerTreeHostImplTest):
+
2012-05-12 Sheriff Bot <[email protected]>
Unreviewed, rolling out r116812.
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp (116978 => 116979)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-05-14 19:06:54 UTC (rev 116978)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp 2012-05-14 19:10:19 UTC (rev 116979)
@@ -113,6 +113,8 @@
}
DebugScopedSetImplThread m_alwaysImplThread;
+ DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
+
OwnPtr<CCLayerTreeHostImpl> m_hostImpl;
bool m_didRequestCommit;
bool m_didRequestRedraw;