[Mac] The UIProcess should listen to memory pressure signals
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Oct 2018 23:46:52 +0000 (23:46 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Oct 2018 23:46:52 +0000 (23:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190166

Reviewed by Simon Fraser.

The UIProcess should listen to memory pressure signals on Mac in order to free memory, similarly to what we already
do on iOS. The memory pressure handler currently discards view snapshots and prewarmed processes.

* SourcesCocoa.txt:
* UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h: Renamed from Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.h.
* UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm: Renamed from Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm.
(WebKit::installMemoryPressureHandler):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize):
* WebKit.xcodeproj/project.pbxproj:

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

Source/WebKit/ChangeLog
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h [moved from Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.h with 97% similarity]
Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm [moved from Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm with 97% similarity]
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj

index f9bd229..3fbfe38 100644 (file)
@@ -1,3 +1,21 @@
+2018-10-01  Chris Dumez  <cdumez@apple.com>
+
+        [Mac] The UIProcess should listen to memory pressure signals
+        https://bugs.webkit.org/show_bug.cgi?id=190166
+
+        Reviewed by Simon Fraser.
+
+        The UIProcess should listen to memory pressure signals on Mac in order to free memory, similarly to what we already
+        do on iOS. The memory pressure handler currently discards view snapshots and prewarmed processes.
+
+        * SourcesCocoa.txt:
+        * UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h: Renamed from Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.h.
+        * UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm: Renamed from Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm.
+        (WebKit::installMemoryPressureHandler):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitialize):
+        * WebKit.xcodeproj/project.pbxproj:
+
 2018-10-01  Sihui Liu  <sihui_liu@apple.com>
 
         Fix Internal iOS Build after r236690
index 76e433a..644dca6 100644 (file)
@@ -330,6 +330,7 @@ UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
 UIProcess/Cocoa/VersionChecks.mm
 UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
 UIProcess/Cocoa/ViewGestureController.cpp
+UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm
 UIProcess/Cocoa/WebPageProxyCocoa.mm
 UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
 UIProcess/Cocoa/WebProcessPoolCocoa.mm
@@ -377,7 +378,6 @@ UIProcess/ios/ResourceLoadStatisticsPersistentStorageIOS.mm
 UIProcess/ios/SmartMagnificationController.mm
 UIProcess/ios/TextCheckerIOS.mm
 UIProcess/ios/ViewGestureControllerIOS.mm
-UIProcess/ios/WebMemoryPressureHandlerIOS.mm
 UIProcess/ios/WebPageProxyIOS.mm
 UIProcess/ios/WebProcessProxyIOS.mm
 UIProcess/ios/WKActionSheet.mm
@@ -24,9 +24,7 @@
  */
 
 #import "config.h"
-#import "WebMemoryPressureHandlerIOS.h"
-
-#if PLATFORM(IOS)
+#import "WebMemoryPressureHandlerCocoa.h"
 
 #import "ViewSnapshotStore.h"
 #import "WebProcessPool.h"
@@ -54,5 +52,3 @@ void installMemoryPressureHandler()
 }
 
 } // namespace WebKit
-
-#endif
index f22a21a..e265b62 100644 (file)
@@ -36,6 +36,7 @@
 #import "TextChecker.h"
 #import "VersionChecks.h"
 #import "WKBrowsingContextControllerInternal.h"
+#import "WebMemoryPressureHandlerCocoa.h"
 #import "WebPageGroup.h"
 #import "WebPreferencesKeys.h"
 #import "WebProcessCreationParameters.h"
@@ -54,9 +55,7 @@
 #import <wtf/ProcessPrivilege.h>
 #import <wtf/spi/darwin/dyldSPI.h>
 
-#if PLATFORM(IOS)
-#import "WebMemoryPressureHandlerIOS.h"
-#else
+#if PLATFORM(MAC)
 #import <QuartzCore/CARemoteLayerServer.h>
 #endif
 
@@ -132,9 +131,7 @@ void WebProcessPool::platformInitialize()
     registerUserDefaultsIfNeeded();
     registerNotificationObservers();
 
-#if PLATFORM(IOS)
     installMemoryPressureHandler();
-#endif
 
     setLegacyCustomProtocolManagerClient(std::make_unique<LegacyCustomProtocolManagerClient>());
 }
index d4bcc6d..2c8aaed 100644 (file)
                2D3A65DF1A7C3A7D00CAC637 /* WKNavigationResponseRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A65DD1A7C3A7D00CAC637 /* WKNavigationResponseRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D3A65E31A7C3A9300CAC637 /* WKNavigationRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A65E11A7C3A9300CAC637 /* WKNavigationRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2D3A65E71A7C3AA700CAC637 /* WKFrameInfoRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A65E51A7C3AA700CAC637 /* WKFrameInfoRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               2D3EF4431917646300034184 /* WebMemoryPressureHandlerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3EF4411917646300034184 /* WebMemoryPressureHandlerIOS.h */; };
