Commit 152cf6c6 authored by caseq@chromium.org's avatar caseq@chromium.org

Timeline: decouple TimelineFrameModel from TimelineModel

We'd like TimelineFrameModel to be independent from TimelineModel,
since we may build the former based on row trace events.
As a drive by, fix "no live updates" experiment which was broken
in a couple of places, especially WRT displaying frames.

BUG=361045
R=yurys@chromium.org

Review URL: https://codereview.chromium.org/319743002

git-svn-id: svn://svn.chromium.org/blink/trunk@175644 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2fd0f03c
......@@ -30,17 +30,14 @@
/**
* @constructor
* @extends {WebInspector.Object}
* @param {!WebInspector.TimelineModel} model
* @extends {WebInspector.TargetAwareObject}
* @param {!WebInspector.Target} target
*/
WebInspector.TimelineFrameModel = function(model)
WebInspector.TimelineFrameModel = function(target)
{
this._model = model;
WebInspector.TargetAwareObject.call(this, target);
this.reset();
var records = model.records();
for (var i = 0; i < records.length; ++i)
this.addRecord(records[i]);
}
WebInspector.TimelineFrameModel.Events = {
......@@ -55,14 +52,6 @@ WebInspector.TimelineFrameModel._mainFrameMarkers = [
];
WebInspector.TimelineFrameModel.prototype = {
/**
* @return {!WebInspector.Target}
*/
target: function()
{
return this._model.target();
},
/**
* @return {!Array.<!WebInspector.TimelineFrame>}
*/
......@@ -102,8 +91,18 @@ WebInspector.TimelineFrameModel.prototype = {
return frames.slice(firstFrame, lastFrame);
},
/**
* @param {boolean} value
*/
setMergeRecords: function(value)
{
this._mergeRecords = value;
},
reset: function()
{
this._mergeRecords = true;
this._minimumRecordTime = Infinity;
this._frames = [];
this._lastFrame = null;
this._lastLayerTree = null;
......@@ -114,6 +113,19 @@ WebInspector.TimelineFrameModel.prototype = {
this._mergingBuffer = new WebInspector.TimelineMergingRecordBuffer();
},
/**
* @param {!Array.<!WebInspector.TimelineModel.Record>} records
*/
addRecords: function(records)
{
if (!records.length)
return;
if (records[0].startTime() < this._minimumRecordTime)
this._minimumRecordTime = records[0].startTime();
for (var i = 0; i < records.length; ++i)
this.addRecord(records[i]);
},
/**
* @param {!WebInspector.TimelineModel.Record} record
*/
......@@ -129,7 +141,7 @@ WebInspector.TimelineFrameModel.prototype = {
}
/** type {Array.<!WebInspector.TimelineModel.Record>} */
var records = [];
if (this._model.bufferEvents())
if (!this._mergeRecords)
records = [record];
else
records = this._mergingBuffer.process(record.thread(), /** type {Array.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() || [] : [record]));
......@@ -328,7 +340,7 @@ WebInspector.TimelineFrameModel.prototype = {
if (this._lastFrame)
this._flushFrame(this._lastFrame, startTime);
this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime - this._model.minimumRecordTime());
this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime - this._minimumRecordTime);
},
/**
......@@ -338,7 +350,7 @@ WebInspector.TimelineFrameModel.prototype = {
{
if (this._lastFrame)
this._flushFrame(this._lastFrame, startTime);
this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime - this._model.minimumRecordTime());
this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime - this._minimumRecordTime);
},
/**
......@@ -372,7 +384,7 @@ WebInspector.TimelineFrameModel.prototype = {
return null;
},
__proto__: WebInspector.Object.prototype
__proto__: WebInspector.TargetAwareObject.prototype
}
/**
......
......@@ -278,14 +278,6 @@ WebInspector.TimelineModel.prototype = {
return this._records;
},
/**
* @return {boolean}
*/
bufferEvents: function()
{
return false;
},
/**
* @param {!Blob} file
* @param {!WebInspector.Progress} progress
......
......@@ -42,13 +42,12 @@ WebInspector.TimelineModelImpl.prototype = {
this._clientInitiatedRecording = true;
this.reset();
var maxStackFrames = captureStacks ? 30 : 0;
this._bufferEvents = WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled();
var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEnabled();
var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame,
WebInspector.TimelineModel.RecordType.DrawFrame,
WebInspector.TimelineModel.RecordType.RequestMainThreadFrame,
WebInspector.TimelineModel.RecordType.ActivateLayerTree ];
this._timelineManager.start(maxStackFrames, this._bufferEvents, liveEvents.join(","), captureMemory, includeGPUEvents, this._fireRecordingStarted.bind(this));
this._timelineManager.start(maxStackFrames, WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled(), liveEvents.join(","), captureMemory, includeGPUEvents, this._fireRecordingStarted.bind(this));
},
stopRecording: function()
......@@ -105,6 +104,9 @@ WebInspector.TimelineModelImpl.prototype = {
*/
_onStopped: function(event)
{
// If we were buffering events, discard those that got through, the real ones are coming!
if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled())
this.reset();
if (event.data) {
// Stopped from console.
this._fireRecordingStopped(null, null);
......@@ -131,21 +133,12 @@ WebInspector.TimelineModelImpl.prototype = {
*/
_fireRecordingStopped: function(error, cpuProfile)
{
this._bufferEvents = false;
this._collectionEnabled = false;
if (cpuProfile)
WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(this, cpuProfile);
this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped);
},
/**
* @return {boolean}
*/
bufferEvents: function()
{
return this._bufferEvents;
},
/**
* @param {!TimelineAgent.TimelineEvent} payload
*/
......
......@@ -250,10 +250,11 @@ WebInspector.TimelinePanel.prototype = {
_frameModel: function()
{
if (!this._lazyFrameModel) {
this._lazyFrameModel = new WebInspector.TimelineFrameModel(this._model);
this._lazyFrameModel = new WebInspector.TimelineFrameModel(this._model.target());
this._lazyFrameModel.setMergeRecords(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() || !this._recordingInProgress);
this._lazyFrameModel.addRecords(this._model.records());
if (this._lazyTracingModel)
this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._lazyTracingModel.sessionId());
}
return this._lazyFrameModel;
},
......@@ -672,6 +673,9 @@ WebInspector.TimelinePanel.prototype = {
this._tracingTimelineModel.willStartRecordingTraceEvents();
}
}
if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() && this._lazyFrameModel)
this._lazyFrameModel.setMergeRecords(false);
for (var i = 0; i < this._overviewControls.length; ++i)
this._overviewControls[i].timelineStarted();
......@@ -818,6 +822,10 @@ WebInspector.TimelinePanel.prototype = {
_onRecordingStopped: function()
{
this._updateToggleTimelineButton(false);
if (this._lazyFrameModel && WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled()) {
this._lazyFrameModel.reset();
this._lazyFrameModel.addRecords(this._model.records());
}
this._hideProgressPane();
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment