[iOS] Purge GraphicsServices font cache on memory warning.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jan 2017 00:47:37 +0000 (00:47 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jan 2017 00:47:37 +0000 (00:47 +0000)
<https://webkit.org/b/154343>

Reviewed by Antti Koivisto.

Source/WebCore:

The GS font cache was retaining CSS fonts after we stopped using them.
Call SPI to release them on memory pressure. This is one of multiple
steps necessary to actually free the fonts.

* Configurations/WebCore.xcconfig:
* page/cocoa/MemoryReleaseCocoa.mm:
(WebCore::platformReleaseMemory):
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
* platform/spi/ios/GraphicsServicesSPI.h:

WebKitLibraries:

* WebKitPrivateFrameworkStubs/iOS/10/GraphicsServices.framework/GraphicsServices.tbd: Add SPI.

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

Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCore.xcconfig
Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm
Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm
Source/WebCore/platform/spi/ios/GraphicsServicesSPI.h
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/GraphicsServices.framework/GraphicsServices.tbd

index 9bb5f2ed9a8b90d6e5ae06207fc955dc42f3a673..175045ada98b0466cb4c9294e7382c570afa8f0b 100644 (file)
@@ -1,3 +1,20 @@
+2017-01-12  Andreas Kling  <akling@apple.com>
+
+        [iOS] Purge GraphicsServices font cache on memory warning.
+        <https://webkit.org/b/154343>
+
+        Reviewed by Antti Koivisto.
+
+        The GS font cache was retaining CSS fonts after we stopped using them.
+        Call SPI to release them on memory pressure. This is one of multiple
+        steps necessary to actually free the fonts.
+
+        * Configurations/WebCore.xcconfig:
+        * page/cocoa/MemoryReleaseCocoa.mm:
+        (WebCore::platformReleaseMemory):
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        * platform/spi/ios/GraphicsServicesSPI.h:
+
 2017-01-12  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed EFL/GTK build fix after r210684.
index c488f804ffb00674bbe98a1d2856b360dac0c8a3..6b19acf645cd8996d603b4a00144eab86dc8b437 100644 (file)
@@ -69,7 +69,7 @@ WK_IOS_BINCOMPAT_LDFLAGS_V10_0 = $(WK_IOS_BINCOMPAT_LDFLAGS_V9_3);
 OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_PLATFORM)
 OTHER_LDFLAGS_BASE = -lsqlite3 -lobjc -lANGLE;
 OTHER_LDFLAGS_BASE_ios = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework MobileCoreServices -framework OpenGLES -lMobileGestalt $(WK_IOS_BINCOMPAT_LDFLAGS);
-OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = $(OTHER_LDFLAGS_BASE_ios) -framework IOSurface;
+OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = $(OTHER_LDFLAGS_BASE_ios) -framework IOSurface -framework GraphicsServices;
 OTHER_LDFLAGS_PLATFORM[sdk=iphonesimulator*] = $(OTHER_LDFLAGS_BASE_ios);
 OTHER_LDFLAGS_PLATFORM[sdk=macosx*] = $(OTHER_LDFLAGS_BASE) -sub_library libobjc -umbrella WebKit -allowable_client WebCoreTestSupport -allowable_client WebKit2 -allowable_client WebKitLegacy -framework ApplicationServices -framework AudioUnit -framework Carbon -framework Cocoa -framework CoreAudio -framework DataDetectorsCore -framework IOSurface -framework OpenGL -framework SystemConfiguration;
 
index 8d40f24077eba07498ac254950545d56bd858de5..44eccee2ac36d8e8293a8d256b43efca5a2bddc1 100644 (file)
@@ -27,6 +27,7 @@
 #include "MemoryRelease.h"
 
 #import "GCController.h"
+#import "GraphicsServicesSPI.h"
 #import "IOSurfacePool.h"
 #import "LayerPool.h"
 #import <notify.h>
@@ -37,6 +38,10 @@ namespace WebCore {
 
 void platformReleaseMemory(Critical)
 {
+#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
+    GSFontPurgeFontCache();
+#endif
+
     _sqlite3_purgeEligiblePagerCacheMemory();
 
     for (auto& pool : LayerPool::allLayerPools())
index 3eec7c7ac72a8e70ff6965abb5f4788d797ee6fa..83ff42b788a09fc184843a2fb7fdbef7152c4e75 100644 (file)
@@ -34,6 +34,7 @@
 #import <wtf/CurrentTime.h>
 
 #if PLATFORM(IOS)
+#import "GraphicsServicesSPI.h"
 #import "SystemMemory.h"
 #import "WebCoreThread.h"
 #endif
index fca1bdd92edad894d2fb4706bbbb6f3bcfa0ac11..3453ddf5b74ffbfc75d22c3009dc99e54c12375b 100644 (file)
@@ -41,6 +41,7 @@ WTF_EXTERN_C_BEGIN
 void GSInitialize(void);
 uint64_t GSCurrentEventTimestamp(void);
 CFStringRef GSSystemRootDirectory(void);
+void GSFontPurgeFontCache(void);
 
 WTF_EXTERN_C_END
 
index cc7972bf9616db2670b1a03a91387a817d22dd6f..14b0e61c2bba3f9577a40ed92730daa1b79ee781 100644 (file)
@@ -1,3 +1,12 @@
+2017-01-12  Andreas Kling  <akling@apple.com>
+
+        [iOS] Purge GraphicsServices font cache on memory warning.
+        <https://webkit.org/b/154343>
+
+        Reviewed by Antti Koivisto.
+
+        * WebKitPrivateFrameworkStubs/iOS/10/GraphicsServices.framework/GraphicsServices.tbd: Add SPI.
+
 2017-01-01  Jeff Miller  <jeffm@apple.com>
 
         Update user-visible copyright strings to include 2017
index 6b83a1e48e74757ed9a6a71eaabffbbb5623942d..56d36afe21b2b7958c2ebb375f29f2833613e8d0 100644 (file)
@@ -11,6 +11,7 @@ exports:
       - arm64
     symbols:
       - _GSCurrentEventTimestamp
+      - _GSFontPurgeFontCache
       - _GSInitialize
       - _GSSystemRootDirectory
 install-name: /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices