From b080ac41ab44c4a3c9859f255da7763afff92108 Mon Sep 17 00:00:00 2001 From: "andersca@apple.com" Date: Thu, 16 Feb 2012 00:01:55 +0000 Subject: [PATCH] The TileCache object should be deallocated on the main thread https://bugs.webkit.org/show_bug.cgi?id=78757 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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107852 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 20 ++++++++++++++++++++ Source/WebCore/platform/graphics/ca/mac/TileCache.h | 1 + Source/WebCore/platform/graphics/ca/mac/TileCache.mm | 6 ++++++ .../platform/graphics/ca/mac/WebTileCacheLayer.mm | 13 +++++++++++++ 4 files changed, 40 insertions(+) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index dc63af6..fbf33c2 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,5 +1,25 @@ 2012-02-15 Anders Carlsson + The TileCache object should be deallocated on the main thread + https://bugs.webkit.org/show_bug.cgi?id=78757 + + + 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 + Scrolling Coordinator must be deleted on the main thread https://bugs.webkit.org/show_bug.cgi?id=78756 diff --git a/Source/WebCore/platform/graphics/ca/mac/TileCache.h b/Source/WebCore/platform/graphics/ca/mac/TileCache.h index 77a8800..768b2aa 100644 --- a/Source/WebCore/platform/graphics/ca/mac/TileCache.h +++ b/Source/WebCore/platform/graphics/ca/mac/TileCache.h @@ -49,6 +49,7 @@ class TileCache { public: static PassOwnPtr create(WebTileCacheLayer*, const IntSize& tileSize); + ~TileCache(); void tileCacheLayerBoundsChanged(); diff --git a/Source/WebCore/platform/graphics/ca/mac/TileCache.mm b/Source/WebCore/platform/graphics/ca/mac/TileCache.mm index cdd8183..dda076b 100644 --- a/Source/WebCore/platform/graphics/ca/mac/TileCache.mm +++ b/Source/WebCore/platform/graphics/ca/mac/TileCache.mm @@ -31,6 +31,7 @@ #import "WebLayer.h" #import "WebTileCacheLayer.h" #import "WebTileLayer.h" +#import #import using namespace std; @@ -62,6 +63,11 @@ TileCache::TileCache(WebTileCacheLayer* tileCacheLayer, const IntSize& tileSize) [CATransaction commit]; } +TileCache::~TileCache() +{ + ASSERT(isMainThread()); +} + void TileCache::tileCacheLayerBoundsChanged() { if (m_tiles.isEmpty()) { diff --git a/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm b/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm index c07b5df..d7dc8c9 100644 --- a/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm +++ b/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm @@ -28,6 +28,7 @@ #import "IntRect.h" #import "TileCache.h" +#import using namespace WebCore; @@ -45,6 +46,18 @@ using namespace WebCore; 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]; -- 2.7.4