Title: [252431] trunk/Source
Revision
252431
Author
[email protected]
Date
2019-11-13 14:41:08 -0800 (Wed, 13 Nov 2019)

Log Message

VeryHigh priority loads are actually loading at VeryLow priority
https://bugs.webkit.org/show_bug.cgi?id=203423
<rdar://problem/56621789>

Patch by Benjamin Nham <[email protected]> on 2019-11-13
Reviewed by Antti Koivisto.

There are two issues with the way we translate ResourceLoadPriority to
CFURLRequestPriority:

1. We call _CFNetworkHTTPConnectionCacheSetLimit and set 1 too few
priority levels. This means VeryHigh priority loads are actually out
of bounds, which causes CFNetwork to set the priority level back to 0
in HTTPConnectionCacheEntry::_prepareNewRequest. After this patch we'll
call _CFNetworkHTTPConnectionCacheSetLimit with the correct number of
levels.

2. _CFNetworkHTTPConnectionCacheSetLimit doesn't work for NSURLSession
right now (<rdar://problem/56621205>), so we have to map to the default
number of CFURLRequestPriority levels, which is 4. Right now we have 5
ResourceLoadPriority levels, so there will be some aliasing involved.
After this patch VeryLow gets a priority of -1 and Low gets a priority
of 0, but due to the aforementioned clamping behavior both VeryLow and
Low will effectively both have a CFURLRequestPriority of 0.

Source/WebCore:

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

Source/WebKit:

* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::initializeNetworkSettings):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252430 => 252431)


--- trunk/Source/WebCore/ChangeLog	2019-11-13 21:51:48 UTC (rev 252430)
+++ trunk/Source/WebCore/ChangeLog	2019-11-13 22:41:08 UTC (rev 252431)
@@ -1,3 +1,36 @@
+2019-11-13  Benjamin Nham  <[email protected]>
+
+        VeryHigh priority loads are actually loading at VeryLow priority
+        https://bugs.webkit.org/show_bug.cgi?id=203423
+        <rdar://problem/56621789>
+
+        Reviewed by Antti Koivisto.
+
+        There are two issues with the way we translate ResourceLoadPriority to
+        CFURLRequestPriority:
+
+        1. We call _CFNetworkHTTPConnectionCacheSetLimit and set 1 too few
+        priority levels. This means VeryHigh priority loads are actually out
+        of bounds, which causes CFNetwork to set the priority level back to 0
+        in HTTPConnectionCacheEntry::_prepareNewRequest. After this patch we'll
+        call _CFNetworkHTTPConnectionCacheSetLimit with the correct number of
+        levels.
+
+        2. _CFNetworkHTTPConnectionCacheSetLimit doesn't work for NSURLSession
+        right now (<rdar://problem/56621205>), so we have to map to the default
+        number of CFURLRequestPriority levels, which is 4. Right now we have 5
+        ResourceLoadPriority levels, so there will be some aliasing involved.
+        After this patch VeryLow gets a priority of -1 and Low gets a priority
+        of 0, but due to the aforementioned clamping behavior both VeryLow and
+        Low will effectively both have a CFURLRequestPriority of 0.
+
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::initializeMaximumHTTPConnectionCountPerHost):
+        (WebCore::initializeHTTPConnectionSettingsOnStartup):
+        * platform/network/cf/ResourceRequestCFNet.h:
+        (WebCore::toResourceLoadPriority):
+        (WebCore::toPlatformRequestPriority):
+
 2019-11-13  Dean Jackson  <[email protected]>
 
         Fix some WebGPU demos

Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp (252430 => 252431)


--- trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2019-11-13 21:51:48 UTC (rev 252430)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp	2019-11-13 22:41:08 UTC (rev 252431)
@@ -414,7 +414,7 @@
     if (!ResourceRequest::resourcePrioritiesEnabled())
         return maximumHTTPConnectionCountPerHost;
 
-    _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, toPlatformRequestPriority(ResourceLoadPriority::Highest));
+    _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, resourceLoadPriorityCount);
 #if !PLATFORM(WIN)
     // FIXME: <rdar://problem/9375609> Implement minimum fast lane priority setting on Windows
     _CFNetworkHTTPConnectionCacheSetLimit(kHTTPMinimumFastLanePriority, toPlatformRequestPriority(ResourceLoadPriority::Medium));
@@ -433,7 +433,7 @@
     static const unsigned preferredConnectionCount = 6;
     static const unsigned fastLaneConnectionCount = 1;
     _CFNetworkHTTPConnectionCacheSetLimit(kHTTPLoadWidth, preferredConnectionCount);
