Diff
Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (241312 => 241313)
--- branches/safari-607-branch/Source/WebKit/ChangeLog 2019-02-12 20:44:58 UTC (rev 241312)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog 2019-02-12 21:13:44 UTC (rev 241313)
@@ -1,3 +1,28 @@
+2019-02-12 Alan Coon <[email protected]>
+
+ Apply patch. rdar://problem/48009995
+
+ 2019-02-12 Alex Christensen <[email protected]>
+
+ WebPage::close needs to remove all message receivers associated with that WebPage, not WebPage::~WebPage
+ https://bugs.webkit.org/show_bug.cgi?id=194522
+ <rdar://problem/47789393>
+
+ Reviewed by Chris Dumez.
+
+ The InjectedBundle SPI can retain the WebPage or wrapping objects (WKWebProcessPlugInBrowserContextController/WKBundlePageRef).
+ This can make it so WebPage::close is called before WebPage::~WebPage, and if the SuspendedPageProxy is reused for a subsequent
+ navigation to the same domain, the WebProcess is reused with a different WebPage instance with the same PageID, which causes problems
+ when another WebPage registers message handlers and then the previous WebPage is destroyed, which removes both message handlers.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::~WebPage):
+ (WebKit::WebPage::close):
+ (WebKit::WebPage::mainFrameDidLayout):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebProcess.h:
+ (WebKit::WebProcess::eventDispatcher):
+
2019-02-07 Babak Shafiei <[email protected]>
Cherry-pick r241171. rdar://problem/47908156
Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (241312 => 241313)
--- branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-02-12 20:44:58 UTC (rev 241312)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-02-12 21:13:44 UTC (rev 241313)
@@ -360,7 +360,7 @@
#endif
, m_layerHostingMode(parameters.layerHostingMode)
#if PLATFORM(COCOA)
- , m_viewGestureGeometryCollector(makeUniqueRef<ViewGestureGeometryCollector>(*this))
+ , m_viewGestureGeometryCollector(std::make_unique<ViewGestureGeometryCollector>(*this))
#elif HAVE(ACCESSIBILITY) && PLATFORM(GTK)
, m_accessibilityObject(nullptr)
#endif
@@ -739,12 +739,6 @@
{
ASSERT(!m_page);
- auto& webProcess = WebProcess::singleton();
-#if ENABLE(ASYNC_SCROLLING)
- if (m_useAsyncScrolling)
- webProcess.eventDispatcher().removeScrollingTreeForPage(this);
-#endif
-
platformDetach();
m_sandboxExtensionTracker.invalidate();
@@ -759,16 +753,6 @@
m_footerBanner->detachFromPage();
#endif // !PLATFORM(IOS_FAMILY)
- webProcess.removeMessageReceiver(Messages::WebPage::messageReceiverName(), m_pageID);
-
- // FIXME: This should be done in the object destructors, and the objects themselves should be message receivers.
- webProcess.removeMessageReceiver(Messages::WebInspector::messageReceiverName(), m_pageID);
- webProcess.removeMessageReceiver(Messages::WebInspectorUI::messageReceiverName(), m_pageID);
- webProcess.removeMessageReceiver(Messages::RemoteWebInspectorUI::messageReceiverName(), m_pageID);
-#if ENABLE(FULLSCREEN_API)
- webProcess.removeMessageReceiver(Messages::WebFullScreenManager::messageReceiverName(), m_pageID);
-#endif
-
#ifndef NDEBUG
webPageCounter.decrement();
#endif
@@ -1305,6 +1289,23 @@
bool isRunningModal = m_isRunningModal;
m_isRunningModal = false;
+ auto& webProcess = WebProcess::singleton();
+#if ENABLE(ASYNC_SCROLLING)
+ if (m_useAsyncScrolling)
+ webProcess.eventDispatcher().removeScrollingTreeForPage(this);
+#endif
+ webProcess.removeMessageReceiver(Messages::WebPage::messageReceiverName(), m_pageID);
+ // FIXME: This should be done in the object destructors, and the objects themselves should be message receivers.
+ webProcess.removeMessageReceiver(Messages::WebInspector::messageReceiverName(), m_pageID);
+ webProcess.removeMessageReceiver(Messages::WebInspectorUI::messageReceiverName(), m_pageID);
+ webProcess.removeMessageReceiver(Messages::RemoteWebInspectorUI::messageReceiverName(), m_pageID);
+#if ENABLE(FULLSCREEN_API)
+ webProcess.removeMessageReceiver(Messages::WebFullScreenManager::messageReceiverName(), m_pageID);
+#endif
+#if PLATFORM(COCOA)
+ m_viewGestureGeometryCollector = nullptr;
+#endif
+
// The WebPage can be destroyed by this call.
WebProcess::singleton().removeWebPage(m_pageID);
@@ -4180,7 +4181,8 @@
}
#if PLATFORM(COCOA)
- m_viewGestureGeometryCollector->mainFrameDidLayout();
+ if (m_viewGestureGeometryCollector)
+ m_viewGestureGeometryCollector->mainFrameDidLayout();
#endif
#if PLATFORM(IOS_FAMILY)
if (FrameView* frameView = mainFrameView()) {
Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (241312 => 241313)
--- branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-02-12 20:44:58 UTC (rev 241312)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-02-12 21:13:44 UTC (rev 241313)
@@ -1559,7 +1559,7 @@
RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
- UniqueRef<ViewGestureGeometryCollector> m_viewGestureGeometryCollector;
+ std::unique_ptr<ViewGestureGeometryCollector> m_viewGestureGeometryCollector;
RetainPtr<NSDictionary> m_dataDetectionContext;
#endif
Modified: branches/safari-607-branch/Source/WebKit/WebProcess/WebProcess.h (241312 => 241313)
--- branches/safari-607-branch/Source/WebKit/WebProcess/WebProcess.h 2019-02-12 20:44:58 UTC (rev 241312)
+++ branches/safari-607-branch/Source/WebKit/WebProcess/WebProcess.h 2019-02-12 21:13:44 UTC (rev 241313)
@@ -166,7 +166,7 @@
PluginProcessConnectionManager& pluginProcessConnectionManager();
#endif
- EventDispatcher& eventDispatcher() { return *m_eventDispatcher; }
+ EventDispatcher& eventDispatcher() { return m_eventDispatcher.get(); }
NetworkProcessConnection& ensureNetworkProcessConnection();
void networkProcessConnectionClosed(NetworkProcessConnection*);
@@ -407,7 +407,7 @@
HashMap<uint64_t, RefPtr<WebPageGroupProxy>> m_pageGroupMap;
RefPtr<InjectedBundle> m_injectedBundle;
- RefPtr<EventDispatcher> m_eventDispatcher;
+ Ref<EventDispatcher> m_eventDispatcher;
#if PLATFORM(IOS_FAMILY)
RefPtr<ViewUpdateDispatcher> m_viewUpdateDispatcher;
#endif
Modified: branches/safari-607-branch/Tools/ChangeLog (241312 => 241313)
--- branches/safari-607-branch/Tools/ChangeLog 2019-02-12 20:44:58 UTC (rev 241312)
+++ branches/safari-607-branch/Tools/ChangeLog 2019-02-12 21:13:44 UTC (rev 241313)
@@ -1,3 +1,20 @@
+2019-02-12 Alan Coon <[email protected]>
+
+ Apply patch. rdar://problem/48009995
+
+ 2019-02-12 Alex Christensen <[email protected]>
+
+ WebPage::close needs to remove all message receivers associated with that WebPage, not WebPage::~WebPage
+ https://bugs.webkit.org/show_bug.cgi?id=194522
+ <rdar://problem/47789393>
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/BundleRetainPagePlugIn.mm: Added.
+ (-[BundleRetainPagePlugIn webProcessPlugIn:didCreateBrowserContextController:]):
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
2019-02-07 Alan Coon <[email protected]>
Cherry-pick r240710. rdar://problem/47776353
Modified: branches/safari-607-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (241312 => 241313)
--- branches/safari-607-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-02-12 20:44:58 UTC (rev 241312)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-02-12 21:13:44 UTC (rev 241313)
@@ -301,6 +301,7 @@
5C4A84951F7EEFFC00ACFC54 /* Configuration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C4A84941F7EEFD400ACFC54 /* Configuration.mm */; };
5C69BDD51F82A7EF000F4F4B /* _javascript_DuringNavigation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C69BDD41F82A7EB000F4F4B /* _javascript_DuringNavigation.mm */; };
5C7148952123A40A00FDE3C5 /* WKWebsiteDatastore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7148942123A40700FDE3C5 /* WKWebsiteDatastore.mm */; };
+ 5C75716122124C5200B9E5AC /* BundleRetainPagePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C75715F221249BD00B9E5AC /* BundleRetainPagePlugIn.mm */; };
5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C79640F1EB0269B0075D74C /* EventModifiers.cpp */; };
5C7C74CB1FB529BA002F9ABE /* WebViewScheduleInRunLoop.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7C74CA1FB528D4002F9ABE /* WebViewScheduleInRunLoop.mm */; };
5C838F7F1DB04F900082858F /* LoadInvalidURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */; };
@@ -1672,6 +1673,7 @@
5C5E633D1D0B67940085A025 /* UniqueRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueRef.cpp; sourceTree = "<group>"; };
5C69BDD41F82A7EB000F4F4B /* _javascript_DuringNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _javascript_DuringNavigation.mm; sourceTree = "<group>"; };
5C7148942123A40700FDE3C5 /* WKWebsiteDatastore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebsiteDatastore.mm; sourceTree = "<group>"; };
+ 5C75715F221249BD00B9E5AC /* BundleRetainPagePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleRetainPagePlugIn.mm; sourceTree = "<group>"; };
5C79640F1EB0269B0075D74C /* EventModifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventModifiers.cpp; sourceTree = "<group>"; };
5C7C74CA1FB528D4002F9ABE /* WebViewScheduleInRunLoop.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewScheduleInRunLoop.mm; sourceTree = "<group>"; };
5C8BC798218CF3E900813886 /* NetworkProcess.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkProcess.mm; sourceTree = "<group>"; };
@@ -2445,6 +2447,7 @@
37A709AD1E3EA8B000CA5969 /* BundleRangeHandle.mm */,
37A709AA1E3EA79000CA5969 /* BundleRangeHandlePlugIn.mm */,
37A709AC1E3EA7E800CA5969 /* BundleRangeHandleProtocol.h */,
+ 5C75715F221249BD00B9E5AC /* BundleRetainPagePlugIn.mm */,
1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */,
1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */,
5CB18BA71F5645B200EE23C4 /* ClickAutoFillButton.mm */,
@@ -4351,6 +4354,7 @@
374B7A611DF371CF00ACCB6C /* BundleEditingDelegatePlugIn.mm in Sources */,
A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
37A709AF1E3EA97E00CA5969 /* BundleRangeHandlePlugIn.mm in Sources */,
+ 5C75716122124C5200B9E5AC /* BundleRetainPagePlugIn.mm in Sources */,
1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */,
5CB18BA81F5645E300EE23C4 /* ClickAutoFillButton.mm in Sources */,
A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */,
Added: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleRetainPagePlugIn.mm (0 => 241313)
--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleRetainPagePlugIn.mm (rev 0)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleRetainPagePlugIn.mm 2019-02-12 21:13:44 UTC (rev 241313)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 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"
+
+#if WK_API_ENABLED
+
+#import <WebKit/WKWebProcessPlugIn.h>
+#import <wtf/RetainPtr.h>
+
+@interface BundleRetainPagePlugIn : NSObject <WKWebProcessPlugIn>
+@end
+
+@implementation BundleRetainPagePlugIn
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5*NSEC_PER_SEC), dispatch_get_main_queue(), [retainedPage = retainPtr(browserContextController)] { });
+}
+
+@end
+
+#endif // WK_API_ENABLED
Modified: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (241312 => 241313)
--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-02-12 20:44:58 UTC (rev 241312)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-02-12 21:13:44 UTC (rev 241313)
@@ -2404,11 +2404,17 @@
</body>
)PSONRESOURCE";
-TEST(ProcessSwap, ReuseSuspendedProcessForRegularNavigation)
+enum class RetainPageInBundle { No, Yes };
+void testReuseSuspendedProcessForRegularNavigation(RetainPageInBundle retainPageInBundle)
{
auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
[processPoolConfiguration setProcessSwapsOnNavigation:YES];
+ if (retainPageInBundle == RetainPageInBundle::Yes)
+ [processPoolConfiguration setInjectedBundleURL:[[NSBundle mainBundle] URLForResource:@"TestWebKitAPI" withExtension:@"wkbundle"]];
+
auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+ if (retainPageInBundle == RetainPageInBundle::Yes)
+ [processPool _setObject:@"BundleRetainPagePlugIn" forBundleParameter:TestWebKitAPI::Util::TestPlugInClassNameParameter];
auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
[webViewConfiguration setProcessPool:processPool.get()];
@@ -2446,6 +2452,16 @@
EXPECT_EQ(webkitPID, [webView _webProcessIdentifier]);
}
+TEST(ProcessSwap, ReuseSuspendedProcessForRegularNavigationRetainBundlePage)
+{
+ testReuseSuspendedProcessForRegularNavigation(RetainPageInBundle::Yes);
+}
+
+TEST(ProcessSwap, ReuseSuspendedProcessForRegularNavigation)
+{
+ testReuseSuspendedProcessForRegularNavigation(RetainPageInBundle::No);
+}
+
static const char* mainFramesOnlyMainFrame = R"PSONRESOURCE(
<script>
function loaded() {