Title: [273452] trunk/Source/WebKit
Revision
273452
Author
pvol...@apple.com
Date
2021-02-24 16:08:23 -0800 (Wed, 24 Feb 2021)

Log Message

[iOS] Get default value in the UI process for whether synchronous XMLHttpRequest are allowed during unload
https://bugs.webkit.org/show_bug.cgi?id=222377

Reviewed by Brent Fulgham.

Getting this default value in the UI process instead of in every WebContent process should be a small speedup,
since getting this default value is a bit costly on iOS.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* Shared/ios/WebPreferencesDefaultValuesIOS.h: Added.
* Shared/ios/WebPreferencesDefaultValuesIOS.mm:
(WebKit::cachedAllowsRequest):
(WebKit::allowsDeprecatedSynchronousXMLHttpRequestDuringUnload):
(WebKit::setAllowsDeprecatedSynchronousXMLHttpRequestDuringUnload):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_lastNavigationWasAppBound):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (273451 => 273452)


--- trunk/Source/WebKit/ChangeLog	2021-02-25 00:07:16 UTC (rev 273451)
+++ trunk/Source/WebKit/ChangeLog	2021-02-25 00:08:23 UTC (rev 273452)
@@ -1,3 +1,28 @@
+2021-02-24  Per Arne Vollan  <pvol...@apple.com>
+
+        [iOS] Get default value in the UI process for whether synchronous XMLHttpRequest are allowed during unload
+        https://bugs.webkit.org/show_bug.cgi?id=222377
+
+        Reviewed by Brent Fulgham.
+
+        Getting this default value in the UI process instead of in every WebContent process should be a small speedup,
+        since getting this default value is a bit costly on iOS.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * Shared/ios/WebPreferencesDefaultValuesIOS.h: Added.
+        * Shared/ios/WebPreferencesDefaultValuesIOS.mm:
+        (WebKit::cachedAllowsRequest):
+        (WebKit::allowsDeprecatedSynchronousXMLHttpRequestDuringUnload):
+        (WebKit::setAllowsDeprecatedSynchronousXMLHttpRequestDuringUnload):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_lastNavigationWasAppBound):
+
 2021-02-24  Russell Epstein  <repst...@apple.com>
 
         Revert r272735. rdar://problem/74674837

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (273451 => 273452)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2021-02-25 00:07:16 UTC (rev 273451)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2021-02-25 00:08:23 UTC (rev 273452)
@@ -184,6 +184,9 @@
     
     encoder << textInteractionEnabled;
     encoder << httpsUpgradeEnabled;
+#if PLATFORM(IOS)
+    encoder << allowsDeprecatedSynchronousXMLHttpRequestDuringUnload;
+#endif
 }
 
 Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder)
@@ -591,6 +594,11 @@
     if (!decoder.decode(parameters.httpsUpgradeEnabled))
         return WTF::nullopt;
 
+#if PLATFORM(IOS)
+    if (!decoder.decode(parameters.allowsDeprecatedSynchronousXMLHttpRequestDuringUnload))
+        return WTF::nullopt;
+#endif
+
     return parameters;
 }
 

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (273451 => 273452)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2021-02-25 00:07:16 UTC (rev 273451)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2021-02-25 00:08:23 UTC (rev 273452)
@@ -256,6 +256,10 @@
 
     bool textInteractionEnabled { true };
     bool httpsUpgradeEnabled { true };
+    
+#if PLATFORM(IOS)
+    bool allowsDeprecatedSynchronousXMLHttpRequestDuringUnload { false };
+#endif
 };
 
 } // namespace WebKit

Copied: trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.h (from rev 273450, trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm) (0 => 273452)


--- trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.h	                        (rev 0)
+++ trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.h	2021-02-25 00:08:23 UTC (rev 273452)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 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
+
+#include "WebPreferencesDefaultValues.h"
+
+namespace WebKit {
+
+void setAllowsDeprecatedSynchronousXMLHttpRequestDuringUnload(bool allowsRequest);
+
+} // namespace WebKit

Modified: trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm (273451 => 273452)


--- trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm	2021-02-25 00:07:16 UTC (rev 273451)
+++ trunk/Source/WebKit/Shared/ios/WebPreferencesDefaultValuesIOS.mm	2021-02-25 00:08:23 UTC (rev 273452)
@@ -24,7 +24,7 @@
  */
 
 #import "config.h"
-#import "WebPreferencesDefaultValues.h"
+#import "WebPreferencesDefaultValuesIOS.h"
 
 #if PLATFORM(IOS_FAMILY)
 
@@ -44,10 +44,23 @@
 #endif
 
 #if !PLATFORM(MACCATALYST) && !PLATFORM(WATCHOS)
