Title: [271526] trunk/Source
Revision
271526
Author
[email protected]
Date
2021-01-15 10:29:08 -0800 (Fri, 15 Jan 2021)

Log Message

[GPUProcess] Improve the GPUProcess' memory pressure handler
https://bugs.webkit.org/show_bug.cgi?id=220659

Reviewed by Simon Fraser.

Improve the GPUProcess' memory pressure handler to clear things like the IOSurfacePool
and the SubimageCacheWithTimer.

Source/WebCore:

* page/MemoryRelease.cpp:
(WebCore::releaseGraphicsMemory):
(WebCore::platformReleaseGraphicsMemory):
* page/MemoryRelease.h:
* page/cocoa/MemoryReleaseCocoa.mm:
(WebCore::platformReleaseGraphicsMemory):

Source/WebKit:

* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::lowMemoryHandler):
(WebKit::GPUProcess::initializeGPUProcess):
(WebKit::GPUProcess::prepareToSuspend):
* GPUProcess/GPUProcess.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271525 => 271526)


--- trunk/Source/WebCore/ChangeLog	2021-01-15 18:03:24 UTC (rev 271525)
+++ trunk/Source/WebCore/ChangeLog	2021-01-15 18:29:08 UTC (rev 271526)
@@ -1,3 +1,20 @@
+2021-01-15  Chris Dumez  <[email protected]>
+
+        [GPUProcess] Improve the GPUProcess' memory pressure handler
+        https://bugs.webkit.org/show_bug.cgi?id=220659
+
+        Reviewed by Simon Fraser.
+
+        Improve the GPUProcess' memory pressure handler to clear things like the IOSurfacePool
+        and the SubimageCacheWithTimer.
+
+        * page/MemoryRelease.cpp:
+        (WebCore::releaseGraphicsMemory):
+        (WebCore::platformReleaseGraphicsMemory):
+        * page/MemoryRelease.h:
+        * page/cocoa/MemoryReleaseCocoa.mm:
+        (WebCore::platformReleaseGraphicsMemory):
+
 2021-01-15  Antoine Quint  <[email protected]>
 
         Reversed transform animation not applied alongside other transform animations

Modified: trunk/Source/WebCore/page/MemoryRelease.cpp (271525 => 271526)


--- trunk/Source/WebCore/page/MemoryRelease.cpp	2021-01-15 18:03:24 UTC (rev 271525)
+++ trunk/Source/WebCore/page/MemoryRelease.cpp	2021-01-15 18:29:08 UTC (rev 271526)
@@ -161,6 +161,15 @@
 #endif
 }
 
+void releaseGraphicsMemory(Critical critical, Synchronous synchronous)
+{
+    TraceScope scope(MemoryPressureHandlerStart, MemoryPressureHandlerEnd, static_cast<uint64_t>(critical), static_cast<uint64_t>(synchronous));
+
+    platformReleaseGraphicsMemory(critical);
+
+    WTF::releaseFastMallocFreeMemory();
+}
+
 #if !RELEASE_LOG_DISABLED
 static unsigned pageCount()
 {
@@ -213,6 +222,7 @@
 
 #if !PLATFORM(COCOA)
 void platformReleaseMemory(Critical) { }
+void platformReleaseGraphicsMemory(Critical) { }
 void jettisonExpensiveObjectsOnTopLevelNavigation() { }
 void registerMemoryReleaseNotifyCallbacks() { }
 #endif

Modified: trunk/Source/WebCore/page/MemoryRelease.h (271525 => 271526)


--- trunk/Source/WebCore/page/MemoryRelease.h	2021-01-15 18:03:24 UTC (rev 271525)
+++ trunk/Source/WebCore/page/MemoryRelease.h	2021-01-15 18:29:08 UTC (rev 271526)
@@ -34,6 +34,8 @@
 
 WEBCORE_EXPORT void releaseMemory(Critical, Synchronous, MaintainBackForwardCache = MaintainBackForwardCache::No, MaintainMemoryCache = MaintainMemoryCache::No);
 void platformReleaseMemory(Critical);
+WEBCORE_EXPORT void releaseGraphicsMemory(Critical, Synchronous);
+void platformReleaseGraphicsMemory(Critical);
 void jettisonExpensiveObjectsOnTopLevelNavigation();
 WEBCORE_EXPORT void registerMemoryReleaseNotifyCallbacks();
 WEBCORE_EXPORT void logMemoryStatisticsAtTimeOfDeath();

Modified: trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm (271525 => 271526)


--- trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm	2021-01-15 18:03:24 UTC (rev 271525)
+++ trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm	2021-01-15 18:29:08 UTC (rev 271526)
@@ -72,6 +72,15 @@
 #endif
 }
 
