Title: [218781] trunk/Source/WebInspectorUI
Revision
218781
Author
[email protected]
Date
2017-06-23 19:45:51 -0700 (Fri, 23 Jun 2017)

Log Message

Web Inspector: Script Timeline bubbles sometimes appear to miss large events
https://bugs.webkit.org/show_bug.cgi?id=173746
<rdar://problem/32950808>

Reviewed by Brian Burg.

* UserInterface/Models/Timeline.js:
(WebInspector.Timeline.prototype.addRecord):
(WebInspector.Timeline.prototype._tryInsertInSortedOrder):
The list of records is assumed to be sorted by the code that draws bubbles
however the order in which we receive them may not be sorted. Make a quick
effort to sort recent records so that as we are drawing the timeline it is
more accurate.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (218780 => 218781)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-06-24 02:19:06 UTC (rev 218780)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-06-24 02:45:51 UTC (rev 218781)
@@ -1,3 +1,19 @@
+2017-06-23  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Script Timeline bubbles sometimes appear to miss large events
+        https://bugs.webkit.org/show_bug.cgi?id=173746
+        <rdar://problem/32950808>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Models/Timeline.js:
+        (WebInspector.Timeline.prototype.addRecord):
+        (WebInspector.Timeline.prototype._tryInsertInSortedOrder):
+        The list of records is assumed to be sorted by the code that draws bubbles
+        however the order in which we receive them may not be sorted. Make a quick
+        effort to sort recent records so that as we are drawing the timeline it is
+        more accurate.
+
 2017-06-23  Brian Burg  <[email protected]>
 
         Web Inspector: RTL: flip all go-to-arrow instances

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js (218780 => 218781)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js	2017-06-24 02:19:06 UTC (rev 218780)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js	2017-06-24 02:45:51 UTC (rev 218781)
@@ -71,7 +71,12 @@
         if (record.updatesDynamically)
             record.addEventListener(WebInspector.TimelineRecord.Event.Updated, this._recordUpdated, this);
 
-        this._records.push(record);
+        // Because records can be nested, it is possible that outer records with an early start time
+        // may be completed and added to the Timeline after inner records with a later start time
+        // were already added. In most cases this is a small drift, so make an effort to still keep
+        // the list sorted. Do it now, when inserting, so if the timeline is visible it has the
+        // best chance of being as accurate as possible during a recording.
+        this._tryInsertingRecordInSortedOrder(record);
 
         this._updateTimesIfNeeded(record);
 
@@ -124,6 +129,29 @@
     {
         this._updateTimesIfNeeded(event.target);
     }
+
+    _tryInsertingRecordInSortedOrder(record)
+    {
+        // Fast case add to the end.
+        let lastValue = this._records.lastValue;
+        if (!lastValue || lastValue.startTime < record.startTime || record.updatesDynamically) {
+            this._records.push(record);
+            return;
+        }
+
+        // Slow case, try to insert in the last 20 records.
+        let start = this._records.length - 2;
+        let end = Math.max(this._records.length - 20, 0);
+        for (let i = start; i >= end; --i) {
+            if (this._records[i].startTime < record.startTime) {
+                this._records.insertAtIndex(record, i + 1);
+                return;
+            }
+        }
+
+        // Give up and add to the end.
+        this._records.push(record);
+    }
 };
 
 WebInspector.Timeline.Event = {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to