+static Optional<bool>& cachedAllowsRequest()
+{
+    static NeverDestroyed<Optional<bool>> allowsRequest;
+    return allowsRequest;
+}
+
 bool allowsDeprecatedSynchronousXMLHttpRequestDuringUnload()
 {
-    return [[PAL::getMCProfileConnectionClass() sharedConnection] effectiveBoolValueForSetting:@"allowDeprecatedWebKitSynchronousXHRLoads"] == MCRestrictedBoolExplicitYes;
+    if (!cachedAllowsRequest())
+        cachedAllowsRequest() = [[PAL::getMCProfileConnectionClass() sharedConnection] effectiveBoolValueForSetting:@"allowDeprecatedWebKitSynchronousXHRLoads"] == MCRestrictedBoolExplicitYes;
+    return *cachedAllowsRequest();
 }
+
+void setAllowsDeprecatedSynchronousXMLHttpRequestDuringUnload(bool allowsRequest)
+{
+    cachedAllowsRequest() = allowsRequest;
+}
 #endif
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (273451 => 273452)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-02-25 00:07:16 UTC (rev 273451)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-02-25 00:08:23 UTC (rev 273452)
@@ -7985,6 +7985,10 @@
     parameters.textInteractionEnabled = preferences().textInteractionEnabled();
     parameters.httpsUpgradeEnabled = m_configuration->httpsUpgradeEnabled();
 
+#if PLATFORM(IOS)
+    parameters.allowsDeprecatedSynchronousXMLHttpRequestDuringUnload = allowsDeprecatedSynchronousXMLHttpRequestDuringUnload();
+#endif
+
     return parameters;
 }
 

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (273451 => 273452)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-02-25 00:07:16 UTC (rev 273451)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-02-25 00:08:23 UTC (rev 273452)
@@ -5487,6 +5487,7 @@
 		C18F3A142563334300797E66 /* WebInspectorPreferenceObserver.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspectorPreferenceObserver.mm; sourceTree = "<group>"; };
 		C18FB51D242F9F76007E9875 /* WebSleepDisablerClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSleepDisablerClient.cpp; sourceTree = "<group>"; };
 		C18FB51E242F9F77007E9875 /* WebSleepDisablerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSleepDisablerClient.h; sourceTree = "<group>"; };
+		C19D23DE25E6F02400FA03F3 /* WebPreferencesDefaultValuesIOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebPreferencesDefaultValuesIOS.h; path = ios/WebPreferencesDefaultValuesIOS.h; sourceTree = "<group>"; };
 		C1A152D524E5A1D200978C8B /* HandleXPCEndpointMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HandleXPCEndpointMessages.h; sourceTree = "<group>"; };
 		C1A152D624E5A29A00978C8B /* HandleXPCEndpointMessages.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HandleXPCEndpointMessages.mm; sourceTree = "<group>"; };
 		C1C1B30E2540F45600D9100B /* NetworkConnectionToWebProcessMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkConnectionToWebProcessMac.mm; sourceTree = "<group>"; };
@@ -7558,6 +7559,7 @@
 				2DA944991884E4F000ED86DB /* WebIOSEventFactory.h */,
 				2DA9449A1884E4F000ED86DB /* WebIOSEventFactory.mm */,
 				2DA9449B1884E4F000ED86DB /* WebPlatformTouchPointIOS.cpp */,
+				C19D23DE25E6F02400FA03F3 /* WebPreferencesDefaultValuesIOS.h */,
 				F4AC655E22A3140E00A05607 /* WebPreferencesDefaultValuesIOS.mm */,
 				2DA9449C1884E4F000ED86DB /* WebTouchEventIOS.cpp */,
 			);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (273451 => 273452)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-02-25 00:07:16 UTC (rev 273451)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-02-25 00:08:23 UTC (rev 273452)
@@ -357,6 +357,10 @@
 #include <WebCore/ImageExtractionResult.h>
 #endif
 
+#if PLATFORM(IOS)
+#include "WebPreferencesDefaultValuesIOS.h"
+#endif
+
 namespace WebKit {
 using namespace JSC;
 using namespace WebCore;
@@ -633,6 +637,10 @@
 
     m_page = makeUnique<Page>(WTFMove(pageConfiguration));
 
+#if PLATFORM(IOS)
+    setAllowsDeprecatedSynchronousXMLHttpRequestDuringUnload(parameters.allowsDeprecatedSynchronousXMLHttpRequestDuringUnload);
+#endif
+
     updatePreferences(parameters.store);
 
 #if PLATFORM(IOS_FAMILY) || ENABLE(ROUTING_ARBITRATION)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to