Changeset 247033 in webkit


Ignore:
Timestamp:
Jul 1, 2019 6:17:50 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: REGRESSION(r245498): Timelines: CPU: discontinuities are filled in by the next record
https://bugs.webkit.org/show_bug.cgi?id=198927

Reviewed by Matt Baker.

Source/WebInspectorUI:

  • UserInterface/Controllers/TimelineManager.js:

(WI.TimelineManager.prototype.capturingStarted):
(WI.TimelineManager.prototype.capturingStopped):

  • UserInterface/Models/TimelineRecording.js:

(WI.TimelineRecording):
(WI.TimelineRecording.prototype.start):
(WI.TimelineRecording.prototype.capturingStarted): Added.
(WI.TimelineRecording.prototype.capturingStopped): Added.
(WI.TimelineRecording.prototype.reset):
(WI.TimelineRecording.prototype.addRecord):
(WI.TimelineRecording.prototype.discontinuitiesInTimeRange):
(WI.TimelineRecording.prototype.addDiscontinuity): Deleted.
Notify the TimelineRecording when capturing has started/stopped.
Adjust the first record after a discontinuity to have it's startTime match the endTime
of the most recent discontinuity.

  • UserInterface/Models/Timeline.js:

(WI.Timeline.prototype.addRecord):

  • UserInterface/Models/CPUTimeline.js:

(WI.CPUTimeline.prototype.addRecord):

  • UserInterface/Models/CPUTimelineRecord.js:

(WI.CPUTimelineRecord.prototype.adjustStartTime): Added.
(WI.CPUTimelineRecord.prototype.adjustStartTimeToLastRecord): Deleted.

  • UserInterface/Models/MemoryTimeline.js:

(WI.MemoryTimeline.prototype.addRecord):

  • UserInterface/Models/MemoryTimelineRecord.js:

(WI.MemoryTimelineRecord.prototype.adjustStartTime): Added.
(WI.MemoryTimelineRecord.prototype.adjustStartTimeToLastRecord): Deleted.

  • UserInterface/Models/NetworkTimeline.js:

(WI.NetworkTimeline.prototype.addRecord):

  • UserInterface/Views/CPUTimelineView.js:

(WI.CPUTimelineView.prototype.layout):

  • UserInterface/Views/MemoryTimelineOverviewGraph.js:

(WI.MemoryTimelineOverviewGraph.prototype.layout):

  • UserInterface/Views/MemoryTimelineView.js:

(WI.MemoryTimelineView.prototype.layout):
Include discontinuities that exactly match the start/end time of the record immediately
before/after the discontinuity.

  • UserInterface/Views/TimelineRecordingContentView.js:

(WI.TimelineRecordingContentView):
(WI.TimelineRecordingContentView.prototype._handleTimelineCapturingStateChanged):
(WI.TimelineRecordingContentView.prototype._recordingReset):
Move the logic for handling discontinuity start/end times to the TimelineRecording.

  • UserInterface/Base/Utilities.js:

