Before tracking Document leaks, clear all caches
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 18:16:37 +0000 (18:16 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 18:16:37 +0000 (18:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189459

Reviewed by Sam Weinig.
Source/WebKit:

It's not enough to clear the page and memory caches; font caches can reference Documents (for SVG fonts),
so just call WebCore::releaseMemory(), which empties caches including the page and memory caches, and
does the GC that we need to happen.

* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleReleaseMemory):
(WKBundleClearPageCache): Deleted.
(WKBundleClearMemoryCache): Deleted.
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:

Tools:

It's not enough to clear the page and memory caches; font caches can reference Documents (for SVG fonts),
so just call WebCore::releaseMemory(), which empties caches including the page and memory caches, and
does the GC that we need to happen.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):

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

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

index 5ba509d..3595a7f 100644 (file)
@@ -1,3 +1,20 @@
+2018-09-10  Simon Fraser  <simon.fraser@apple.com>
+
+        Before tracking Document leaks, clear all caches
+        https://bugs.webkit.org/show_bug.cgi?id=189459
+
+        Reviewed by Sam Weinig.
+        
+        It's not enough to clear the page and memory caches; font caches can reference Documents (for SVG fonts),
+        so just call WebCore::releaseMemory(), which empties caches including the page and memory caches, and
+        does the GC that we need to happen.
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleReleaseMemory):
+        (WKBundleClearPageCache): Deleted.
+        (WKBundleClearMemoryCache): Deleted.
+        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
+
 2018-09-07  Matt Rajca  <mrajca@apple.com>
 
         Touch Bar displays an active PIP button for audio elements (and it doesn't do anything)
index 1a32c60..7f74f7e 100644 (file)
@@ -44,8 +44,7 @@
 #include "WebPage.h"
 #include "WebPageGroupProxy.h"
 #include <WebCore/DatabaseTracker.h>
-#include <WebCore/MemoryCache.h>
-#include <WebCore/PageCache.h>
+#include <WebCore/MemoryRelease.h>
 #include <WebCore/ResourceLoadObserver.h>
 #include <WebCore/ServiceWorkerThreadProxy.h>
 
@@ -260,14 +259,9 @@ void WKBundleSetDatabaseQuota(WKBundleRef bundleRef, uint64_t quota)
     DatabaseTracker::singleton().setQuota(*SecurityOriginData::fromDatabaseIdentifier("file__0"), quota);
 }
 
-void WKBundleClearPageCache(WKBundleRef bundle)
+void WKBundleReleaseMemory(WKBundleRef)
 {
-    PageCache::singleton().pruneToSizeNow(0, PruningReason::MemoryPressure);
-}
-
-void WKBundleClearMemoryCache(WKBundleRef bundle)
-{
-    MemoryCache::singleton().evictResources();
+    WebCore::releaseMemory(WTF::Critical::Yes, WTF::Synchronous::Yes);
 }
 
 WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSContextRef context, JSValueRef data)
index 3949f77..ecf329d 100644 (file)
@@ -98,8 +98,7 @@ WK_EXPORT void WKBundleResourceLoadStatisticsNotifyObserver(WKBundleRef);
 
 WK_EXPORT void WKBundleExtendClassesForParameterCoder(WKBundleRef bundle, WKArrayRef classes);
 
-WK_EXPORT void WKBundleClearPageCache(WKBundleRef bundle);
-WK_EXPORT void WKBundleClearMemoryCache(WKBundleRef bundle);
+WK_EXPORT void WKBundleReleaseMemory(WKBundleRef);
 
 #ifdef __cplusplus
 }
index 321cefe..fbd43f9 100644 (file)
@@ -1,3 +1,17 @@
+2018-09-10  Simon Fraser  <simon.fraser@apple.com>
+
+        Before tracking Document leaks, clear all caches
+        https://bugs.webkit.org/show_bug.cgi?id=189459
+
+        Reviewed by Sam Weinig.
+
+        It's not enough to clear the page and memory caches; font caches can reference Documents (for SVG fonts),
+        so just call WebCore::releaseMemory(), which empties caches including the page and memory caches, and
+        does the GC that we need to happen.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+
 2018-09-07  Matt Rajca  <mrajca@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=189433
index 6113b76..72a057f 100644 (file)
@@ -271,9 +271,7 @@ void InjectedBundle::didReceiveMessageToPage(WKBundlePageRef page, WKStringRef m
     }
 
     if (WKStringIsEqualToUTF8CString(messageName, "CheckForWorldLeaks")) {
-        WKBundleClearPageCache(m_bundle);
-        WKBundleClearMemoryCache(m_bundle);
-        WKBundleGarbageCollectJavaScriptObjects(m_bundle);
+        WKBundleReleaseMemory(m_bundle);
 
         WKRetain(page); // Balanced by the release in postGCTask.
         WKBundlePagePostTask(page, postGCTask, (void*)page);