-    _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, toPlatformRequestPriority(ResourceLoadPriority::Highest));
+    _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, resourceLoadPriorityCount);
     _CFNetworkHTTPConnectionCacheSetLimit(kHTTPMinimumFastLanePriority, toPlatformRequestPriority(ResourceLoadPriority::Medium));
     _CFNetworkHTTPConnectionCacheSetLimit(kHTTPNumFastLanes, fastLaneConnectionCount);
 }

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


--- trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h	2019-11-13 21:51:48 UTC (rev 252430)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h	2019-11-13 22:41:08 UTC (rev 252431)
@@ -40,17 +40,17 @@
 
 inline ResourceLoadPriority toResourceLoadPriority(CFURLRequestPriority priority)
 {
+    // FIXME: switch VeryLow back to 0 priority when CFNetwork fixes <rdar://problem/56621205>
     switch (priority) {
     case -1:
+        return ResourceLoadPriority::VeryLow;
     case 0:
-        return ResourceLoadPriority::VeryLow;
+        return ResourceLoadPriority::Low;
     case 1:
-        return ResourceLoadPriority::Low;
+        return ResourceLoadPriority::Medium;
     case 2:
-        return ResourceLoadPriority::Medium;
+        return ResourceLoadPriority::High;
     case 3:
-        return ResourceLoadPriority::High;
-    case 4:
         return ResourceLoadPriority::VeryHigh;
     default:
         ASSERT_NOT_REACHED();
@@ -60,17 +60,18 @@
 
 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;
+    case ResourceLoadPriority::Low:
         return 0;
-    case ResourceLoadPriority::Low:
+    case ResourceLoadPriority::Medium:
         return 1;
-    case ResourceLoadPriority::Medium:
+    case ResourceLoadPriority::High:
         return 2;
-    case ResourceLoadPriority::High:
+    case ResourceLoadPriority::VeryHigh:
         return 3;
-    case ResourceLoadPriority::VeryHigh:
-        return 4;
     }
 
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebKit/ChangeLog (252430 => 252431)


--- trunk/Source/WebKit/ChangeLog	2019-11-13 21:51:48 UTC (rev 252430)
+++ trunk/Source/WebKit/ChangeLog	2019-11-13 22:41:08 UTC (rev 252431)
@@ -1,3 +1,32 @@
+2019-11-13  Benjamin Nham  <[email protected]>
+
+        VeryHigh priority loads are actually loading at VeryLow priority
+        https://bugs.webkit.org/show_bug.cgi?id=203423
+        <rdar://problem/56621789>
+
+        Reviewed by Antti Koivisto.
+
+        There are two issues with the way we translate ResourceLoadPriority to
+        CFURLRequestPriority:
+
+        1. We call _CFNetworkHTTPConnectionCacheSetLimit and set 1 too few
+        priority levels. This means VeryHigh priority loads are actually out
+        of bounds, which causes CFNetwork to set the priority level back to 0
+        in HTTPConnectionCacheEntry::_prepareNewRequest. After this patch we'll
+        call _CFNetworkHTTPConnectionCacheSetLimit with the correct number of
+        levels.
+
+        2. _CFNetworkHTTPConnectionCacheSetLimit doesn't work for NSURLSession
+        right now (<rdar://problem/56621205>), so we have to map to the default
+        number of CFURLRequestPriority levels, which is 4. Right now we have 5
+        ResourceLoadPriority levels, so there will be some aliasing involved.
+        After this patch VeryLow gets a priority of -1 and Low gets a priority
+        of 0, but due to the aforementioned clamping behavior both VeryLow and
+        Low will effectively both have a CFURLRequestPriority of 0.
+
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::initializeNetworkSettings):
+
 2019-11-13  Youenn Fablet  <[email protected]>
 
         Remove timer to stop service worker process

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (252430 => 252431)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2019-11-13 21:51:48 UTC (rev 252430)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2019-11-13 22:41:08 UTC (rev 252431)
@@ -62,7 +62,7 @@
     if (WebCore::ResourceRequest::resourcePrioritiesEnabled()) {
         const unsigned fastLaneConnectionCount = 1;
 
-        _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, toPlatformRequestPriority(WebCore::ResourceLoadPriority::Highest));
+        _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, WebCore::resourceLoadPriorityCount);
         _CFNetworkHTTPConnectionCacheSetLimit(kHTTPMinimumFastLanePriority, toPlatformRequestPriority(WebCore::ResourceLoadPriority::Medium));
         _CFNetworkHTTPConnectionCacheSetLimit(kHTTPNumFastLanes, fastLaneConnectionCount);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to