Title: [274161] trunk/Source
Revision
274161
Author
n...@apple.com
Date
2021-03-09 11:08:33 -0800 (Tue, 09 Mar 2021)

Log Message

Adopt new NSURLSessionConfiguration SPI for connection cache configuration
https://bugs.webkit.org/show_bug.cgi?id=222934

Reviewed by Geoffrey Garen.

Source/WebCore:

This uses the NSURLSessionConfiguration connection cache limit SPI introduced in Big Sur to
properly set the parameters we want for HTTP/1.1 connections. Previously we tried to do this
using _CFNetworkHTTPConnectionCacheSetLimit in NetworkProcessCocoa, but this didn't work
because that SPI only applies to NSURLConnection rather than NSURLSession.

In particular, this meant that the number of priority levels wasn't set correctly, which we
had to work around by constraining the number of priority levels when mapping WebKit
resource priorities to CFNetwork priorities (https://bugs.webkit.org/show_bug.cgi?id=203423).
This patch adopts the SPI and removes that workaround.

* platform/network/cf/ResourceRequestCFNet.h:
(WebCore::toResourceLoadPriority):
(WebCore::toPlatformRequestPriority):

Source/WebCore/PAL:

Declare NSURLSessionConfiguration connection cache limit SPI when building using the public SDK.

* pal/spi/cf/CFNetworkSPI.h:

Source/WebKit:

This uses the NSURLSessionConfiguration connection cache limit SPI introduced in Big Sur to
properly set the parameters we want for HTTP/1.1 connections. Previously we tried to do this
using _CFNetworkHTTPConnectionCacheSetLimit in NetworkProcessCocoa, but this didn't work
because that SPI only applies to NSURLConnection rather than NSURLSession.

In particular, this meant that the number of priority levels wasn't set correctly, which we
had to work around by constraining the number of priority levels when mapping WebKit
resource priorities to CFNetwork priorities (https://bugs.webkit.org/show_bug.cgi?id=203423).
This patch adopts the SPI and removes that workaround.

* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::configurationForSessionID):

Source/WTF:

Add the HAVE_CFNETWORK_NSURLSESSION_CONNECTION_CACHE_LIMITS flag to control whether or not
to use the connection cache limit SPI on NSURLSessionConfiguration.

* wtf/PlatformHave.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (274160 => 274161)


--- trunk/Source/WTF/ChangeLog	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WTF/ChangeLog	2021-03-09 19:08:33 UTC (rev 274161)
@@ -1,3 +1,15 @@
+2021-03-09  Ben Nham  <n...@apple.com>
+
+        Adopt new NSURLSessionConfiguration SPI for connection cache configuration
+        https://bugs.webkit.org/show_bug.cgi?id=222934
+
+        Reviewed by Geoffrey Garen.
+
+        Add the HAVE_CFNETWORK_NSURLSESSION_CONNECTION_CACHE_LIMITS flag to control whether or not
+        to use the connection cache limit SPI on NSURLSessionConfiguration.
+
+        * wtf/PlatformHave.h:
+
 2021-03-08  Sam Weinig  <wei...@apple.com>
 
         Remove quirks for the no longer supported iAd Producer

Modified: trunk/Source/WTF/wtf/PlatformHave.h (274160 => 274161)


--- trunk/Source/WTF/wtf/PlatformHave.h	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2021-03-09 19:08:33 UTC (rev 274161)
@@ -416,6 +416,13 @@
 #define HAVE_CFNETWORK_NSURLSESSION_STRICTRUSTEVALUATE 1
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000) \
+    || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) \
+    || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 70000) \
+    || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 140000)
+#define HAVE_CFNETWORK_NSURLSESSION_CONNECTION_CACHE_LIMITS 1
+#endif
+
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || PLATFORM(IOS_FAMILY)
 #define HAVE_CFNETWORK_NEGOTIATED_SSL_PROTOCOL_CIPHER 1
 #endif

