Diff
Modified: trunk/Source/WebKit/ChangeLog (236699 => 236700)
--- trunk/Source/WebKit/ChangeLog 2018-10-01 23:45:59 UTC (rev 236699)
+++ trunk/Source/WebKit/ChangeLog 2018-10-01 23:46:52 UTC (rev 236700)
@@ -1,3 +1,21 @@
+2018-10-01 Chris Dumez <cdu...@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_...@apple.com>
Fix Internal iOS Build after r236690
Modified: trunk/Source/WebKit/SourcesCocoa.txt (236699 => 236700)
--- trunk/Source/WebKit/SourcesCocoa.txt 2018-10-01 23:45:59 UTC (rev 236699)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2018-10-01 23:46:52 UTC (rev 236700)
@@ -330,6 +330,7 @@
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/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
Copied: trunk/Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h (from rev 236699, trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.h) (0 => 236700)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h 2018-10-01 23:46:52 UTC (rev 236700)
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+namespace WebKit {
+
+void installMemoryPressureHandler();
+
+}
Copied: trunk/Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm (from rev 236699, trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm) (0 => 236700)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm 2018-10-01 23:46:52 UTC (rev 236700)
@@ -0,0 +1,54 @@
+/*
+ * 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 "WebMemoryPressureHandlerCocoa.h"
+
+#import "ViewSnapshotStore.h"
+#import "WebProcessPool.h"
+#import <wtf/MemoryPressureHandler.h>
+
+namespace WebKit {
+
+void installMemoryPressureHandler()
+{
+ // FIXME: This should be able to share code with WebCore's MemoryPressureHandler (and be platform independent).
+ // Right now it cannot because WebKit1 and WebKit2 need to be able to coexist in the UI process,
+ // and you can only have one WebCore::MemoryPressureHandler.
+
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitSuppressMemoryPressureHandler"])
+ return;
+
+ auto& memoryPressureHandler = MemoryPressureHandler::singleton();
+ memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous) {
+ ViewSnapshotStore::singleton().discardSnapshotImages();
+
+ for (auto* processPool : WebProcessPool::allProcessPools())
+ processPool->handleMemoryPressureWarning(critical);
+ });
+ memoryPressureHandler.install();
+}
+
+} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (236699 => 236700)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2018-10-01 23:45:59 UTC (rev 236699)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2018-10-01 23:46:52 UTC (rev 236700)
@@ -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 @@
registerUserDefaultsIfNeeded();
registerNotificationObservers();
-#if PLATFORM(IOS)
installMemoryPressureHandler();
-#endif
setLegacyCustomProtocolManagerClient(std::make_unique<LegacyCustomProtocolManagerClient>());
}
Deleted: trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.h (236699 => 236700)
--- trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.h 2018-10-01 23:45:59 UTC (rev 236699)
+++ trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.h 2018-10-01 23:46:52 UTC (rev 236700)
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#if PLATFORM(IOS)
-
-namespace WebKit {
-
-void installMemoryPressureHandler();
-
-}
-
-#endif // PLATFORM(IOS)
Deleted: trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm (236699 => 236700)
--- trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm 2018-10-01 23:45:59 UTC (rev 236699)
+++ trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm 2018-10-01 23:46:52 UTC (rev 236700)
@@ -1,58 +0,0 @@
-/*
- * 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 "WebMemoryPressureHandlerIOS.h"
-
-#if PLATFORM(IOS)
-
-#import "ViewSnapshotStore.h"
-#import "WebProcessPool.h"
-#import <wtf/MemoryPressureHandler.h>
-
-namespace WebKit {
-
-void installMemoryPressureHandler()
-{
- // FIXME: This should be able to share code with WebCore's MemoryPressureHandler (and be platform independent).
- // Right now it cannot because WebKit1 and WebKit2 need to be able to coexist in the UI process,
- // and you can only have one WebCore::MemoryPressureHandler.
-
- if ([[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitSuppressMemoryPressureHandler"])
- return;
-
- auto& memoryPressureHandler = MemoryPressureHandler::singleton();
- memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous) {
- ViewSnapshotStore::singleton().discardSnapshotImages();
-
- for (auto* processPool : WebProcessPool::allProcessPools())
- processPool->handleMemoryPressureWarning(critical);
- });
- memoryPressureHandler.install();
-}
-
-} // namespace WebKit
-
-#endif
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (236699 => 236700)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2018-10-01 23:45:59 UTC (rev 236699)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2018-10-01 23:46:52 UTC (rev 236700)
@@ -575,7 +575,7 @@
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 */; };
@@ -2476,8 +2476,8 @@
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>"; };
@@ -5250,6 +5250,8 @@
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 */,
@@ -5727,8 +5729,6 @@
2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */,
E5BEF6802130C47F00F31111 /* WebDataListSuggestionsDropdownIOS.h */,
E5BEF6812130C47F00F31111 /* WebDataListSuggestionsDropdownIOS.mm */,
- 2D3EF4411917646300034184 /* WebMemoryPressureHandlerIOS.h */,
- 2D3EF4401917646300034184 /* WebMemoryPressureHandlerIOS.mm */,
2DA944AB1884E9BA00ED86DB /* WebPageProxyIOS.mm */,
2DA944AC1884E9BA00ED86DB /* WebProcessProxyIOS.mm */,
0FCB4E3818BBE044000FCFC9 /* WKActionSheet.h */,
@@ -9300,7 +9300,7 @@
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 */,