Bug 1198582 - Buffer percentage should never be a negative value. r=vp
authorJordan Santell <jsantell@mozilla.com>
Wed, 26 Aug 2015 10:43:49 -0700
changeset 260030 b22743d8ef64b3206e57807af088a5b843589381
parent 260029 944ac81b4b761ab2ee7a5e7261ce88bcac3be20e
child 260031 59435b91dd8c14d7a7161ba0929a867c70083f11
push id29298
push userryanvm@gmail.com
push dateMon, 31 Aug 2015 02:09:10 +0000
treeherdermozilla-central@f2518b8a7b97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvp
bugs1198582
milestone43.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 1198582 - Buffer percentage should never be a negative value. r=vp
toolkit/devtools/server/actors/performance.js
--- a/toolkit/devtools/server/actors/performance.js
+++ b/toolkit/devtools/server/actors/performance.js
@@ -206,17 +206,22 @@ const PerformanceFront = exports.Perform
     if (!recording.isRecording()) {
       return void 0;
     }
     let { position: currentPosition, totalSize, generation: currentGeneration } = this._currentBufferStatus;
     let { position: origPosition, generation: origGeneration } = recording.getStartingBufferStatus();
 
     let normalizedCurrent = (totalSize * (currentGeneration - origGeneration)) + currentPosition;
     let percent = (normalizedCurrent - origPosition) / totalSize;
-    return percent > 1 ? 1 : percent;
+
+    // Clamp between 0 and 1; can get negative percentage values when a new
+    // recording starts and the currentBufferStatus has not yet been updated. Rather
+    // than fetching another status update, just clamp to 0, and this will be updated
+    // on the next profiler-status event.
+    return percent > 1 ? 1 : percent < 0 ? 0 : percent;
   },
 
   /**
    * Loads a recording from a file.
    *
    * @param {nsILocalFile} file
    *        The file to import the data from.
    * @return {Promise<PerformanceRecordingFront>}