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 @@ ...@@ -30,17 +30,14 @@
/** /**
* @constructor * @constructor
* @extends {WebInspector.Object} * @extends {WebInspector.TargetAwareObject}
* @param {!WebInspector.TimelineModel} model * @param {!WebInspector.Target} target
*/ */
WebInspector.TimelineFrameModel = function(model) WebInspector.TimelineFrameModel = function(target)
{ {
this._model = model; WebInspector.TargetAwareObject.call(this, target);
this.reset(); this.reset();
var records = model.records();
for (var i = 0; i < records.length; ++i)
this.addRecord(records[i]);
} }
WebInspector.TimelineFrameModel.Events = { WebInspector.TimelineFrameModel.Events = {
...@@ -55,14 +52,6 @@ WebInspector.TimelineFrameModel._mainFrameMarkers = [ ...@@ -55,14 +52,6 @@ WebInspector.TimelineFrameModel._mainFrameMarkers = [
]; ];
WebInspector.TimelineFrameModel.prototype = { WebInspector.TimelineFrameModel.prototype = {
/**
* @return {!WebInspector.Target}
*/
target: function()
{
return this._model.target();
},
/** /**
* @return {!Array.<!WebInspector.TimelineFrame>} * @return {!Array.<!WebInspector.TimelineFrame>}
*/ */
...@@ -102,8 +91,18 @@ WebInspector.TimelineFrameModel.prototype = { ...@@ -102,8 +91,18 @@ WebInspector.TimelineFrameModel.prototype = {
return frames.slice(firstFrame, lastFrame); return frames.slice(firstFrame, lastFrame);
}, },
/**
* @param {boolean} value
*/
setMergeRecords: function(value)
{
this._mergeRecords = value;
},
reset: function() reset: function()
{ {
this._mergeRecords = true;
this._minimumRecordTime = Infinity;
this._frames = []; this._frames = [];
this._lastFrame = null; this._lastFrame = null;
this._lastLayerTree = null; this._lastLayerTree = null;
...@@ -114,6 +113,19 @@ WebInspector.TimelineFrameModel.prototype = { ...@@ -114,6 +113,19 @@ WebInspector.TimelineFrameModel.prototype = {
this._mergingBuffer = new WebInspector.TimelineMergingRecordBuffer(); 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 * @param {!WebInspector.TimelineModel.Record} record
*/ */
...@@ -129,7 +141,7 @@ WebInspector.TimelineFrameModel.prototype = { ...@@ -129,7 +141,7 @@ WebInspector.TimelineFrameModel.prototype = {
} }
/** type {Array.<!WebInspector.TimelineModel.Record>} */ /** type {Array.<!WebInspector.TimelineModel.Record>} */
var records = []; var records = [];
if (this._model.bufferEvents()) if (!this._mergeRecords)
records = [record]; records = [record];
else else
records = this._mergingBuffer.process(record.thread(), /** type {Array.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() || [] : [record])); records = this._mergingBuffer.process(record.thread(), /** type {Array.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() || [] : [record]));
...@@ -328,7 +340,7 @@ WebInspector.TimelineFrameModel.prototype = { ...@@ -328,7 +340,7 @@ WebInspector.TimelineFrameModel.prototype = {
if (this._lastFrame) if (this._lastFrame)
this._flushFrame(this._lastFrame, startTime); 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 = { ...@@ -338,7 +350,7 @@ WebInspector.TimelineFrameModel.prototype = {
{ {
if (this._lastFrame) if (this._lastFrame)
this._flushFrame(this._lastFrame, startTime); 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 = { ...@@ -372,7 +384,7 @@ WebInspector.TimelineFrameModel.prototype = {
return null; return null;
}, },
__proto__: WebInspector.Object.prototype __proto__: WebInspector.TargetAwareObject.prototype
} }
/** /**
......
...@@ -278,14 +278,6 @@ WebInspector.TimelineModel.prototype = { ...@@ -278,14 +278,6 @@ WebInspector.TimelineModel.prototype = {
return this._records; return this._records;
}, },
/**
* @return {boolean}
*/
bufferEvents: function()
{
return false;
},
/** /**
* @param {!Blob} file * @param {!Blob} file
* @param {!WebInspector.Progress} progress * @param {!WebInspector.Progress} progress
......
...@@ -42,13 +42,12 @@ WebInspector.TimelineModelImpl.prototype = { ...@@ -42,13 +42,12 @@ WebInspector.TimelineModelImpl.prototype = {
this._clientInitiatedRecording = true; this._clientInitiatedRecording = true;
this.reset(); this.reset();
var maxStackFrames = captureStacks ? 30 : 0; var maxStackFrames = captureStacks ? 30 : 0;
this._bufferEvents = WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled();
var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEnabled(); var includeGPUEvents = WebInspector.experimentsSettings.gpuTimeline.isEnabled();
var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame, var liveEvents = [ WebInspector.TimelineModel.RecordType.BeginFrame,
WebInspector.TimelineModel.RecordType.DrawFrame, WebInspector.TimelineModel.RecordType.DrawFrame,
WebInspector.TimelineModel.RecordType.RequestMainThreadFrame, WebInspector.TimelineModel.RecordType.RequestMainThreadFrame,
WebInspector.TimelineModel.RecordType.ActivateLayerTree ]; 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() stopRecording: function()
...@@ -105,6 +104,9 @@ WebInspector.TimelineModelImpl.prototype = { ...@@ -105,6 +104,9 @@ WebInspector.TimelineModelImpl.prototype = {
*/ */
_onStopped: function(event) _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) { if (event.data) {
// Stopped from console. // Stopped from console.
this._fireRecordingStopped(null, null); this._fireRecordingStopped(null, null);
...@@ -131,21 +133,12 @@ WebInspector.TimelineModelImpl.prototype = { ...@@ -131,21 +133,12 @@ WebInspector.TimelineModelImpl.prototype = {
*/ */
_fireRecordingStopped: function(error, cpuProfile) _fireRecordingStopped: function(error, cpuProfile)
{ {
this._bufferEvents = false;
this._collectionEnabled = false; this._collectionEnabled = false;
if (cpuProfile) if (cpuProfile)
WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(this, cpuProfile); WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline(this, cpuProfile);
this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped); this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped);
}, },
/**
* @return {boolean}
*/
bufferEvents: function()
{
return this._bufferEvents;
},
/** /**
* @param {!TimelineAgent.TimelineEvent} payload * @param {!TimelineAgent.TimelineEvent} payload
*/ */
......
...@@ -250,10 +250,11 @@ WebInspector.TimelinePanel.prototype = { ...@@ -250,10 +250,11 @@ WebInspector.TimelinePanel.prototype = {
_frameModel: function() _frameModel: function()
{ {
if (!this._lazyFrameModel) { 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) if (this._lazyTracingModel)
this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._lazyTracingModel.sessionId()); this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._lazyTracingModel.sessionId());
} }
return this._lazyFrameModel; return this._lazyFrameModel;
}, },
...@@ -672,6 +673,9 @@ WebInspector.TimelinePanel.prototype = { ...@@ -672,6 +673,9 @@ WebInspector.TimelinePanel.prototype = {
this._tracingTimelineModel.willStartRecordingTraceEvents(); this._tracingTimelineModel.willStartRecordingTraceEvents();
} }
} }
if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() && this._lazyFrameModel)
this._lazyFrameModel.setMergeRecords(false);
for (var i = 0; i < this._overviewControls.length; ++i) for (var i = 0; i < this._overviewControls.length; ++i)
this._overviewControls[i].timelineStarted(); this._overviewControls[i].timelineStarted();
...@@ -818,6 +822,10 @@ WebInspector.TimelinePanel.prototype = { ...@@ -818,6 +822,10 @@ WebInspector.TimelinePanel.prototype = {
_onRecordingStopped: function() _onRecordingStopped: function()
{ {
this._updateToggleTimelineButton(false); this._updateToggleTimelineButton(false);
if (this._lazyFrameModel && WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled()) {
this._lazyFrameModel.reset();
this._lazyFrameModel.addRecords(this._model.records());
}
this._hideProgressPane(); 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