+void platformReleaseGraphicsMemory(Critical)
+{
+    IOSurfacePool::sharedPool().discardAllSurfaces();
+
+#if CACHE_SUBIMAGES
+    SubimageCacheWithTimer::clear();
+#endif
+}
+
 void jettisonExpensiveObjectsOnTopLevelNavigation()
 {
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/ChangeLog (271525 => 271526)


--- trunk/Source/WebKit/ChangeLog	2021-01-15 18:03:24 UTC (rev 271525)
+++ trunk/Source/WebKit/ChangeLog	2021-01-15 18:29:08 UTC (rev 271526)
@@ -1,3 +1,19 @@
+2021-01-15  Chris Dumez  <[email protected]>
+
+        [GPUProcess] Improve the GPUProcess' memory pressure handler
+        https://bugs.webkit.org/show_bug.cgi?id=220659
+
+        Reviewed by Simon Fraser.
+
+        Improve the GPUProcess' memory pressure handler to clear things like the IOSurfacePool
+        and the SubimageCacheWithTimer.
+
+        * GPUProcess/GPUProcess.cpp:
+        (WebKit::GPUProcess::lowMemoryHandler):
+        (WebKit::GPUProcess::initializeGPUProcess):
+        (WebKit::GPUProcess::prepareToSuspend):
+        * GPUProcess/GPUProcess.h:
+
 2021-01-15  Philippe Normand  <[email protected]>
 
         [GStreamer] UI<->WebPocess IPC needed for enumerateDevices support

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (271525 => 271526)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-01-15 18:03:24 UTC (rev 271525)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2021-01-15 18:29:08 UTC (rev 271526)
@@ -41,6 +41,7 @@
 #include "WebProcessPoolMessages.h"
 #include <WebCore/DeprecatedGlobalSettings.h>
 #include <WebCore/LogInitialization.h>
+#include <WebCore/MemoryRelease.h>
 #include <WebCore/NowPlayingManager.h>
 #include <WebCore/RuntimeApplicationChecks.h>
 #include <wtf/Algorithms.h>
@@ -114,9 +115,9 @@
     return m_webProcessConnections.isEmpty();
 }
 
-void GPUProcess::lowMemoryHandler(Critical critical)
+void GPUProcess::lowMemoryHandler(Critical critical, Synchronous synchronous)
 {
-    WTF::releaseFastMallocFreeMemory();
+    WebCore::releaseGraphicsMemory(critical, synchronous);
 }
 
 void GPUProcess::initializeGPUProcess(GPUProcessCreationParameters&& parameters)
@@ -125,8 +126,8 @@
     AtomString::init();
 
     auto& memoryPressureHandler = MemoryPressureHandler::singleton();
-    memoryPressureHandler.setLowMemoryHandler([this] (Critical critical, Synchronous) {
-        lowMemoryHandler(critical);
+    memoryPressureHandler.setLowMemoryHandler([this] (Critical critical, Synchronous synchronous) {
+        lowMemoryHandler(critical, synchronous);
     });
     memoryPressureHandler.install();
 
@@ -165,7 +166,7 @@
 {
     RELEASE_LOG(ProcessSuspension, "%p - GPUProcess::prepareToSuspend(), isSuspensionImminent: %d", this, isSuspensionImminent);
 
-    lowMemoryHandler(Critical::Yes);
+    lowMemoryHandler(Critical::Yes, Synchronous::Yes);
     completionHandler();
 }
 

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.h (271525 => 271526)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.h	2021-01-15 18:03:24 UTC (rev 271525)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.h	2021-01-15 18:29:08 UTC (rev 271526)
@@ -88,7 +88,7 @@
 #endif
 
 private:
-    void lowMemoryHandler(Critical);
+    void lowMemoryHandler(Critical, Synchronous);
 
     // AuxiliaryProcess
     void initializeProcess(const AuxiliaryProcessInitializationParameters&) override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to