LayoutTests:

  • inspector/unit-tests/set-utilities.html:
  • inspector/unit-tests/set-utilities-expected.txt:
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247031 r247033  
     12019-07-01  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: REGRESSION(r245498): Timelines: CPU: discontinuities are filled in by the next record
     4        https://bugs.webkit.org/show_bug.cgi?id=198927
     5
     6        Reviewed by Matt Baker.
     7
     8        * inspector/unit-tests/set-utilities.html:
     9        * inspector/unit-tests/set-utilities-expected.txt:
     10
    1112019-07-01  Russell Epstein  <russell_e@apple.com>
    212
  • trunk/LayoutTests/inspector/unit-tests/set-utilities-expected.txt

    r244154 r247033  
    11
    22== Running test suite: Set
     3-- Running test case: Set.prototype.take
     4PASS: Set can take `key`.
     5PASS: Set no longer has `key`.
     6PASS: Set can NOT take `key`.
     7PASS: Set can NOT take `DNE`, as it does NOT exist.
     8
    39-- Running test case: Set.prototype.intersects
    410PASS: an empty set should not intersect another empty set.
  • trunk/LayoutTests/inspector/unit-tests/set-utilities.html

    r244154 r247033  
    77{
    88    let suite = InspectorTest.createSyncSuite("Set");
     9
     10    suite.addTestCase({
     11        name: "Set.prototype.take",
     12        test() {
     13            const key = "key";
     14
     15            let set = new Set;
     16            set.add(key);
     17            InspectorTest.expectTrue(set.take(key), "Set can take `key`.");
     18            InspectorTest.expectFalse(set.has(key), "Set no longer has `key`.");
     19            InspectorTest.expectFalse(set.take(key), "Set can NOT take `key`.");
     20            InspectorTest.expectFalse(set.take("DNE"), "Set can NOT take `DNE`, as it does NOT exist.");
     21        }
     22    });
    923
    1024    suite.addTestCase({
  • trunk/Source/WebInspectorUI/ChangeLog

    r246953 r247033  
     12019-07-01  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: REGRESSION(r245498): Timelines: CPU: discontinuities are filled in by the next record
     4        https://bugs.webkit.org/show_bug.cgi?id=198927
     5
     6        Reviewed by Matt Baker.
     7
     8        * UserInterface/Controllers/TimelineManager.js:
     9        (WI.TimelineManager.prototype.capturingStarted):
     10        (WI.TimelineManager.prototype.capturingStopped):
     11        * UserInterface/Models/TimelineRecording.js:
     12        (WI.TimelineRecording):
     13        (WI.TimelineRecording.prototype.start):
     14        (WI.TimelineRecording.prototype.capturingStarted): Added.
     15        (WI.TimelineRecording.prototype.capturingStopped): Added.
     16        (WI.TimelineRecording.prototype.reset):
     17        (WI.TimelineRecording.prototype.addRecord):
     18        (WI.TimelineRecording.prototype.discontinuitiesInTimeRange):
     19        (WI.TimelineRecording.prototype.addDiscontinuity): Deleted.
     20        Notify the `TimelineRecording` when capturing has started/stopped.
     21        Adjust the first record after a discontinuity to have it's `startTime` match the `endTime`
     22        of the most recent discontinuity.
     23
     24        * UserInterface/Models/Timeline.js:
     25        (WI.Timeline.prototype.addRecord):
     26        * UserInterface/Models/CPUTimeline.js:
     27        (WI.CPUTimeline.prototype.addRecord):
     28        * UserInterface/Models/CPUTimelineRecord.js:
     29        (WI.CPUTimelineRecord.prototype.adjustStartTime): Added.
     30        (WI.CPUTimelineRecord.prototype.adjustStartTimeToLastRecord): Deleted.
     31        * UserInterface/Models/MemoryTimeline.js:
     32        (WI.MemoryTimeline.prototype.addRecord):
     33        * UserInterface/Models/MemoryTimelineRecord.js:
     34        (WI.MemoryTimelineRecord.prototype.adjustStartTime): Added.
     35        (WI.MemoryTimelineRecord.prototype.adjustStartTimeToLastRecord): Deleted.
     36        * UserInterface/Models/NetworkTimeline.js:
     37        (WI.NetworkTimeline.prototype.addRecord):
     38
     39        * UserInterface/Views/CPUTimelineView.js:
     40        (WI.CPUTimelineView.prototype.layout):
     41        * UserInterface/Views/MemoryTimelineOverviewGraph.js:
     42        (WI.MemoryTimelineOverviewGraph.prototype.layout):
     43        * UserInterface/Views/MemoryTimelineView.js:
     44        (WI.MemoryTimelineView.prototype.layout):
     45        Include discontinuities that exactly match the start/end time of the record immediately
     46        before/after the discontinuity.
     47
     48        * UserInterface/Views/TimelineRecordingContentView.js:
     49        (WI.TimelineRecordingContentView):
     50        (WI.TimelineRecordingContentView.prototype._handleTimelineCapturingStateChanged):
     51        (WI.TimelineRecordingContentView.prototype._recordingReset):
     52        Move the logic for handling discontinuity start/end times to the `TimelineRecording`.
     53
     54        * UserInterface/Base/Utilities.js:
     55
    1562019-06-29  Nikita Vasilyev  <nvasilyev@apple.com>
    257
  • trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js

    r246271 r247033  
    147147});
    148148
     149Object.defineProperty(Set.prototype, "take",
     150{
     151    value(key)
     152    {
     153        let exists = this.has(key);
     154        if (exists)
     155            this.delete(key);
     156        return exists;
     157    }
     158});
     159
    149160Object.defineProperty(Set.prototype, "equals",
    150161{
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js

    r244933 r247033  
    356356        this._webTimelineScriptRecordsExpectingScriptProfilerEvents = [];
    357357
     358        this._activeRecording.capturingStarted(this._capturingStartTime);
     359
    358360        WI.settings.timelinesAutoStop.addEventListener(WI.Setting.Event.Changed, this._handleTimelinesAutoStopSettingChanged, this);
    359361
     
    400402        WI.Frame.removeEventListener(WI.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);
    401403        WI.settings.timelinesAutoStop.removeEventListener(null, null, this);
     404
     405        this._activeRecording.capturingStopped(this._capturingEndTime);
    402406
    403407        this.relaxAutoStop();
  • trunk/Source/WebInspectorUI/UserInterface/Models/CPUTimeline.js

    r245498 r247033  
    2828    // Public
    2929
    30     addRecord(record)
     30    addRecord(record, options = {})
    3131    {
    3232        let lastRecord = this.records.lastValue;
    33         if (lastRecord)
    34             record.adjustStartTimeToLastRecord(lastRecord);
     33        if (lastRecord) {
     34            let startTime = lastRecord.endTime;
     35            if (options.discontinuity)
     36                startTime = options.discontinuity.endTime;
     37            record.adjustStartTime(startTime);
     38        }
    3539
    36         super.addRecord(record);
     40        super.addRecord(record, options);
    3741    }
    3842};
  • trunk/Source/WebInspectorUI/UserInterface/Models/CPUTimelineRecord.js

    r245498 r247033  
    105105    get workersData() { return this._workersData; }
    106106
    107     adjustStartTimeToLastRecord(lastRecord)
     107    adjustStartTime(startTime)
    108108    {
    109         console.assert(lastRecord instanceof CPUTimelineRecord);
    110         console.assert(this._startTime >= lastRecord.endTime);
    111         this._startTime = lastRecord.endTime;
     109        console.assert(startTime < this._endTime);
     110        this._startTime = startTime;
    112111    }
    113112};
  • trunk/Source/WebInspectorUI/UserInterface/Models/MemoryTimeline.js

    r245498 r247033  
    4848    }
    4949
    50     addRecord(record)
     50    addRecord(record, options = {})
    5151    {
    5252        let lastRecord = this.records.lastValue;
    53         if (lastRecord)
    54             record.adjustStartTimeToLastRecord(lastRecord);
     53        if (lastRecord) {
     54            let startTime = lastRecord.endTime;
     55            if (options.discontinuity)
     56                startTime = options.discontinuity.endTime;
     57            record.adjustStartTime(startTime);
     58        }
    5559
    56         super.addRecord(record);
     60        super.addRecord(record, options);
    5761    }
    5862};
  • trunk/Source/WebInspectorUI/UserInterface/Models/MemoryTimelineRecord.js

    r245498 r247033  
    110110    get totalSize() { return this._totalSize; }
    111111
    112     adjustStartTimeToLastRecord(lastRecord)
     112    adjustStartTime(startTime)
    113113    {
    114         console.assert(lastRecord instanceof MemoryTimelineRecord);
    115         console.assert(this._startTime >= lastRecord.endTime);
    116         this._startTime = lastRecord.endTime;
     114        console.assert(startTime < this._endTime);
     115        this._startTime = startTime;
    117116    }
    118117};
  • trunk/Source/WebInspectorUI/UserInterface/Models/NetworkTimeline.js

    r220119 r247033  
    4242    }
    4343
    44     addRecord(record)
     44    addRecord(record, options = {})
    4545    {
    4646        console.assert(record instanceof WI.ResourceTimelineRecord);
     
    5252        this._resourceRecordMap.set(record.resource, record);
    5353
    54         super.addRecord(record);
     54        super.addRecord(record, options);
    5555    }
    5656};
  • trunk/Source/WebInspectorUI/UserInterface/Models/Timeline.js

    r245498 r247033  
    7070    }
    7171
    72     addRecord(record)
     72    addRecord(record, options = {})
    7373    {
    7474        if (record.updatesDynamically)
  • trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js

    r246292 r247033  
    4040        this._startTime = NaN;
    4141        this._endTime = NaN;
     42
     43        this._discontinuityStartTime = NaN;
    4244        this._discontinuities = null;
     45        this._firstRecordOfTypeAfterDiscontinuity = new Set;
    4346
    4447        this._exportDataRecords = null;
     
    169172        for (let instrument of this._instruments)
    170173            instrument.startInstrumentation(initiatedByBackend);
     174
     175        if (!isNaN(this._discontinuityStartTime)) {
     176            for (let instrument of this._instruments)
     177                this._firstRecordOfTypeAfterDiscontinuity.add(instrument.timelineRecordType);
     178        }
    171179    }
    172180
     
    180188        for (let instrument of this._instruments)
    181189            instrument.stopInstrumentation(initiatedByBackend);
     190    }
     191
     192    capturingStarted(startTime)
     193    {
     194        // A discontinuity occurs when the recording is stopped and resumed at
     195        // a future time. Capturing started signals the end of the current
     196        // discontinuity, if one exists.
     197        if (!isNaN(this._discontinuityStartTime)) {
     198            this._discontinuities.push({
     199                startTime: this._discontinuityStartTime,
     200                endTime: startTime,
     201            });
     202            this._discontinuityStartTime = NaN;
     203        }
     204    }
     205
     206    capturingStopped(endTime)
     207    {
     208        this._discontinuityStartTime = endTime;
    182209    }
    183210
     
    215242        this._startTime = NaN;
    216243        this._endTime = NaN;
     244
     245        this._discontinuityStartTime = NaN;
    217246        this._discontinuities = [];
     247        this._firstRecordOfTypeAfterDiscontinuity.clear();
    218248
    219249        this._exportDataRecords = [];
     
    301331            return;
    302332
     333        let discontinuity = null;
     334        if (this._firstRecordOfTypeAfterDiscontinuity.take(record.type))
     335            discontinuity = this._discontinuities.lastValue;
     336
    303337        // Add the record to the global timeline by type.
    304         timeline.addRecord(record);
     338        timeline.addRecord(record, {discontinuity});
    305339
    306340        // Some records don't have source code timelines.
     
    359393    }
    360394
    361     addDiscontinuity(startTime, endTime)
    362     {
    363         this._discontinuities.push({startTime, endTime});
    364     }
    365 
    366395    discontinuitiesInTimeRange(startTime, endTime)
    367396    {
    368         return this._discontinuities.filter((item) => item.startTime < endTime && item.endTime > startTime);
     397        return this._discontinuities.filter((item) => item.startTime <= endTime && item.endTime >= startTime);
    369398    }
    370399
  • trunk/Source/WebInspectorUI/UserInterface/Views/CPUTimelineView.js

    r246179 r247033  
    487487            let {usage, mainThreadUsage, workerThreadUsage, webkitThreadUsage, unknownThreadUsage} = record;
    488488
    489             if (discontinuities.length && discontinuities[0].endTime < time) {
     489            if (discontinuities.length && discontinuities[0].endTime <= time) {
    490490                let startDiscontinuity = discontinuities.shift();
    491491                let endDiscontinuity = startDiscontinuity;
    492                 while (discontinuities.length && discontinuities[0].endTime < time)
     492                while (discontinuities.length && discontinuities[0].endTime <= time)
    493493                    endDiscontinuity = discontinuities.shift();
    494494
  • trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineOverviewGraph.js

    r245498 r247033  
    189189        let previousRecord = null;
    190190        for (let record of visibleRecords) {
    191             if (discontinuities.length && discontinuities[0].endTime < record.startTime) {
     191            if (discontinuities.length && discontinuities[0].endTime <= record.startTime) {
    192192                let startDiscontinuity = discontinuities.shift();
    193193                let endDiscontinuity = startDiscontinuity;
    194                 while (discontinuities.length && discontinuities[0].endTime < record.startTime)
     194                while (discontinuities.length && discontinuities[0].endTime <= record.startTime)
    195195                    endDiscontinuity = discontinuities.shift();
    196196                insertDiscontinuity.call(this, previousRecord, startDiscontinuity, endDiscontinuity, record);
  • trunk/Source/WebInspectorUI/UserInterface/Views/MemoryTimelineView.js

    r245498 r247033  
    229229            let startDiscontinuity = null;
    230230            let endDiscontinuity = null;
    231             if (discontinuities.length && discontinuities[0].endTime < time) {
     231            if (discontinuities.length && discontinuities[0].endTime <= time) {
    232232                startDiscontinuity = discontinuities.shift();
    233233                endDiscontinuity = startDiscontinuity;
    234                 while (discontinuities.length && discontinuities[0].endTime < time)
     234                while (discontinuities.length && discontinuities[0].endTime <= time)
    235235                    endDiscontinuity = discontinuities.shift();
    236236            }
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js

    r246558 r247033  
    9393        this._updating = false;
    9494        this._currentTime = NaN;
    95         this._discontinuityStartTime = NaN;
    9695        this._lastUpdateTimestamp = NaN;
    9796        this._startTimeNeedsReset = true;
     
    524523            this._clearTimelineNavigationItem.enabled = !this._recording.readonly;
    525524            this._exportButtonNavigationItem.enabled = false;
    526 
    527             // A discontinuity occurs when the recording is stopped and resumed at
    528             // a future time. Capturing started signals the end of the current
    529             // discontinuity, if one exists.
    530             if (!isNaN(this._discontinuityStartTime)) {
    531                 this._recording.addDiscontinuity(this._discontinuityStartTime, startTime);
    532                 this._discontinuityStartTime = NaN;
    533             }
    534525            break;
    535526
     
    540531            if (this.currentTimelineView)
    541532                this._updateTimelineViewTimes(this.currentTimelineView);
    542 
    543             this._discontinuityStartTime = endTime || this._currentTime;
    544533
    545534            this._exportButtonNavigationItem.enabled = this._recording.canExport();
     
    711700
    712701        this._currentTime = NaN;
    713         this._discontinuityStartTime = NaN;
    714702
    715703        if (!this._updating) {
Note: See TracChangeset for help on using the changeset viewer.