Modified: trunk/Source/WebCore/ChangeLog (274160 => 274161)


--- trunk/Source/WebCore/ChangeLog	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WebCore/ChangeLog	2021-03-09 19:08:33 UTC (rev 274161)
@@ -1,3 +1,24 @@
+2021-03-09  Ben Nham  <n...@apple.com>
+
+        Adopt new NSURLSessionConfiguration SPI for connection cache configuration
+        https://bugs.webkit.org/show_bug.cgi?id=222934
+
+        Reviewed by Geoffrey Garen.
+
+        This uses the NSURLSessionConfiguration connection cache limit SPI introduced in Big Sur to
+        properly set the parameters we want for HTTP/1.1 connections. Previously we tried to do this
+        using _CFNetworkHTTPConnectionCacheSetLimit in NetworkProcessCocoa, but this didn't work
+        because that SPI only applies to NSURLConnection rather than NSURLSession.
+
+        In particular, this meant that the number of priority levels wasn't set correctly, which we
+        had to work around by constraining the number of priority levels when mapping WebKit
+        resource priorities to CFNetwork priorities (https://bugs.webkit.org/show_bug.cgi?id=203423).
+        This patch adopts the SPI and removes that workaround.
+
+        * platform/network/cf/ResourceRequestCFNet.h:
+        (WebCore::toResourceLoadPriority):
+        (WebCore::toPlatformRequestPriority):
+
 2021-03-09  Peng Liu  <peng.l...@apple.com>
 
         [GPUP] Test fast/images/animated-image-mp4.html times out when media in GPU Process is enabled

Modified: trunk/Source/WebCore/PAL/ChangeLog (274160 => 274161)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-03-09 19:08:33 UTC (rev 274161)
@@ -1,3 +1,14 @@
+2021-03-09  Ben Nham  <n...@apple.com>
+
+        Adopt new NSURLSessionConfiguration SPI for connection cache configuration
+        https://bugs.webkit.org/show_bug.cgi?id=222934
+
+        Reviewed by Geoffrey Garen.
+
+        Declare NSURLSessionConfiguration connection cache limit SPI when building using the public SDK.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+
 2021-03-05  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] Fix compile error

Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (274160 => 274161)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2021-03-09 19:08:33 UTC (rev 274161)
@@ -242,6 +242,11 @@
 #if HAVE(NETWORK_LOADER)
 @property BOOL _usesNWLoader;
 #endif
+#if HAVE(CFNETWORK_NSURLSESSION_CONNECTION_CACHE_LIMITS)
+@property (readwrite, assign) NSInteger _connectionCacheNumPriorityLevels;
+@property (readwrite, assign) NSInteger _connectionCacheNumFastLanes;
+@property (readwrite, assign) NSInteger _connectionCacheMinimumFastLanePriority;
+#endif
 @end
 
 @interface NSURLSessionTask ()

Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h (274160 => 274161)


--- trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h	2021-03-09 19:08:33 UTC (rev 274161)
@@ -44,10 +44,50 @@
 CFURLRequestRef cfURLRequest(const ResourceRequest&);
 #endif
 
