Title: [115376] trunk/Source/WebCore
Revision
115376
Author
[email protected]
Date
2012-04-26 15:03:37 -0700 (Thu, 26 Apr 2012)

Log Message

A TileCache should never outlive its WebTileCacheLayer
https://bugs.webkit.org/show_bug.cgi?id=85008
<rdar://problem/11141172>

Reviewed by Andreas Kling.

Since WebTileCacheLayer objects can be destroyed on the scrolling thread, make sure to delete the TileCache layer
when the PlatformCALayer is destroyed. This fixes a crash when the tile revalidation timer fires after the WebTileCacheLayer has
been destroyed, but before the TileCache itself has been destroyed.

* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayer::~PlatformCALayer):
* platform/graphics/ca/mac/WebTileCacheLayer.h:
* platform/graphics/ca/mac/WebTileCacheLayer.mm:
(-[WebTileCacheLayer dealloc]):
(-[WebTileCacheLayer invalidate]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (115375 => 115376)


--- trunk/Source/WebCore/ChangeLog	2012-04-26 21:56:23 UTC (rev 115375)
+++ trunk/Source/WebCore/ChangeLog	2012-04-26 22:03:37 UTC (rev 115376)
@@ -1,3 +1,22 @@
+2012-04-26  Anders Carlsson  <[email protected]>
+
+        A TileCache should never outlive its WebTileCacheLayer
+        https://bugs.webkit.org/show_bug.cgi?id=85008
+        <rdar://problem/11141172>
+
+        Reviewed by Andreas Kling.
+
+        Since WebTileCacheLayer objects can be destroyed on the scrolling thread, make sure to delete the TileCache layer
+        when the PlatformCALayer is destroyed. This fixes a crash when the tile revalidation timer fires after the WebTileCacheLayer has
+        been destroyed, but before the TileCache itself has been destroyed.
+
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (PlatformCALayer::~PlatformCALayer):
+        * platform/graphics/ca/mac/WebTileCacheLayer.h:
+        * platform/graphics/ca/mac/WebTileCacheLayer.mm:
+        (-[WebTileCacheLayer dealloc]):
+        (-[WebTileCacheLayer invalidate]):
+
 2012-04-26  Benjamin Poulain  <[email protected]>
 
         Use String instead of RefPtr<StringImpl> for the cache of ObjcClass

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (115375 => 115376)


--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm	2012-04-26 21:56:23 UTC (rev 115375)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm	2012-04-26 22:03:37 UTC (rev 115376)
@@ -239,7 +239,10 @@
     setOwner(0);
     
     // Remove the owner pointer from the delegate in case there is a pending animationStarted event.
-    [static_cast<WebAnimationDelegate*>(m_delegate.get()) setOwner:nil];        
+    [static_cast<WebAnimationDelegate*>(m_delegate.get()) setOwner:nil];
+
+    if (m_layerType == LayerTypeTileCacheLayer)
+        [static_cast<WebTileCacheLayer *>(m_layer.get()) invalidate];
 }
 
 PlatformCALayer* PlatformCALayer::platformCALayer(void* platformLayer)

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.h (115375 => 115376)


--- trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.h	2012-04-26 21:56:23 UTC (rev 115375)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.h	2012-04-26 22:03:37 UTC (rev 115376)
@@ -38,5 +38,6 @@
 
 - (CALayer *)tileContainerLayer;
 - (WebCore::TiledBacking*)tiledBacking;
+- (void)invalidate;
 
 @end

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm (115375 => 115376)


--- trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm	2012-04-26 21:56:23 UTC (rev 115375)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm	2012-04-26 22:03:37 UTC (rev 115376)
@@ -48,12 +48,7 @@
 
 - (void)dealloc
 {
-    if (!isMainThread()) {
-        TileCache* tileCache = _tileCache.leakPtr();
-        dispatch_async(dispatch_get_main_queue(), ^{
-            delete tileCache;
-        });
-    }
+    ASSERT(!_tileCache);
 
     [super dealloc];
 }
@@ -116,6 +111,13 @@
     return _tileCache.get();
 }
 
+- (void)invalidate
+{
+    ASSERT(isMainThread());
+    ASSERT(_tileCache);
+    _tileCache = nullptr;
+}
+
 - (void)setBorderColor:(CGColorRef)borderColor
 {
     _tileCache->setTileDebugBorderColor(borderColor);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to