Changeset 240351 in webkit


Ignore:
Timestamp:
Jan 23, 2019 11:29:18 AM (5 years ago)
Author:
Devin Rousso
Message:

WebInspector: Confusingly nested events in the timeline for Mutation Observers
https://bugs.webkit.org/show_bug.cgi?id=192884
<rdar://problem/46854178>

Reviewed by Joseph Pecoraro.

If a microtask event (e.g. ObserverCallback) is contained within a EvaluatedScript
event, move that microtask event to be a sibling of the EvaluateScript, subtracting the
microtask's time taken from the EvaluateScript's time. If there are no other children
after this move, then remove the EvaluateScript altogether.

  • UserInterface/Controllers/TimelineManager.js:

(WI.TimelineManager.prototype.eventRecorded.fixMicrotaskPlacement): Added.
(WI.TimelineManager.prototype.eventRecorded):
(WI.TimelineManager.prototype._mergeScriptProfileRecords):

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r240347 r240351  
     12019-01-23  Devin Rousso  <drousso@apple.com>
     2
     3        WebInspector: Confusingly nested events in the timeline for Mutation Observers
     4        https://bugs.webkit.org/show_bug.cgi?id=192884
     5        <rdar://problem/46854178>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        If a microtask event (e.g. `ObserverCallback`) is contained within a `EvaluatedScript`
     10        event, move that microtask event to be a sibling of the `EvaluateScript`, subtracting the
     11        microtask's time taken from the `EvaluateScript`'s time. If there are no other children
     12        after this move, then remove the `EvaluateScript` altogether.
     13
     14        * UserInterface/Controllers/TimelineManager.js:
     15        (WI.TimelineManager.prototype.eventRecorded.fixMicrotaskPlacement): Added.
     16        (WI.TimelineManager.prototype.eventRecorded):
     17        (WI.TimelineManager.prototype._mergeScriptProfileRecords):
     18
    1192019-01-23  Joseph Pecoraro  <pecoraro@apple.com>
    220
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js

    r240323 r240351  
    357357            return;
    358358
     359        function fixMicrotaskPlacement(children)
     360        {
     361            let newChildren = [];
     362            for (let child of children) {
     363                if (child.type === TimelineAgent.EventType.EvaluateScript) {
     364                    let [microtasks, events] = child.children.partition((grandchild) => {
     365                        return grandchild.type === TimelineAgent.EventType.ObserverCallback;
     366                    });
     367
     368                    if (events.length) {
     369                        child.children = events;
     370                        child.endTime = events.lastValue.endTime;
     371                        newChildren.push(child);
     372                    }
     373
     374                    newChildren = newChildren.concat(microtasks);
     375                } else
     376                    newChildren.push(child);
     377            }
     378            return newChildren;
     379        }
     380
    359381        var records = [];
    360382
     
    377399
    378400                if (recordPayload.children && recordPayload.children.length)
    379                     stack.push({array: recordPayload.children, parent: recordPayload, parentRecord: record || entry.parentRecord, index: 0});
     401                    stack.push({array: fixMicrotaskPlacement(recordPayload.children), parent: recordPayload, parentRecord: record || entry.parentRecord, index: 0});
    380402                ++entry.index;
    381403            } else
     
    10561078                profilerRecord = nextScriptProfilerRecord();
    10571079
     1080                let firstProfilerRecordForWebRecord = null;
     1081
    10581082                // If there are more script profile records in the same time interval, add them
    10591083                // as individual script evaluated records with profiles. This can happen with
     
    10611085                // FIXME: <https://webkit.org/b/152903> Web Inspector: Timeline Cleanup: Better Timeline Record for Microtask Checkpoints
    10621086                while (profilerRecord && recordEnclosesRecord(webRecord, profilerRecord)) {
     1087                    if (!firstProfilerRecordForWebRecord)
     1088                        firstProfilerRecordForWebRecord = profilerRecord;
     1089
    10631090                    this._addRecord(profilerRecord);
    10641091                    profilerRecord = nextScriptProfilerRecord();
    10651092                }
     1093
     1094                if (firstProfilerRecordForWebRecord)
     1095                    webRecord.endTime = firstProfilerRecordForWebRecord.startTime;
    10661096
    10671097                webRecord = nextWebTimelineRecord();
Note: See TracChangeset for help on using the changeset viewer.