Title: [246615] trunk/Source/WebKit
Revision
246615
Author
[email protected]
Date
2019-06-19 16:36:35 -0700 (Wed, 19 Jun 2019)

Log Message

DownloadMonitor::measuredThroughputRate should approach zero with no throughput
https://bugs.webkit.org/show_bug.cgi?id=198981
<rdar://problem/51456914>

Patch by Alex Christensen <[email protected]> on 2019-06-19
Reviewed by Geoffrey Garen.

When the timer fires to approximate the download rate, add a new timestamp with 0 bytes received since the last time we received bytes.
Then, if there's only one timestamp, assume the throughput rate is 0 instead of infinite.
This will prevent false positives estimating large download rates based on old data when the throughput drops to 0.

* NetworkProcess/Downloads/DownloadMonitor.cpp:
(WebKit::DownloadMonitor::measuredThroughputRate const):
(WebKit::DownloadMonitor::timerFired):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (246614 => 246615)


--- trunk/Source/WebKit/ChangeLog	2019-06-19 23:30:04 UTC (rev 246614)
+++ trunk/Source/WebKit/ChangeLog	2019-06-19 23:36:35 UTC (rev 246615)
@@ -1,3 +1,19 @@
+2019-06-19  Alex Christensen  <[email protected]>
+
+        DownloadMonitor::measuredThroughputRate should approach zero with no throughput
+        https://bugs.webkit.org/show_bug.cgi?id=198981
+        <rdar://problem/51456914>
+
+        Reviewed by Geoffrey Garen.
+
+        When the timer fires to approximate the download rate, add a new timestamp with 0 bytes received since the last time we received bytes.
+        Then, if there's only one timestamp, assume the throughput rate is 0 instead of infinite.
+        This will prevent false positives estimating large download rates based on old data when the throughput drops to 0.
+
+        * NetworkProcess/Downloads/DownloadMonitor.cpp:
+        (WebKit::DownloadMonitor::measuredThroughputRate const):
+        (WebKit::DownloadMonitor::timerFired):
+
 2019-06-19  Sihui Liu  <[email protected]>
 
         Remove unused originsWithCredentials from WebsiteData

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp (246614 => 246615)


--- trunk/Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp	2019-06-19 23:30:04 UTC (rev 246614)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp	2019-06-19 23:36:35 UTC (rev 246615)
@@ -78,7 +78,7 @@
     Seconds timeDifference = m_timestamps.last().time.secondsSinceEpoch() - m_timestamps.first().time.secondsSinceEpoch();
     double seconds = timeDifference.seconds();
     if (!seconds)
-        return std::numeric_limits<double>::max();
+        return 0;
     return bytes / seconds;
 }
 
@@ -113,6 +113,8 @@
 
 void DownloadMonitor::timerFired()
 {
+    downloadReceivedBytes(0);
+
     RELEASE_ASSERT(m_interval < WTF_ARRAY_LENGTH(throughputIntervals));
     if (measuredThroughputRate() < throughputIntervals[m_interval].bytesPerSecond) {
         RELEASE_LOG_IF_ALLOWED("timerFired: cancelling download (id = %" PRIu64 ")", m_download.downloadID().downloadID());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to