Bug 1531179 - [1.1] Remove noisy data-received signal and simplify page load progress tracking. r=snorp
authorEugen Sawin <esawin@me73.com>
Wed, 06 Mar 2019 15:34:32 +0000
changeset 520499 b6b1d95ca7805be4716271947d716e17b0c84f92
parent 520498 a28ae4304209412e0cb5256dfa4ef1169c8e42dd
child 520500 8a2800ad38adc98d863bcc4effc52d84aaa105c4
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1531179
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531179 - [1.1] Remove noisy data-received signal and simplify page load progress tracking. r=snorp Differential Revision: https://phabricator.services.mozilla.com/D21465
mobile/android/chrome/geckoview/GeckoViewProgressChild.js
--- a/mobile/android/chrome/geckoview/GeckoViewProgressChild.js
+++ b/mobile/android/chrome/geckoview/GeckoViewProgressChild.js
@@ -13,35 +13,27 @@ const PAGE_LOAD_PROGRESS_PROBE =
 const PAGE_LOAD_PROBE = new HistogramStopwatch("GV_PAGE_LOAD_MS", content);
 
 class GeckoViewProgressChild extends GeckoViewChildModule {
   onInit() {
     debug `onInit`;
 
     ProgressTracker.onInit(this);
 
-    const flags = Ci.nsIWebProgress.NOTIFY_PROGRESS |
-                  Ci.nsIWebProgress.NOTIFY_STATE_NETWORK |
+    const flags = Ci.nsIWebProgress.NOTIFY_STATE_NETWORK |
                   Ci.nsIWebProgress.NOTIFY_LOCATION;
     this.progressFilter =
       Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
       .createInstance(Ci.nsIWebProgress);
     this.progressFilter.addProgressListener(this, flags);
     const webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIWebProgress);
     webProgress.addProgressListener(this.progressFilter, flags);
   }
 
-  onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
-    debug `onProgressChange ${aCurSelf}/${aMaxSelf} ${aCurTotal}/${aMaxTotal}`;
-
-    ProgressTracker.handleProgress(null, aCurTotal, aMaxTotal);
-    ProgressTracker.updateProgress();
-  }
-
   onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
     debug `onStateChange: isTopLevel=${aWebProgress.isTopLevel},
                           flags=${aStateFlags}, status=${aStatus}`;
 
     if (!aWebProgress || !aWebProgress.isTopLevel) {
       return;
     }
 
@@ -203,135 +195,69 @@ const ProgressTracker = {
       prev: 0,
       uri: null,
       locationChange: false,
       pageStart: false,
       pageStop: false,
       firstPaint: false,
       pageShow: false,
       parsed: false,
-      totalReceived: 1,
-      totalExpected: 1,
-      channels: {},
     };
   },
 
   _debugData: function() {
     return {
       prev: this._data.prev,
       uri: this._data.uri,
       locationChange: this._data.locationChange,
       pageStart: this._data.pageStart,
       pageStop: this._data.pageStop,
       firstPaint: this._data.firstPaint,
       pageShow: this._data.pageShow,
       parsed: this._data.parsed,
-      totalReceived: this._data.totalReceived,
-      totalExpected: this._data.totalExpected,
     };
   },
 
-  handleProgress: function(aChannelUri, aProgress, aMax) {
-    debug `ProgressTracker handleProgress ${aChannelUri} ${aProgress}/${aMax}`;
-
-    let data = this._data;
-
-    if (!data.uri) {
-      return;
-    }
-
-    aChannelUri = aChannelUri || data.uri;
-
-    const now = content.performance.now();
-
-    if (!data.channels[aChannelUri]) {
-      data.channels[aChannelUri] = {
-        received: aProgress,
-        max: aMax,
-        expected: (aMax > 0 ? aMax : aProgress * 2),
-        lastUpdate: now,
-      };
-    } else {
-      let channelProgress = data.channels[aChannelUri];
-      channelProgress.received = Math.max(channelProgress.received, aProgress);
-      channelProgress.expected = Math.max(channelProgress.expected, aMax);
-      channelProgress.lastUpdate = now;
-    }
-  },
-
   updateProgress: function() {
     debug `ProgressTracker updateProgress`;
 
     let data = this._data;
 
     if (!this._tracking || !data.uri) {
       return;
     }
 
-    const now = content.performance.now();
-
     let progress = 0;
-
-    if (data.pageStart) {
-      progress += 10;
-    }
-    if (data.firstPaint) {
-      progress += 15;
-    }
-    if (data.parsed) {
-      progress += 15;
-    }
-    if (data.pageShow) {
-      progress += 15;
-    }
-    if (data.locationChange) {
-      progress += 10;
+    if (data.pageStop || data.pageShow) {
+      progress = 100;
+    } else if (data.firstPaint) {
+      progress = 80;
+    } else if (data.parsed) {
+      progress = 55;
+    } else if (data.locationChange) {
+      progress = 30;
+    } else if (data.pageStart) {
+      progress = 15;
     }
 
-    data.totalReceived = 1;
-    data.totalExpected = 1;
-    const channelOverdue = now - 300;
-
-    for (let channel in data.channels) {
-      if (data.channels[channel].max < 1 &&
-          channelOverdue > data.channels[channel].lastUpdate) {
-        data.channels[channel].expected = data.channels[channel].received;
-      }
-      data.totalReceived += data.channels[channel].received;
-      data.totalExpected += data.channels[channel].expected;
-    }
-
-    const minExpected = 1024 * 1;
-    const maxExpected = 1024 * 1024 * 0.5;
-
-    if (data.pageStop ||
-        (data.pageStart && data.firstPaint && data.parsed && data.pageShow &&
-         data.totalReceived > minExpected &&
-         data.totalReceived >= data.totalExpected)) {
-      progress = 100;
-    } else {
-      const a = Math.min(1, (data.totalExpected / maxExpected)) * 30;
-      progress += data.totalReceived / data.totalExpected * a;
+    if (data.prev >= progress) {
+      return;
     }
 
     debug `ProgressTracker updateProgress data=${this._debugData()}
            progress=${progress}`;
 
-    if (data.prev >= progress) {
-      return;
-    }
-
     this.eventDispatcher.sendRequest({
       type: "GeckoView:ProgressChanged",
       progress,
     });
 
     data.prev = progress;
 
-    if (progress === 100) {
+    if (progress >= 100) {
       PAGE_LOAD_PROGRESS_PROBE.finish();
     }
   },
 };
 
 
 const {debug, warn} = GeckoViewProgressChild.initLogging("GeckoViewProgress"); // eslint-disable-line no-unused-vars
 const module = GeckoViewProgressChild.create(this);