Changeset 218781 in webkit


Ignore:
Timestamp:
Jun 23, 2017 7:45:51 PM (7 years ago)
Author:
Joseph Pecoraro
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.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r218777 r218781  
     12017-06-23  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Script Timeline bubbles sometimes appear to miss large events
     4        https://bugs.webkit.org/show_bug.cgi?id=173746
     5        <rdar://problem/32950808>
     6
     7        Reviewed by Brian Burg.
     8
     9        * UserInterface/Models/Timeline.js:
     10        (WebInspector.Timeline.prototype.addRecord):
     11        (WebInspector.Timeline.prototype._tryInsertInSortedOrder):
     12        The list of records is assumed to be sorted by the code that draws bubbles
     13        however the order in which we receive them may not be sorted. Make a quick
     14        effort to sort recent records so that as we are drawing the timeline it is
     15        more accurate.
     16
    1172017-06-23  Brian Burg  <bburg@apple.com>
    218
  • trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js

    r204507 r218781  
    7272            record.addEventListener(WebInspector.TimelineRecord.Event.Updated, this._recordUpdated, this);
    7373
    74         this._records.push(record);
     74        // Because records can be nested, it is possible that outer records with an early start time
     75        // may be completed and added to the Timeline after inner records with a later start time
     76        // were already added. In most cases this is a small drift, so make an effort to still keep
     77        // the list sorted. Do it now, when inserting, so if the timeline is visible it has the
     78        // best chance of being as accurate as possible during a recording.
     79        this._tryInsertingRecordInSortedOrder(record);
    7580
    7681        this._updateTimesIfNeeded(record);
     
    125130        this._updateTimesIfNeeded(event.target);
    126131    }
     132
     133    _tryInsertingRecordInSortedOrder(record)
     134    {
     135        // Fast case add to the end.
     136        let lastValue = this._records.lastValue;
     137        if (!lastValue || lastValue.startTime < record.startTime || record.updatesDynamically) {
     138            this._records.push(record);
     139            return;
     140        }
     141
     142        // Slow case, try to insert in the last 20 records.
     143        let start = this._records.length - 2;
     144        let end = Math.max(this._records.length - 20, 0);
     145        for (let i = start; i >= end; --i) {
     146            if (this._records[i].startTime < record.startTime) {
     147                this._records.insertAtIndex(record, i + 1);
     148                return;
     149            }
     150        }
     151
     152        // Give up and add to the end.
     153        this._records.push(record);
     154    }
    127155};
    128156
Note: See TracChangeset for help on using the changeset viewer.