[iOS WebKit2] IOSurfacePool should force CA to actually garbage collect surfaces.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Apr 2014 18:47:15 +0000 (18:47 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Apr 2014 18:47:15 +0000 (18:47 +0000)
<https://webkit.org/b/132065>
<rdar://problem/16110687>

Add a platformGarbageCollectNow() helper function to IOSurfacePool that
triggers a sweep of the IOSurfaces. Call this from collectionTimerFired()
and discardAllSurfaces().

This lets us drop all otherwise-unused 420f surfaces on memory pressure.

Reviewed by Tim Horton.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::collectionTimerFired):
(WebCore::IOSurfacePool::discardAllSurfaces):
* platform/graphics/cg/IOSurfacePool.h:
* platform/graphics/cocoa/IOSurfacePoolCocoa.mm: Added.
(WebCore::IOSurfacePool::platformGarbageCollectNow):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167717 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp
Source/WebCore/platform/graphics/cg/IOSurfacePool.h
Source/WebCore/platform/graphics/cocoa/IOSurfacePoolCocoa.mm [new file with mode: 0644]

index 240c03d..74943fe 100644 (file)
@@ -1,3 +1,25 @@
+2014-04-23  Andreas Kling  <akling@apple.com>
+
+        [iOS WebKit2] IOSurfacePool should force CA to actually garbage collect surfaces.
+        <https://webkit.org/b/132065>
+        <rdar://problem/16110687>
+
+        Add a platformGarbageCollectNow() helper function to IOSurfacePool that
+        triggers a sweep of the IOSurfaces. Call this from collectionTimerFired()
+        and discardAllSurfaces().
+
+        This lets us drop all otherwise-unused 420f surfaces on memory pressure.
+
+        Reviewed by Tim Horton.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        (WebCore::IOSurfacePool::collectionTimerFired):
+        (WebCore::IOSurfacePool::discardAllSurfaces):
+        * platform/graphics/cg/IOSurfacePool.h:
+        * platform/graphics/cocoa/IOSurfacePoolCocoa.mm: Added.
+        (WebCore::IOSurfacePool::platformGarbageCollectNow):
+
 2014-04-23  Morten Stenshorne  <mstensho@opera.com>
 
         REGRESSION (Safari 6 - ToT): Incorrectly assumes that RenderStyle data can be shared
index 63658fe..acf7733 100644 (file)
                AD726FED16DA1171003A4E6D /* JSCSSStyleDeclarationCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD726FEE16DA11BC003A4E6D /* JSStyleSheetCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD726FEF16DA11F5003A4E6D /* JSCSSRuleCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               AD9FF6E11908391D003B61E0 /* IOSurfacePoolCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */; };
                ADB6B29818FB90240081963E /* MemoryPressureHandlerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */; };
                ADDF1AD71257CD9A0003A759 /* RenderSVGPath.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDF1AD51257CD9A0003A759 /* RenderSVGPath.h */; };
                ADEC78F818EE5308001315C2 /* JSElementCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = ADEC78F718EE5308001315C2 /* JSElementCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSRuleCustom.h; sourceTree = "<group>"; };
                AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleDeclarationCustom.h; sourceTree = "<group>"; };
                AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStyleSheetCustom.h; sourceTree = "<group>"; };
+               AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IOSurfacePoolCocoa.mm; sourceTree = "<group>"; };
                ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandlerCocoa.mm; sourceTree = "<group>"; };
                ADDF1AD41257CD9A0003A759 /* RenderSVGPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGPath.cpp; sourceTree = "<group>"; };
                ADDF1AD51257CD9A0003A759 /* RenderSVGPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGPath.h; sourceTree = "<group>"; };
                                2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
                                1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */,
                                1C21E57B183ED1FF001C289D /* IOSurfacePool.h */,
+                               AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */,
                                B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
                        );
                        path = cocoa;
                                E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */,
                                86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */,
                                8AF4E55511DC5A36000ED3DE /* PerformanceNavigation.cpp in Sources */,
+                               AD9FF6E11908391D003B61E0 /* IOSurfacePoolCocoa.mm in Sources */,
                                86512EDE154A2AEF00A90426 /* PerformanceResourceTiming.cpp in Sources */,
                                0F43C85D189E10CF00019AE2 /* PerformanceTiming.cpp in Sources */,
                                FD581FB41520F93B003A7A75 /* PeriodicWave.cpp in Sources */,
index 72d79b3..9e8279e 100644 (file)
@@ -288,6 +288,7 @@ void IOSurfacePool::collectionTimerFired(Timer<IOSurfacePool>&)
     if (!m_inUseSurfaces.size() && markedAllSurfaces)
         m_collectionTimer.stop();
 
+    platformGarbageCollectNow();
     DUMP_POOL_STATISTICS();
 }
 
@@ -306,6 +307,7 @@ void IOSurfacePool::discardAllSurfaces()
     m_inUseSurfaces.clear();
     m_sizesInPruneOrder.clear();
     m_collectionTimer.stop();
+    platformGarbageCollectNow();
 }
 
 void IOSurfacePool::showPoolStatistics()
index 5f80988..c5073a7 100644 (file)
@@ -91,6 +91,8 @@ private:
     void collectInUseSurfaces();
     bool markOlderSurfacesPurgeable();
 
+    void platformGarbageCollectNow();
+
     Timer<IOSurfacePool> m_collectionTimer;
     CachedSurfaceMap m_cachedSurfaces;
     CachedSurfaceQueue m_inUseSurfaces;
diff --git a/Source/WebCore/platform/graphics/cocoa/IOSurfacePoolCocoa.mm b/Source/WebCore/platform/graphics/cocoa/IOSurfacePoolCocoa.mm
new file mode 100644 (file)
index 0000000..4ad5d2e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "IOSurfacePool.h"
+
+#if USE(IOSURFACE)
+
+#include <QuartzCore/QuartzCore.h>
+
+namespace WebCore {
+
+void IOSurfacePool::platformGarbageCollectNow()
+{
+    [CATransaction begin];
+    [CATransaction commit];
+}
+
+}
+
+#endif // USE(IOSURFACE)