Title: [292067] trunk/Source
Revision
292067
Author
achristen...@apple.com
Date
2022-03-29 13:55:36 -0700 (Tue, 29 Mar 2022)

Log Message

Navigation Timing data is corrupt in WebView (UIWebView/WKWebView)
https://bugs.webkit.org/show_bug.cgi?id=186919
<rdar://41393423>

Reviewed by Simon Fraser.

Source/WebCore:

Sometimes the observed requestStart time is after the observed responseStart time.
This may be due to the device's clock changing.  It may be due to something else,
but currently CFNetwork does not use a monotonic timer to gather the data.
When this happens, use the later of the two times for responseStart.

* platform/network/cocoa/NetworkLoadMetrics.mm:
(WebCore::packageTimingData):

Source/WebKit:

* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292066 => 292067)


--- trunk/Source/WebCore/ChangeLog	2022-03-29 20:53:29 UTC (rev 292066)
+++ trunk/Source/WebCore/ChangeLog	2022-03-29 20:55:36 UTC (rev 292067)
@@ -1,3 +1,19 @@
+2022-03-29  Alex Christensen  <achristen...@webkit.org>
+
+        Navigation Timing data is corrupt in WebView (UIWebView/WKWebView)
+        https://bugs.webkit.org/show_bug.cgi?id=186919
+        <rdar://41393423>
+
+        Reviewed by Simon Fraser.
+
+        Sometimes the observed requestStart time is after the observed responseStart time.
+        This may be due to the device's clock changing.  It may be due to something else,
+        but currently CFNetwork does not use a monotonic timer to gather the data.
+        When this happens, use the later of the two times for responseStart.
+
+        * platform/network/cocoa/NetworkLoadMetrics.mm:
+        (WebCore::packageTimingData):
+
 2022-03-29  Fujii Hironori  <hironori.fu...@sony.com>
 
         drop-shadow filter doesn't work correctly in tiled backing layer

Modified: trunk/Source/WebCore/platform/network/cocoa/NetworkLoadMetrics.mm (292066 => 292067)


--- trunk/Source/WebCore/platform/network/cocoa/NetworkLoadMetrics.mm	2022-03-29 20:53:29 UTC (rev 292066)
+++ trunk/Source/WebCore/platform/network/cocoa/NetworkLoadMetrics.mm	2022-03-29 20:55:36 UTC (rev 292067)
@@ -54,7 +54,8 @@
         timing->secureConnectionStart = dateToMonotonicTime(secureConnectionStart);
     timing->connectEnd = dateToMonotonicTime(connectEnd);
     timing->requestStart = dateToMonotonicTime(requestStart);
-    timing->responseStart = dateToMonotonicTime(responseStart);
+    // Sometimes, likely because of <rdar://90997689>, responseStart is before requestStart. If this happens, use the later of the two.
+    timing->responseStart = std::max(timing->requestStart, dateToMonotonicTime(responseStart));
     timing->redirectCount = redirectCount;
     timing->failsTAOCheck = failsTAOCheck;
     timing->hasCrossOriginRedirect = hasCrossOriginRedirect;

Modified: trunk/Source/WebKit/ChangeLog (292066 => 292067)


--- trunk/Source/WebKit/ChangeLog	2022-03-29 20:53:29 UTC (rev 292066)
+++ trunk/Source/WebKit/ChangeLog	2022-03-29 20:55:36 UTC (rev 292067)
@@ -1,3 +1,14 @@
+2022-03-29  Alex Christensen  <achristen...@webkit.org>
+
+        Navigation Timing data is corrupt in WebView (UIWebView/WKWebView)
+        https://bugs.webkit.org/show_bug.cgi?id=186919
+        <rdar://41393423>
+
+        Reviewed by Simon Fraser.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):
+
 2022-03-29  C Lopez  <clop...@apple.com>
 
         Add Captive Portal alert to WKWebView

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (292066 => 292067)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2022-03-29 20:53:29 UTC (rev 292066)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2022-03-29 20:55:36 UTC (rev 292067)
@@ -837,7 +837,8 @@
             networkLoadMetrics.secureConnectionStart = dateToMonotonicTime(m.secureConnectionStartDate);
         networkLoadMetrics.connectEnd = dateToMonotonicTime(m.connectEndDate);
         networkLoadMetrics.requestStart = dateToMonotonicTime(m.requestStartDate);
-        networkLoadMetrics.responseStart = dateToMonotonicTime(m.responseStartDate);
+        // Sometimes, likely because of <rdar://90997689>, responseStart is before requestStart. If this happens, use the later of the two.
+        networkLoadMetrics.responseStart = std::max(networkLoadMetrics.requestStart, dateToMonotonicTime(m.responseStartDate));
         networkLoadMetrics.responseEnd = dateToMonotonicTime(m.responseEndDate);
         networkLoadMetrics.markComplete();
         networkLoadMetrics.redirectCount = metrics.redirectCount;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to