- Revision
- 128005
- Author
- [email protected]
- Date
- 2012-09-09 16:59:41 -0700 (Sun, 09 Sep 2012)
Log Message
[chromium] Do not delete texture backing structures on the main thread
https://bugs.webkit.org/show_bug.cgi?id=96018
Patch by Christopher Cameron <[email protected]> on 2012-09-09
Reviewed by James Robinson.
Do not delete CCPrioritizedTexture::Backing structures on the main
thread. Instead, unlink them from their owning CCPrioritizedTexture
in the main thread, and have the impl thread then delete all unlinked
textures.
This is towards having the main thread not access the m_backings set,
which will allow the impl thread to traverse that set when deleting
resources in response to GPU memory management events.
Tested by existing eviction tests (CCLayerTreeHostTest's
TestEvictTextures, LostContextAfterEvictTextures)
Fix a place where single thread proxy wasn't setting the main thread
blocked state correctly.
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::unlinkAllContentTextures):
(WebCore):
(WebCore::CCLayerTreeHost::deleteUnlinkedTextures):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):
* platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
(WebCore::CCPrioritizedTextureManager::clearAllMemory):
(WebCore::CCPrioritizedTextureManager::unlinkAllBackings):
(WebCore):
(WebCore::CCPrioritizedTextureManager::deleteAllUnlinkedBackings):
* platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
(CCPrioritizedTextureManager):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::commitAndComposite):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::beginFrame):
(WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128004 => 128005)
--- trunk/Source/WebCore/ChangeLog 2012-09-09 22:49:37 UTC (rev 128004)
+++ trunk/Source/WebCore/ChangeLog 2012-09-09 23:59:41 UTC (rev 128005)
@@ -1,3 +1,44 @@
+2012-09-09 Christopher Cameron <[email protected]>
+
+ [chromium] Do not delete texture backing structures on the main thread
+ https://bugs.webkit.org/show_bug.cgi?id=96018
+
+ Reviewed by James Robinson.
+
+ Do not delete CCPrioritizedTexture::Backing structures on the main
+ thread. Instead, unlink them from their owning CCPrioritizedTexture
+ in the main thread, and have the impl thread then delete all unlinked
+ textures.
+
+ This is towards having the main thread not access the m_backings set,
+ which will allow the impl thread to traverse that set when deleting
+ resources in response to GPU memory management events.
+
+ Tested by existing eviction tests (CCLayerTreeHostTest's
+ TestEvictTextures, LostContextAfterEvictTextures)
+
+ Fix a place where single thread proxy wasn't setting the main thread
+ blocked state correctly.
+
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::unlinkAllContentTextures):
+ (WebCore):
+ (WebCore::CCLayerTreeHost::deleteUnlinkedTextures):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+ (CCLayerTreeHost):
+ * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
+ (WebCore::CCPrioritizedTextureManager::clearAllMemory):
+ (WebCore::CCPrioritizedTextureManager::unlinkAllBackings):
+ (WebCore):
+ (WebCore::CCPrioritizedTextureManager::deleteAllUnlinkedBackings):
+ * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
+ (CCPrioritizedTextureManager):
+ * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+ (WebCore::CCSingleThreadProxy::commitAndComposite):
+ * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+ (WebCore::CCThreadProxy::beginFrame):
+ (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
+
2012-09-09 Andreas Kling <[email protected]>
EventListenerMap: Use Vector instead of HashMap as backend.
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (128004 => 128005)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-09-09 22:49:37 UTC (rev 128004)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2012-09-09 23:59:41 UTC (rev 128005)
@@ -414,13 +414,20 @@
m_proxy->setVisible(visible);
}
-void CCLayerTreeHost::evictAllContentTextures()
+void CCLayerTreeHost::unlinkAllContentTextures()
{
ASSERT(CCProxy::isMainThread());
ASSERT(m_contentsTextureManager.get());
- m_contentsTextureManager->allBackingTexturesWereDeleted();
+ m_contentsTextureManager->unlinkAllBackings();
}
+void CCLayerTreeHost::deleteUnlinkedTextures()
+{
+ ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
+ ASSERT(m_contentsTextureManager.get());
+ m_contentsTextureManager->deleteAllUnlinkedBackings();
+}
+
void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec)
{
m_proxy->startPageScaleAnimation(targetPosition, useAnchor, scale, durationSec);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (128004 => 128005)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-09-09 22:49:37 UTC (rev 128004)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h 2012-09-09 23:59:41 UTC (rev 128005)
@@ -211,11 +211,8 @@
CCPrioritizedTextureManager* contentsTextureManager() const;
- // This will cause contents texture manager to evict all textures, but
- // without deleting them. This happens after all content textures have
- // already been deleted on impl, after getting a 0 allocation limit.
- // Set during a commit, but before updateLayers.
- void evictAllContentTextures();
+ void unlinkAllContentTextures();
+ void deleteUnlinkedTextures();
bool visible() const { return m_visible; }
void setVisible(bool);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp (128004 => 128005)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp 2012-09-09 22:49:37 UTC (rev 128004)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp 2012-09-09 23:59:41 UTC (rev 128005)
@@ -248,6 +248,8 @@
void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourceProvider)
{
+ ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
+ ASSERT(resourceProvider);
// Unlink and destroy all backing textures.
while (m_backings.size() > 0) {
BackingSet::iterator it = m_backings.begin();
@@ -257,14 +259,26 @@
}
}
-void CCPrioritizedTextureManager::allBackingTexturesWereDeleted()
+void CCPrioritizedTextureManager::unlinkAllBackings()
{
- // Same as clearAllMemory, except all our textures were already
- // deleted externally, so we don't delete them. Passing no
- // resourceProvider results in leaking the (now invalid) texture ids.
- clearAllMemory(0);
+ ASSERT(CCProxy::isMainThread());
+ for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
+ if ((*it)->owner())
+ (*it)->owner()->unlink();
}
+void CCPrioritizedTextureManager::deleteAllUnlinkedBackings()
+{
+ ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
+ BackingVector backingsToDelete;
+ for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
+ if (!(*it)->owner())
+ backingsToDelete.append((*it));
+
+ for (BackingVector::iterator it = backingsToDelete.begin(); it != backingsToDelete.end(); ++it)
+ destroyBacking((*it), 0);
+}
+
void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture)
{
ASSERT(CCProxy::isMainThread());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h (128004 => 128005)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h 2012-09-09 22:49:37 UTC (rev 128004)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h 2012-09-09 23:59:41 UTC (rev 128005)
@@ -78,7 +78,8 @@
void reduceMemory(CCResourceProvider*);
void clearAllMemory(CCResourceProvider*);
- void allBackingTexturesWereDeleted();
+ void unlinkAllBackings();
+ void deleteAllUnlinkedBackings();
void acquireBackingTextureIfNeeded(CCPrioritizedTexture*, CCResourceProvider*);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp (128004 => 128005)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-09-09 22:49:37 UTC (rev 128004)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp 2012-09-09 23:59:41 UTC (rev 128005)
@@ -154,6 +154,7 @@
bool initialized;
{
+ DebugScopedSetMainThreadBlocked mainThreadBlocked;
DebugScopedSetImplThread impl;
if (!m_layerTreeHostImpl->contentsTexturesPurged())
m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
@@ -296,12 +297,14 @@
{
ASSERT(CCProxy::isMainThread());
-
if (!m_layerTreeHost->initializeRendererIfNeeded())
return false;
- if (m_layerTreeHostImpl->contentsTexturesPurged())
- m_layerTreeHost->evictAllContentTextures();
+ if (m_layerTreeHostImpl->contentsTexturesPurged()) {
+ m_layerTreeHost->unlinkAllContentTextures();
+ DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked;
+ m_layerTreeHost->deleteUnlinkedTextures();
+ }
CCTextureUpdateQueue queue;
m_layerTreeHost->updateLayers(queue, m_layerTreeHostImpl->memoryAllocationLimitBytes());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp (128004 => 128005)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2012-09-09 22:49:37 UTC (rev 128004)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp 2012-09-09 23:59:41 UTC (rev 128005)
@@ -549,7 +549,7 @@
}
if (request->contentsTexturesWereDeleted)
- m_layerTreeHost->evictAllContentTextures();
+ m_layerTreeHost->unlinkAllContentTextures();
OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue);
m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimitBytes);
@@ -591,7 +591,7 @@
{
TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
ASSERT(!m_commitCompletionEventOnImplThread);
- ASSERT(isImplThread());
+ ASSERT(isImplThread() && isMainThreadBlocked());
ASSERT(m_schedulerOnImplThread);
ASSERT(m_schedulerOnImplThread->commitPending());
@@ -601,15 +601,20 @@
return;
}
- if (!contentsTexturesWereDeleted && m_layerTreeHostImpl->contentsTexturesPurged()) {
+ if (contentsTexturesWereDeleted) {
+ ASSERT(m_layerTreeHostImpl->contentsTexturesPurged());
+ // We unlinked all textures on the main thread, delete them now.
+ m_layerTreeHost->deleteUnlinkedTextures();
+ // Mark that we can start drawing again when this commit is complete.
+ m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
+ } else if (m_layerTreeHostImpl->contentsTexturesPurged()) {
// We purged the content textures on the impl thread between the time we
// posted the beginFrame task and now, meaning we have a bunch of
// uploads that are now invalid. Clear the uploads (they all go to
// content textures), and kick another commit to fill them again.
queue->clearUploads();
setNeedsCommitOnImplThread();
- } else
- m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
+ }
m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader());
m_commitCompletionEventOnImplThread = completion;