+#if HAVE(CFNETWORK_NSURLSESSION_CONNECTION_CACHE_LIMITS)
 inline ResourceLoadPriority toResourceLoadPriority(CFURLRequestPriority priority)
 {
-    // FIXME: switch VeryLow back to 0 priority when CFNetwork fixes <rdar://problem/56621205>
     switch (priority) {
+    case 0:
+        return ResourceLoadPriority::VeryLow;
+    case 1:
+        return ResourceLoadPriority::Low;
+    case 2:
+        return ResourceLoadPriority::Medium;
+    case 3:
+        return ResourceLoadPriority::High;
+    case 4:
+        return ResourceLoadPriority::VeryHigh;
+    default:
+        ASSERT_NOT_REACHED();
+        return ResourceLoadPriority::Lowest;
+    }
+}
+
+inline CFURLRequestPriority toPlatformRequestPriority(ResourceLoadPriority priority)
+{
+    switch (priority) {
+    case ResourceLoadPriority::VeryLow:
+        return 0;
+    case ResourceLoadPriority::Low:
+        return 1;
+    case ResourceLoadPriority::Medium:
+        return 2;
+    case ResourceLoadPriority::High:
+        return 3;
+    case ResourceLoadPriority::VeryHigh:
+        return 4;
+    }
+
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+#else
+
+inline ResourceLoadPriority toResourceLoadPriority(CFURLRequestPriority priority)
+{
+    switch (priority) {
     case -1:
         return ResourceLoadPriority::VeryLow;
     case 0:
@@ -66,7 +106,6 @@
 
 inline CFURLRequestPriority toPlatformRequestPriority(ResourceLoadPriority priority)
 {
-    // FIXME: switch VeryLow back to 0 priority when CFNetwork fixes <rdar://problem/56621205>
     switch (priority) {
     case ResourceLoadPriority::VeryLow:
         return -1;
@@ -83,7 +122,9 @@
     ASSERT_NOT_REACHED();
     return 0;
 }
+#endif
 
+
 inline RetainPtr<CFStringRef> httpHeaderValueUsingSuitableEncoding(HTTPHeaderMap::const_iterator::KeyValue header)
 {
     if (header.keyAsHTTPHeaderName && *header.keyAsHTTPHeaderName == HTTPHeaderName::LastEventID && !header.value.isAllASCII()) {

Modified: trunk/Source/WebKit/ChangeLog (274160 => 274161)


--- trunk/Source/WebKit/ChangeLog	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WebKit/ChangeLog	2021-03-09 19:08:33 UTC (rev 274161)
@@ -1,3 +1,23 @@
+2021-03-09  Ben Nham  <n...@apple.com>
+
+        Adopt new NSURLSessionConfiguration SPI for connection cache configuration
+        https://bugs.webkit.org/show_bug.cgi?id=222934
+
+        Reviewed by Geoffrey Garen.
+
+        This uses the NSURLSessionConfiguration connection cache limit SPI introduced in Big Sur to
+        properly set the parameters we want for HTTP/1.1 connections. Previously we tried to do this
+        using _CFNetworkHTTPConnectionCacheSetLimit in NetworkProcessCocoa, but this didn't work
+        because that SPI only applies to NSURLConnection rather than NSURLSession.
+
+        In particular, this meant that the number of priority levels wasn't set correctly, which we
+        had to work around by constraining the number of priority levels when mapping WebKit
+        resource priorities to CFNetwork priorities (https://bugs.webkit.org/show_bug.cgi?id=203423).
+        This patch adopts the SPI and removes that workaround.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::configurationForSessionID):
+
 2021-03-09  Chris Dumez  <cdu...@apple.com>
 
         [IPC Hardening] IPC::decode(Decoder& decoder, RetainPtr<CFDictionaryRef>&) should make sure keys & values aren't null

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (274160 => 274161)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-03-09 18:58:53 UTC (rev 274160)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-03-09 19:08:33 UTC (rev 274161)
@@ -1078,6 +1078,15 @@
     configuration._allowsSensitiveLogging = NO;
 ALLOW_DEPRECATED_DECLARATIONS_END
 #endif
+
+#if HAVE(CFNETWORK_NSURLSESSION_CONNECTION_CACHE_LIMITS)
+    if (WebCore::ResourceRequest::resourcePrioritiesEnabled()) {
+        configuration._connectionCacheNumPriorityLevels = WebCore::resourceLoadPriorityCount;
+        configuration._connectionCacheMinimumFastLanePriority = toPlatformRequestPriority(WebCore::ResourceLoadPriority::Medium);
+        configuration._connectionCacheNumFastLanes = 1;
+    }
+#endif
+
     return configuration;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to