+               2D3EF4431917646300034184 /* WebMemoryPressureHandlerCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3EF4411917646300034184 /* WebMemoryPressureHandlerCocoa.h */; };
                2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */; };
                2D4AF0892044C3C4006C8817 /* FrontBoardServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D4AF0882044C3C4006C8817 /* FrontBoardServicesSPI.h */; };
                2D4D2C811DF60BF3002EB10C /* InteractionInformationRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D4D2C7F1DF60BF3002EB10C /* InteractionInformationRequest.h */; };
                2D3A65E11A7C3A9300CAC637 /* WKNavigationRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationRef.h; sourceTree = "<group>"; };
                2D3A65E41A7C3AA700CAC637 /* WKFrameInfoRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKFrameInfoRef.cpp; sourceTree = "<group>"; };
                2D3A65E51A7C3AA700CAC637 /* WKFrameInfoRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFrameInfoRef.h; sourceTree = "<group>"; };
-               2D3EF4401917646300034184 /* WebMemoryPressureHandlerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebMemoryPressureHandlerIOS.mm; path = ios/WebMemoryPressureHandlerIOS.mm; sourceTree = "<group>"; };
-               2D3EF4411917646300034184 /* WebMemoryPressureHandlerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebMemoryPressureHandlerIOS.h; path = ios/WebMemoryPressureHandlerIOS.h; sourceTree = "<group>"; };
+               2D3EF4401917646300034184 /* WebMemoryPressureHandlerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebMemoryPressureHandlerCocoa.mm; sourceTree = "<group>"; };
+               2D3EF4411917646300034184 /* WebMemoryPressureHandlerCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebMemoryPressureHandlerCocoa.h; sourceTree = "<group>"; };
                2D429BFA1721E2BA00EC681F /* PDFPluginPasswordField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPluginPasswordField.h; path = PDF/PDFPluginPasswordField.h; sourceTree = "<group>"; };
                2D429BFB1721E2BA00EC681F /* PDFPluginPasswordField.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginPasswordField.mm; path = PDF/PDFPluginPasswordField.mm; sourceTree = "<group>"; };
                2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerBackingStore.mm; sourceTree = "<group>"; };
                                2DAF4FFA1B636181006013D6 /* ViewGestureController.cpp */,
                                2D125C5C1857EA05003BA3CB /* ViewGestureController.h */,
                                2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */,
+                               2D3EF4411917646300034184 /* WebMemoryPressureHandlerCocoa.h */,
+                               2D3EF4401917646300034184 /* WebMemoryPressureHandlerCocoa.mm */,
                                1AC0273E196622D600C12B75 /* WebPageProxyCocoa.mm */,
                                7C4694CB1A4B510A00AD5845 /* WebPasteboardProxyCocoa.mm */,
                                7CE4D2151A49148400C7F152 /* WebProcessPoolCocoa.mm */,
                                2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */,
                                E5BEF6802130C47F00F31111 /* WebDataListSuggestionsDropdownIOS.h */,
                                E5BEF6812130C47F00F31111 /* WebDataListSuggestionsDropdownIOS.mm */,
-                               2D3EF4411917646300034184 /* WebMemoryPressureHandlerIOS.h */,
-                               2D3EF4401917646300034184 /* WebMemoryPressureHandlerIOS.mm */,
                                2DA944AB1884E9BA00ED86DB /* WebPageProxyIOS.mm */,
                                2DA944AC1884E9BA00ED86DB /* WebProcessProxyIOS.mm */,
                                0FCB4E3818BBE044000FCFC9 /* WKActionSheet.h */,
                                C98C48A61B6FD4C300145103 /* WebMediaSessionFocusManager.h in Headers */,
                                C9C1833C1B74026D007036A7 /* WebMediaSessionFocusManagerClient.h in Headers */,
                                C9CD43981B4B001D00239E33 /* WebMediaSessionMetadata.h in Headers */,
-                               2D3EF4431917646300034184 /* WebMemoryPressureHandlerIOS.h in Headers */,
+                               2D3EF4431917646300034184 /* WebMemoryPressureHandlerCocoa.h in Headers */,
                                909854ED12BC4E18000AD080 /* WebMemorySampler.h in Headers */,
                                513FFB91201459C6002596EA /* WebMessagePortChannelProvider.h in Headers */,
                                BCF69F9A1176CED600471A52 /* WebNavigationDataStore.h in Headers */,