<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201686] trunk/Source/WebInspectorUI</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201686">201686</a></dd>
<dt>Author</dt> <dd>mattbaker@apple.com</dd>
<dt>Date</dt> <dd>2016-06-04 14:09:55 -0700 (Sat, 04 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: discontinuous recordings should have discontinuities in the timeline memory graph
https://bugs.webkit.org/show_bug.cgi?id=158052
&lt;rdar://problem/26516695&gt;

Reviewed by Joseph Pecoraro.

Add gaps to the overview and category line charts where discontinuities
exist in the timeline recording.

* UserInterface/Models/Timeline.js:
(WebInspector.Timeline.prototype.recordsInTimeRange):
Replaces `_visibleRecords` methods found in various views.

* UserInterface/Models/TimelineRecording.js:
(WebInspector.TimelineRecording.prototype.reset):
(WebInspector.TimelineRecording.prototype.addDiscontinuity):
(WebInspector.TimelineRecording.prototype.discontinuitiesInTimeRange):
Allow discontinuities to be added to the recording, and have a means to
look up gaps within a time range.

* UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js:
(WebInspector.HeapAllocationsTimelineOverviewGraph.prototype._visibleRecords): Deleted.
Replaced by Timeline helper method.

* UserInterface/Views/MemoryTimelineOverviewGraph.js:
(WebInspector.MemoryTimelineOverviewGraph.prototype.layout.insertDiscontinuity):
(WebInspector.MemoryTimelineOverviewGraph.prototype.layout):
Insert zero-points into the chart at discontinuity boundaries to create
gaps. Data points for records immediately before or after a gap are extended
to the edge of the discontinuity.

(WebInspector.MemoryTimelineOverviewGraph.prototype._visibleRecords): Deleted.
Replaced by Timeline helper method.

* UserInterface/Views/MemoryTimelineView.js:
(WebInspector.MemoryTimelineView.prototype.layout):
Insert zero-points into each category chart at discontinuity boundaries
to create gaps.

Insert zero-points into the chart to create gaps.
(WebInspector.MemoryTimelineView.prototype._visibleRecords): Deleted.
Replaced by Timeline helper method.

* UserInterface/Views/TimelineOverview.js:
(WebInspector.TimelineOverview.prototype.discontinuitiesInTimeRange):
Forward to the TimelineRecording, which isn't exposed to clients.

* UserInterface/Views/TimelineRecordingContentView.js:
(WebInspector.TimelineRecordingContentView):
(WebInspector.TimelineRecordingContentView.prototype._capturingStarted):
(WebInspector.TimelineRecordingContentView.prototype._capturingStopped):
(WebInspector.TimelineRecordingContentView.prototype._recordingReset):
Track discontinuities (recording stop followed by a start) and add them
to the current recording.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsTimelinejs">trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsTimelineRecordingjs">trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphjs">trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsMemoryTimelineOverviewGraphjs">trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineOverviewGraph.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsMemoryTimelineViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineView.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsTimelineOverviewjs">trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsTimelineRecordingContentViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2016-06-04  Matt Baker  &lt;mattbaker@apple.com&gt;
+
+        Web Inspector: discontinuous recordings should have discontinuities in the timeline memory graph
+        https://bugs.webkit.org/show_bug.cgi?id=158052
+        &lt;rdar://problem/26516695&gt;
+
+        Reviewed by Joseph Pecoraro.
+
+        Add gaps to the overview and category line charts where discontinuities
+        exist in the timeline recording.
+
+        * UserInterface/Models/Timeline.js:
+        (WebInspector.Timeline.prototype.recordsInTimeRange):
+        Replaces `_visibleRecords` methods found in various views.
+
+        * UserInterface/Models/TimelineRecording.js:
+        (WebInspector.TimelineRecording.prototype.reset):
+        (WebInspector.TimelineRecording.prototype.addDiscontinuity):
+        (WebInspector.TimelineRecording.prototype.discontinuitiesInTimeRange):
+        Allow discontinuities to be added to the recording, and have a means to
+        look up gaps within a time range.
+
+        * UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js:
+        (WebInspector.HeapAllocationsTimelineOverviewGraph.prototype._visibleRecords): Deleted.
+        Replaced by Timeline helper method.
+
+        * UserInterface/Views/MemoryTimelineOverviewGraph.js:
+        (WebInspector.MemoryTimelineOverviewGraph.prototype.layout.insertDiscontinuity):
+        (WebInspector.MemoryTimelineOverviewGraph.prototype.layout):
+        Insert zero-points into the chart at discontinuity boundaries to create
+        gaps. Data points for records immediately before or after a gap are extended
+        to the edge of the discontinuity.
+
+        (WebInspector.MemoryTimelineOverviewGraph.prototype._visibleRecords): Deleted.
+        Replaced by Timeline helper method.
+
+        * UserInterface/Views/MemoryTimelineView.js:
+        (WebInspector.MemoryTimelineView.prototype.layout):
+        Insert zero-points into each category chart at discontinuity boundaries
+        to create gaps.
+
+        Insert zero-points into the chart to create gaps.
+        (WebInspector.MemoryTimelineView.prototype._visibleRecords): Deleted.
+        Replaced by Timeline helper method.
+
+        * UserInterface/Views/TimelineOverview.js:
+        (WebInspector.TimelineOverview.prototype.discontinuitiesInTimeRange):
+        Forward to the TimelineRecording, which isn't exposed to clients.
+
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WebInspector.TimelineRecordingContentView):
+        (WebInspector.TimelineRecordingContentView.prototype._capturingStarted):
+        (WebInspector.TimelineRecordingContentView.prototype._capturingStopped):
+        (WebInspector.TimelineRecordingContentView.prototype._recordingReset):
+        Track discontinuities (recording stop followed by a start) and add them
+        to the current recording.
+
</ins><span class="cx"> 2016-06-03  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: add a keyboard shortcut to close the current tab bar item
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsTimelinejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -103,6 +103,18 @@
</span><span class="cx">         this.dispatchEventToListeners(WebInspector.Timeline.Event.Refreshed);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    recordsInTimeRange(startTime, endTime, includeRecordBeforeStart)
+    {
+        let lowerIndex = this._records.lowerBound(startTime, (time, record) =&gt; time - record.timestamp);
+        let upperIndex = this._records.upperBound(endTime, (time, record) =&gt; time - record.timestamp);
+
+        // Include the record right before the start time.
+        if (includeRecordBeforeStart &amp;&amp; lowerIndex &gt; 0)
+            lowerIndex--;
+
+        return this._records.slice(lowerIndex, upperIndex);
+    }
+
</ins><span class="cx">     // Private
</span><span class="cx"> 
</span><span class="cx">     _updateTimesIfNeeded(record)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsTimelineRecordingjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -159,6 +159,7 @@
</span><span class="cx">         this._eventMarkers = [];
</span><span class="cx">         this._startTime = NaN;
</span><span class="cx">         this._endTime = NaN;
</span><ins>+        this._discontinuities = [];
</ins><span class="cx"> 
</span><span class="cx">         this._topDownCallingContextTree.reset();
</span><span class="cx">         this._bottomUpCallingContextTree.reset();
</span><span class="lines">@@ -282,6 +283,16 @@
</span><span class="cx">         memoryTimeline.addMemoryPressureEvent(memoryPressureEvent);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    addDiscontinuity(startTime, endTime)
+    {
+        this._discontinuities.push({startTime, endTime});
+    }
+
+    discontinuitiesInTimeRange(startTime, endTime)
+    {
+        return this._discontinuities.filter((item) =&gt; item.startTime &lt; endTime &amp;&amp; item.endTime &gt; startTime);
+    }
+
</ins><span class="cx">     computeElapsedTime(timestamp)
</span><span class="cx">     {
</span><span class="cx">         if (!timestamp || isNaN(timestamp))
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsHeapAllocationsTimelineOverviewGraphjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineOverviewGraph.js        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx">         this._selectedImageElement = null;
</span><span class="cx"> 
</span><span class="cx">         // This may display records past the current time marker.
</span><del>-        let visibleRecords = this._visibleRecords(this.startTime, this.endTime);
</del><ins>+        let visibleRecords = this._heapAllocations.recordsInTimeRange(this.startTime, this.endTime);
</ins><span class="cx">         if (!visibleRecords.length)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -114,14 +114,6 @@
</span><span class="cx">         this._selectedImageElement = imageElement;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _visibleRecords(startTime, endTime)
-    {
-        let records = this._heapAllocationsTimeline.records;
-        let lowerIndex = records.lowerBound(startTime, (time, record) =&gt; time - record.timestamp);
-        let upperIndex = records.upperBound(endTime, (time, record) =&gt; time - record.timestamp);
-        return records.slice(lowerIndex, upperIndex);
-    }
-
</del><span class="cx">     _heapAllocationTimelineRecordAdded(event)
</span><span class="cx">     {
</span><span class="cx">         this.needsLayout();
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsMemoryTimelineOverviewGraphjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineOverviewGraph.js (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineOverviewGraph.js        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineOverviewGraph.js        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -133,7 +133,13 @@
</span><span class="cx">                 element.remove();
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        let visibleRecords = this._visibleRecords(graphStartTime, visibleEndTime);
</del><ins>+        let discontinuities = this.timelineOverview.discontinuitiesInTimeRange(graphStartTime, visibleEndTime);
+
+        // Don't include the record before the graph start if the graph start is within a gap.
+        let includeRecordBeforeStart = !discontinuities.length || discontinuities[0].startTime &gt; graphStartTime;
+
+        // FIXME: &lt;https://webkit.org/b/153759&gt; Web Inspector: Memory Timelines should better extend to future data
+        let visibleRecords = this._memoryTimeline.recordsInTimeRange(graphStartTime, visibleEndTime, includeRecordBeforeStart);
</ins><span class="cx">         if (!visibleRecords.length)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -148,19 +154,59 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Extend the first record to the start so it doesn't look like we originate at zero size.
</span><del>-        if (visibleRecords[0] === this._memoryTimeline.records[0])
</del><ins>+        if (visibleRecords[0] === this._memoryTimeline.records[0] &amp;&amp; (!discontinuities.length || discontinuities[0].startTime &gt; visibleRecords[0].startTime))
</ins><span class="cx">             this._chart.addPointSet(0, pointSetForRecord(visibleRecords[0]));
</span><span class="cx"> 
</span><ins>+        function insertDiscontinuity(previousRecord, discontinuity, nextRecord)
+        {
+            console.assert(previousRecord || nextRecord);
+            if (!(previousRecord || nextRecord))
+                return;
+
+            let xStart = xScale(discontinuity.startTime);
+            let xEnd = xScale(discontinuity.endTime);
+
+            // Extend the previous record to the start of the discontinuity.
+            if (previousRecord)
+                this._chart.addPointSet(xStart, pointSetForRecord(previousRecord));
+
+            let zeroValues = Array((previousRecord || nextRecord).categories.length).fill(yScale(0));
+            this._chart.addPointSet(xStart, zeroValues);
+
+            if (nextRecord) {
+                this._chart.addPointSet(xEnd, zeroValues);
+                this._chart.addPointSet(xEnd, pointSetForRecord(nextRecord));
+            } else {
+                // Extend the discontinuity to the visible end time to prevent
+                // drawing artifacts when the next record arrives.
+                this._chart.addPointSet(xScale(visibleEndTime), zeroValues);
+            }
+        }
+
</ins><span class="cx">         // Points for visible records.
</span><ins>+        let previousRecord = null;
</ins><span class="cx">         for (let record of visibleRecords) {
</span><ins>+            if (discontinuities.length &amp;&amp; discontinuities[0].endTime &lt; record.startTime) {
+                let discontinuity = discontinuities.shift();
+                insertDiscontinuity.call(this, previousRecord, discontinuity, record);
+            }
+
</ins><span class="cx">             let x = xScale(record.startTime);
</span><span class="cx">             this._chart.addPointSet(x, pointSetForRecord(record));
</span><ins>+
+            previousRecord = record;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // Extend the last value to current / end time.
-        let lastRecord = visibleRecords.lastValue;
-        let x = Math.floor(xScale(visibleEndTime));
-        this._chart.addPointSet(x, pointSetForRecord(lastRecord));
</del><ins>+        if (discontinuities.length)
+            insertDiscontinuity.call(this, previousRecord, discontinuities[0], null);
+        else {
+            // Extend the last value to current / end time.
+            let lastRecord = visibleRecords.lastValue;
+            if (lastRecord.startTime &lt;= visibleEndTime) {
+                let x = Math.floor(xScale(visibleEndTime));
+                this._chart.addPointSet(x, pointSetForRecord(lastRecord));
+            }
+        }
</ins><span class="cx"> 
</span><span class="cx">         this._chart.updateLayout();
</span><span class="cx">     }
</span><span class="lines">@@ -194,22 +240,6 @@
</span><span class="cx">         return events.slice(lowerIndex, upperIndex);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _visibleRecords(startTime, endTime)
-    {
-        let records = this._memoryTimeline.records;
-        let lowerIndex = records.lowerBound(startTime, (time, record) =&gt; time - record.timestamp);
-        let upperIndex = records.upperBound(endTime, (time, record) =&gt; time - record.timestamp);
-
-        // Include the record right before the start time in case it extends into this range.
-        if (lowerIndex &gt; 0)
-            lowerIndex--;
-        // FIXME: &lt;https://webkit.org/b/153759&gt; Web Inspector: Memory Timelines should better extend to future data
-        // if (upperIndex !== records.length)
-        //     upperIndex++;
-
-        return records.slice(lowerIndex, upperIndex);
-    }
-
</del><span class="cx">     _memoryTimelineRecordAdded(event)
</span><span class="cx">     {
</span><span class="cx">         let memoryTimelineRecord = event.data.record;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsMemoryTimelineViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineView.js (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineView.js        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineView.js        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -29,6 +29,8 @@
</span><span class="cx">     {
</span><span class="cx">         super(timeline, extraArguments);
</span><span class="cx"> 
</span><ins>+        this._recording = extraArguments.recording;
+
</ins><span class="cx">         console.assert(timeline.type === WebInspector.TimelineRecord.Type.Memory, timeline);
</span><span class="cx"> 
</span><span class="cx">         this.element.classList.add(&quot;memory&quot;);
</span><span class="lines">@@ -175,7 +177,13 @@
</span><span class="cx">         let graphCurrentTime = this.currentTime;
</span><span class="cx">         let visibleEndTime = Math.min(this.endTime, this.currentTime);
</span><span class="cx"> 
</span><del>-        let visibleRecords = this._visibleRecords(graphStartTime, visibleEndTime);
</del><ins>+        let discontinuities = this._recording.discontinuitiesInTimeRange(graphStartTime, visibleEndTime);
+
+        // Don't include the record before the graph start if the graph start is within a gap.
+        let includeRecordBeforeStart = !discontinuities.length || discontinuities[0].startTime &gt; graphStartTime;
+
+        // FIXME: &lt;https://webkit.org/b/153759&gt; Web Inspector: Memory Timelines should better extend to future data
+        let visibleRecords = this.representedObject.recordsInTimeRange(graphStartTime, visibleEndTime, includeRecordBeforeStart);
</ins><span class="cx">         if (!visibleRecords.length)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -205,14 +213,35 @@
</span><span class="cx"> 
</span><span class="cx">         for (let record of visibleRecords) {
</span><span class="cx">             let time = record.startTime;
</span><ins>+            let discontinuity = null;
+            if (discontinuities.length &amp;&amp; discontinuities[0].endTime &lt; time)
+                discontinuity = discontinuities.shift();
+
</ins><span class="cx">             for (let category of record.categories) {
</span><span class="cx">                 let categoryData = categoryDataMap[category.type];
</span><ins>+
+                if (discontinuity) {
+                    if (categoryData.dataPoints.length) {
+                        let previousDataPoint = categoryData.dataPoints.lastValue;
+                        categoryData.dataPoints.push({time: discontinuity.startTime, size: previousDataPoint.size});
+                    }
+
+                    categoryData.dataPoints.push({time: discontinuity.startTime, size: 0});
+                    categoryData.dataPoints.push({time: discontinuity.endTime, size: 0});
+                    categoryData.dataPoints.push({time: discontinuity.endTime, size: category.size});
+                }
+
</ins><span class="cx">                 categoryData.dataPoints.push({time, size: category.size});
</span><span class="cx">                 categoryData.max = Math.max(categoryData.max, category.size);
</span><span class="cx">                 categoryData.min = Math.min(categoryData.min, category.size);
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        // If the graph end time is inside a gap, the last data point should
+        // only be extended to the start of the discontinuity.
+        if (discontinuities.length)
+            visibleEndTime = discontinuities[0].startTime;
+
</ins><span class="cx">         function layoutCategoryView(categoryView, categoryData) {
</span><span class="cx">             let {dataPoints, min, max} = categoryData;
</span><span class="cx"> 
</span><span class="lines">@@ -314,22 +343,6 @@
</span><span class="cx">         totalElement.textContent = (percent === 100 ? percent : (percent - 0.05).toFixed(1)) + &quot;%&quot;;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _visibleRecords(startTime, endTime)
-    {
-        let records = this.representedObject.records;
-        let lowerIndex = records.lowerBound(startTime, (time, record) =&gt; time - record.timestamp);
-        let upperIndex = records.upperBound(endTime, (time, record) =&gt; time - record.timestamp);
-
-        // Include the record right before the start time in case it extends into this range.
-        if (lowerIndex &gt; 0)
-            lowerIndex--;
-        // FIXME: &lt;https://webkit.org/b/153759&gt; Web Inspector: Memory Timelines should better extend to future data
-        // if (upperIndex !== records.length)
-        //     upperIndex++;
-
-        return records.slice(lowerIndex, upperIndex);
-    }
-
</del><span class="cx">     _initializeCategoryViews(record)
</span><span class="cx">     {
</span><span class="cx">         console.assert(!this._didInitializeCategories, &quot;Should only initialize category views once&quot;);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsTimelineOverviewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -422,6 +422,11 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    discontinuitiesInTimeRange(startTime, endTime)
+    {
+        return this._recording.discontinuitiesInTimeRange(startTime, endTime);
+    }
+
</ins><span class="cx">     // Protected
</span><span class="cx"> 
</span><span class="cx">     get timelineRuler()
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsTimelineRecordingContentViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (201685 => 201686)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js        2016-06-04 20:59:57 UTC (rev 201685)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js        2016-06-04 21:09:55 UTC (rev 201686)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> 
</span><span class="cx">         this._updating = false;
</span><span class="cx">         this._currentTime = NaN;
</span><ins>+        this._discontinuityStartTime = NaN;
</ins><span class="cx">         this._lastUpdateTimestamp = NaN;
</span><span class="cx">         this._startTimeNeedsReset = true;
</span><span class="cx">         this._renderingFrameTimeline = null;
</span><span class="lines">@@ -470,9 +471,18 @@
</span><span class="cx">     {
</span><span class="cx">         this._updateProgressView();
</span><span class="cx"> 
</span><ins>+        let startTime = event.data.startTime;
</ins><span class="cx">         if (!this._updating)
</span><del>-            this._startUpdatingCurrentTime(event.data.startTime);
</del><ins>+            this._startUpdatingCurrentTime(startTime);
</ins><span class="cx">         this._clearTimelineNavigationItem.enabled = !this._recording.readonly;
</span><ins>+
+        // A discontinuity occurs when the recording is stopped and resumed at
+        // a future time. Capturing started signals the end of the current
+        // discontinuity, if one exists.
+        if (!isNaN(this._discontinuityStartTime)) {
+            this._recording.addDiscontinuity(this._discontinuityStartTime, startTime);
+            this._discontinuityStartTime = NaN;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     _capturingStopped(event)
</span><span class="lines">@@ -484,6 +494,8 @@
</span><span class="cx"> 
</span><span class="cx">         if (this.currentTimelineView)
</span><span class="cx">             this._updateTimelineViewTimes(this.currentTimelineView);
</span><ins>+
+        this._discontinuityStartTime = event.data.endTime || this._currentTime;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     _debuggerPaused(event)
</span><span class="lines">@@ -603,6 +615,7 @@
</span><span class="cx">     _recordingReset(event)
</span><span class="cx">     {
</span><span class="cx">         this._currentTime = NaN;
</span><ins>+        this._discontinuityStartTime = NaN;
</ins><span class="cx"> 
</span><span class="cx">         if (!this._updating) {
</span><span class="cx">             // Force the time ruler and views to reset to 0.
</span></span></pre>
</div>
</div>

</body>
</html>