Title: [107852] trunk/Source/WebCore
Revision
107852
Author
[email protected]
Date
2012-02-15 16:01:55 -0800 (Wed, 15 Feb 2012)

Log Message

The TileCache object should be deallocated on the main thread
https://bugs.webkit.org/show_bug.cgi?id=78757
<rdar://problem/10866161>

Reviewed by Sam Weinig.

Since the WebTileCacheLayer can be deleted on the scrolling thread, we need to make sure that the underlying
TileCache object is actually destroyed on the main thread.

* platform/graphics/ca/mac/TileCache.h:
* platform/graphics/ca/mac/TileCache.mm:
(WebCore::TileCache::~TileCache):
Assert that this object is being destroyed on the main thread.

* platform/graphics/ca/mac/WebTileCacheLayer.mm:
(-[WebTileCacheLayer dealloc]):
If dealloc is being called from a non-main thread, make sure to delete the tile cache object on the main thread.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107851 => 107852)


--- trunk/Source/WebCore/ChangeLog	2012-02-15 23:58:55 UTC (rev 107851)
+++ trunk/Source/WebCore/ChangeLog	2012-02-16 00:01:55 UTC (rev 107852)
@@ -1,5 +1,25 @@
 2012-02-15  Anders Carlsson  <[email protected]>
 
+        The TileCache object should be deallocated on the main thread
+        https://bugs.webkit.org/show_bug.cgi?id=78757
+        <rdar://problem/10866161>
+
+        Reviewed by Sam Weinig.
+
+        Since the WebTileCacheLayer can be deleted on the scrolling thread, we need to make sure that the underlying
+        TileCache object is actually destroyed on the main thread.
+
+        * platform/graphics/ca/mac/TileCache.h:
+        * platform/graphics/ca/mac/TileCache.mm:
+        (WebCore::TileCache::~TileCache):
+        Assert that this object is being destroyed on the main thread.
+
+        * platform/graphics/ca/mac/WebTileCacheLayer.mm:
+        (-[WebTileCacheLayer dealloc]):
+        If dealloc is being called from a non-main thread, make sure to delete the tile cache object on the main thread.
+
+2012-02-15  Anders Carlsson  <[email protected]>
+
         Scrolling Coordinator must be deleted on the main thread
         https://bugs.webkit.org/show_bug.cgi?id=78756
         <rdar://problem/10866167>

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h (107851 => 107852)


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-02-15 23:58:55 UTC (rev 107851)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-02-16 00:01:55 UTC (rev 107852)
@@ -49,6 +49,7 @@
 
 public:
     static PassOwnPtr<TileCache> create(WebTileCacheLayer*, const IntSize& tileSize);
+    ~TileCache();
 
     void tileCacheLayerBoundsChanged();
 

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm (107851 => 107852)


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-02-15 23:58:55 UTC (rev 107851)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-02-16 00:01:55 UTC (rev 107852)
@@ -31,6 +31,7 @@
 #import "WebLayer.h"
 #import "WebTileCacheLayer.h"
 #import "WebTileLayer.h"
+#import <wtf/MainThread.h>
 #import <utility>
 
 using namespace std;
@@ -62,6 +63,11 @@
     [CATransaction commit];
 }
 
+TileCache::~TileCache()
+{
+    ASSERT(isMainThread());
+}
+
 void TileCache::tileCacheLayerBoundsChanged()
 {
     if (m_tiles.isEmpty()) {

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


--- trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm	2012-02-15 23:58:55 UTC (rev 107851)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm	2012-02-16 00:01:55 UTC (rev 107852)
@@ -28,6 +28,7 @@
 
 #import "IntRect.h"
 #import "TileCache.h"
+#import <wtf/MainThread.h>
 
 using namespace WebCore;
 
@@ -45,6 +46,18 @@
     return self;
 }
 
+- (void)dealloc
+{
+    if (!isMainThread()) {
+        TileCache* tileCache = _tileCache.leakPtr();
+        dispatch_async(dispatch_get_main_queue(), ^{
+            delete tileCache;
+        });
+    }
+
+    [super dealloc];
+}
+
 - (void)setBounds:(CGRect)bounds
 {
     [super setBounds:bounds];
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to