| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 { | 202 { |
| 203 this._minimumRecordTime = Infinity; | 203 this._minimumRecordTime = Infinity; |
| 204 this._frames = []; | 204 this._frames = []; |
| 205 this._frameById = {}; | 205 this._frameById = {}; |
| 206 this._lastFrame = null; | 206 this._lastFrame = null; |
| 207 this._lastLayerTree = null; | 207 this._lastLayerTree = null; |
| 208 this._hasThreadedCompositing = false; | 208 this._hasThreadedCompositing = false; |
| 209 this._mainFrameCommitted = false; | 209 this._mainFrameCommitted = false; |
| 210 this._mainFrameRequested = false; | 210 this._mainFrameRequested = false; |
| 211 this._framePendingCommit = null; | 211 this._framePendingCommit = null; |
| 212 this._lastBeginFrame = null; |
| 213 this._lastNeedsBeginFrame = null; |
| 212 }, | 214 }, |
| 213 | 215 |
| 214 /** | 216 /** |
| 215 * @param {number} startTime | 217 * @param {number} startTime |
| 216 */ | 218 */ |
| 217 handleBeginFrame: function(startTime) | 219 handleBeginFrame: function(startTime) |
| 218 { | 220 { |
| 219 if (!this._lastFrame) | 221 if (!this._lastFrame) |
| 220 this._startBackgroundFrame(startTime); | 222 this._startBackgroundFrame(startTime); |
| 223 this._lastBeginFrame = startTime; |
| 221 }, | 224 }, |
| 222 | 225 |
| 223 /** | 226 /** |
| 224 * @param {number} startTime | 227 * @param {number} startTime |
| 225 */ | 228 */ |
| 226 handleDrawFrame: function(startTime) | 229 handleDrawFrame: function(startTime) |
| 227 { | 230 { |
| 228 if (!this._lastFrame) { | 231 if (!this._lastFrame) { |
| 229 this._startBackgroundFrame(startTime); | 232 this._startBackgroundFrame(startTime); |
| 230 return; | 233 return; |
| 231 } | 234 } |
| 232 | 235 |
| 233 // - if it wasn't drawn, it didn't happen! | 236 // - if it wasn't drawn, it didn't happen! |
| 234 // - only show frames that either did not wait for the main thread frame
or had one committed. | 237 // - only show frames that either did not wait for the main thread frame
or had one committed. |
| 235 if (this._mainFrameCommitted || !this._mainFrameRequested) | 238 if (this._mainFrameCommitted || !this._mainFrameRequested) { |
| 239 if (this._lastNeedsBeginFrame) { |
| 240 this._lastFrame.idle = true; |
| 241 var idleTimeEnd = this._framePendingActivation ? this._framePend
ingActivation.triggerTime : (this._lastBeginFrame || this._lastNeedsBeginFrame); |
| 242 this._startBackgroundFrame(idleTimeEnd); |
| 243 if (this._framePendingActivation) |
| 244 this._commitPendingFrame(); |
| 245 this._lastNeedsBeginFrame = null; |
| 246 this._lastBeginFrame = null; |
| 247 } |
| 236 this._startBackgroundFrame(startTime); | 248 this._startBackgroundFrame(startTime); |
| 249 } |
| 237 this._mainFrameCommitted = false; | 250 this._mainFrameCommitted = false; |
| 238 }, | 251 }, |
| 239 | 252 |
| 240 handleActivateLayerTree: function() | 253 handleActivateLayerTree: function() |
| 241 { | 254 { |
| 242 if (!this._lastFrame) | 255 if (!this._lastFrame) |
| 243 return; | 256 return; |
| 244 if (this._framePendingActivation) { | 257 if (this._framePendingActivation && !this._lastNeedsBeginFrame) |
| 245 this._lastFrame._addTimeForCategories(this._framePendingActivation.t
imeByCategory); | 258 this._commitPendingFrame(); |
| 246 this._lastFrame.paints = this._framePendingActivation.paints; | |
| 247 this._lastFrame._mainFrameId = this._framePendingActivation.mainFram
eId; | |
| 248 this._framePendingActivation = null; | |
| 249 } | |
| 250 }, | 259 }, |
| 251 | 260 |
| 252 handleRequestMainThreadFrame: function() | 261 handleRequestMainThreadFrame: function() |
| 253 { | 262 { |
| 254 if (!this._lastFrame) | 263 if (!this._lastFrame) |
| 255 return; | 264 return; |
| 256 this._mainFrameRequested = true; | 265 this._mainFrameRequested = true; |
| 257 }, | 266 }, |
| 258 | 267 |
| 259 handleCompositeLayers: function() | 268 handleCompositeLayers: function() |
| 260 { | 269 { |
| 261 if (!this._hasThreadedCompositing || !this._framePendingCommit) | 270 if (!this._hasThreadedCompositing || !this._framePendingCommit) |
| 262 return; | 271 return; |
| 263 this._framePendingActivation = this._framePendingCommit; | 272 this._framePendingActivation = this._framePendingCommit; |
| 264 this._framePendingCommit = null; | 273 this._framePendingCommit = null; |
| 265 this._mainFrameRequested = false; | 274 this._mainFrameRequested = false; |
| 266 this._mainFrameCommitted = true; | 275 this._mainFrameCommitted = true; |
| 267 }, | 276 }, |
| 268 | 277 |
| 269 /** | 278 /** |
| 270 * @param {!WebInspector.DeferredLayerTree} layerTree | 279 * @param {!WebInspector.DeferredLayerTree} layerTree |
| 271 */ | 280 */ |
| 272 handleLayerTreeSnapshot: function(layerTree) | 281 handleLayerTreeSnapshot: function(layerTree) |
| 273 { | 282 { |
| 274 this._lastLayerTree = layerTree; | 283 this._lastLayerTree = layerTree; |
| 275 }, | 284 }, |
| 276 | 285 |
| 277 /** | 286 /** |
| 278 * @param {number} startTime | 287 * @param {number} startTime |
| 288 * @param {boolean} needsBeginFrame |
| 289 */ |
| 290 handleNeedFrameChanged: function(startTime, needsBeginFrame) |
| 291 { |
| 292 if (needsBeginFrame) |
| 293 this._lastNeedsBeginFrame = startTime; |
| 294 }, |
| 295 |
| 296 /** |
| 297 * @param {number} startTime |
| 279 */ | 298 */ |
| 280 _startBackgroundFrame: function(startTime) | 299 _startBackgroundFrame: function(startTime) |
| 281 { | 300 { |
| 282 if (!this._hasThreadedCompositing) { | 301 if (!this._hasThreadedCompositing) { |
| 283 this._lastFrame = null; | 302 this._lastFrame = null; |
| 284 this._hasThreadedCompositing = true; | 303 this._hasThreadedCompositing = true; |
| 285 } | 304 } |
| 286 if (this._lastFrame) | 305 if (this._lastFrame) |
| 287 this._flushFrame(this._lastFrame, startTime); | 306 this._flushFrame(this._lastFrame, startTime); |
| 288 | 307 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 307 */ | 326 */ |
| 308 _flushFrame: function(frame, endTime) | 327 _flushFrame: function(frame, endTime) |
| 309 { | 328 { |
| 310 frame._setLayerTree(this._lastLayerTree); | 329 frame._setLayerTree(this._lastLayerTree); |
| 311 frame._setEndTime(endTime); | 330 frame._setEndTime(endTime); |
| 312 this._frames.push(frame); | 331 this._frames.push(frame); |
| 313 if (typeof frame._mainFrameId === "number") | 332 if (typeof frame._mainFrameId === "number") |
| 314 this._frameById[frame._mainFrameId] = frame; | 333 this._frameById[frame._mainFrameId] = frame; |
| 315 }, | 334 }, |
| 316 | 335 |
| 336 _commitPendingFrame: function() |
| 337 { |
| 338 this._lastFrame._addTimeForCategories(this._framePendingActivation.timeB
yCategory); |
| 339 this._lastFrame.paints = this._framePendingActivation.paints; |
| 340 this._lastFrame._mainFrameId = this._framePendingActivation.mainFrameId; |
| 341 this._framePendingActivation = null; |
| 342 }, |
| 343 |
| 317 /** | 344 /** |
| 318 * @param {!Array.<string>} types | 345 * @param {!Array.<string>} types |
| 319 * @param {!WebInspector.TimelineModel.Record} record | 346 * @param {!WebInspector.TimelineModel.Record} record |
| 320 * @return {?WebInspector.TimelineModel.Record} record | 347 * @return {?WebInspector.TimelineModel.Record} record |
| 321 */ | 348 */ |
| 322 _findRecordRecursively: function(types, record) | 349 _findRecordRecursively: function(types, record) |
| 323 { | 350 { |
| 324 if (types.indexOf(record.type()) >= 0) | 351 if (types.indexOf(record.type()) >= 0) |
| 325 return record; | 352 return record; |
| 326 if (!record.children()) | 353 if (!record.children()) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 440 |
| 414 var timestamp = event.startTime; | 441 var timestamp = event.startTime; |
| 415 if (event.name === eventNames.BeginFrame) | 442 if (event.name === eventNames.BeginFrame) |
| 416 this.handleBeginFrame(timestamp); | 443 this.handleBeginFrame(timestamp); |
| 417 else if (event.name === eventNames.DrawFrame) | 444 else if (event.name === eventNames.DrawFrame) |
| 418 this.handleDrawFrame(timestamp); | 445 this.handleDrawFrame(timestamp); |
| 419 else if (event.name === eventNames.ActivateLayerTree) | 446 else if (event.name === eventNames.ActivateLayerTree) |
| 420 this.handleActivateLayerTree(); | 447 this.handleActivateLayerTree(); |
| 421 else if (event.name === eventNames.RequestMainThreadFrame) | 448 else if (event.name === eventNames.RequestMainThreadFrame) |
| 422 this.handleRequestMainThreadFrame(); | 449 this.handleRequestMainThreadFrame(); |
| 450 else if (event.name === eventNames.NeedsBeginFrameChanged) |
| 451 this.handleNeedFrameChanged(timestamp, event.args["data"] && event.a
rgs["data"]["needsBeginFrame"]); |
| 423 }, | 452 }, |
| 424 | 453 |
| 425 /** | 454 /** |
| 426 * @param {!WebInspector.TracingModel.Event} event | 455 * @param {!WebInspector.TracingModel.Event} event |
| 427 */ | 456 */ |
| 428 _addMainThreadTraceEvent: function(event) | 457 _addMainThreadTraceEvent: function(event) |
| 429 { | 458 { |
| 430 var eventNames = WebInspector.TimelineModel.RecordType; | 459 var eventNames = WebInspector.TimelineModel.RecordType; |
| 431 var timestamp = event.startTime; | 460 var timestamp = event.startTime; |
| 432 var selfTime = event.selfTime || 0; | 461 var selfTime = event.selfTime || 0; |
| 433 | 462 |
| 434 if (!this._hasThreadedCompositing) { | 463 if (!this._hasThreadedCompositing) { |
| 435 if (event.name === eventNames.BeginMainThreadFrame) | 464 if (event.name === eventNames.BeginMainThreadFrame) |
| 436 this._startMainThreadFrame(timestamp, event.args["data"] && even
t.args["data"]["frameId"]); | 465 this._startMainThreadFrame(timestamp, event.args["data"] && even
t.args["data"]["frameId"]); |
| 437 if (!this._lastFrame) | 466 if (!this._lastFrame) |
| 438 return; | 467 return; |
| 439 if (!selfTime) | 468 if (!selfTime) |
| 440 return; | 469 return; |
| 441 | 470 |
| 442 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca
tegory.name; | 471 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca
tegory.name; |
| 443 this._lastFrame._addTimeForCategory(categoryName, selfTime); | 472 this._lastFrame._addTimeForCategory(categoryName, selfTime); |
| 444 return; | 473 return; |
| 445 } | 474 } |
| 446 | 475 |
| 447 if (WebInspector.TracingModel.isTopLevelEvent(event)) | 476 if (WebInspector.TracingModel.isTopLevelEvent(event)) { |
| 448 this._currentTaskTimeByCategory = {}; | 477 this._currentTaskTimeByCategory = {}; |
| 478 this._lastTaskBeginTime = event.startTime; |
| 479 } |
| 449 if (!this._framePendingCommit && WebInspector.TracingTimelineFrameModel.
_mainFrameMarkers.indexOf(event.name) >= 0) | 480 if (!this._framePendingCommit && WebInspector.TracingTimelineFrameModel.
_mainFrameMarkers.indexOf(event.name) >= 0) |
| 450 this._framePendingCommit = new WebInspector.PendingFrame(this._curre
ntTaskTimeByCategory); | 481 this._framePendingCommit = new WebInspector.PendingFrame(this._lastT
askBeginTime, this._currentTaskTimeByCategory); |
| 451 if (!this._framePendingCommit) { | 482 if (!this._framePendingCommit) { |
| 452 this._addTimeForCategory(this._currentTaskTimeByCategory, event); | 483 this._addTimeForCategory(this._currentTaskTimeByCategory, event); |
| 453 return; | 484 return; |
| 454 } | 485 } |
| 455 this._addTimeForCategory(this._framePendingCommit.timeByCategory, event)
; | 486 this._addTimeForCategory(this._framePendingCommit.timeByCategory, event)
; |
| 456 | 487 |
| 457 if (event.name === eventNames.BeginMainThreadFrame && event.args["data"]
&& event.args["data"]["frameId"]) | 488 if (event.name === eventNames.BeginMainThreadFrame && event.args["data"]
&& event.args["data"]["frameId"]) |
| 458 this._framePendingCommit.mainFrameId = event.args["data"]["frameId"]
; | 489 this._framePendingCommit.mainFrameId = event.args["data"]["frameId"]
; |
| 459 if (event.name === eventNames.Paint && event.args["data"]["layerId"] &&
event.picture && this._target) | 490 if (event.name === eventNames.Paint && event.args["data"]["layerId"] &&
event.picture && this._target) |
| 460 this._framePendingCommit.paints.push(new WebInspector.LayerPaintEven
t(event, this._target)); | 491 this._framePendingCommit.paints.push(new WebInspector.LayerPaintEven
t(event, this._target)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 * @param {number} startTimeOffset | 556 * @param {number} startTimeOffset |
| 526 */ | 557 */ |
| 527 WebInspector.TimelineFrame = function(startTime, startTimeOffset) | 558 WebInspector.TimelineFrame = function(startTime, startTimeOffset) |
| 528 { | 559 { |
| 529 this.startTime = startTime; | 560 this.startTime = startTime; |
| 530 this.startTimeOffset = startTimeOffset; | 561 this.startTimeOffset = startTimeOffset; |
| 531 this.endTime = this.startTime; | 562 this.endTime = this.startTime; |
| 532 this.duration = 0; | 563 this.duration = 0; |
| 533 this.timeByCategory = {}; | 564 this.timeByCategory = {}; |
| 534 this.cpuTime = 0; | 565 this.cpuTime = 0; |
| 566 this.idle = false; |
| 535 /** @type {?WebInspector.DeferredLayerTree} */ | 567 /** @type {?WebInspector.DeferredLayerTree} */ |
| 536 this.layerTree = null; | 568 this.layerTree = null; |
| 537 /** @type {number|undefined} */ | 569 /** @type {number|undefined} */ |
| 538 this._mainFrameId = undefined; | 570 this._mainFrameId = undefined; |
| 539 } | 571 } |
| 540 | 572 |
| 541 WebInspector.TimelineFrame.prototype = { | 573 WebInspector.TimelineFrame.prototype = { |
| 542 /** | 574 /** |
| 543 * @param {number} endTime | 575 * @param {number} endTime |
| 544 */ | 576 */ |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 callback(null, null); | 673 callback(null, null); |
| 642 return; | 674 return; |
| 643 } | 675 } |
| 644 WebInspector.PaintProfilerSnapshot.load(this._target, picture, callb
ack.bind(null, rect)); | 676 WebInspector.PaintProfilerSnapshot.load(this._target, picture, callb
ack.bind(null, rect)); |
| 645 } | 677 } |
| 646 } | 678 } |
| 647 }; | 679 }; |
| 648 | 680 |
| 649 /** | 681 /** |
| 650 * @constructor | 682 * @constructor |
| 683 * @param {number} triggerTime |
| 651 * @param {!Object.<string, number>} timeByCategory | 684 * @param {!Object.<string, number>} timeByCategory |
| 652 */ | 685 */ |
| 653 WebInspector.PendingFrame = function(timeByCategory) | 686 WebInspector.PendingFrame = function(triggerTime, timeByCategory) |
| 654 { | 687 { |
| 655 /** @type {!Object.<string, number>} */ | 688 /** @type {!Object.<string, number>} */ |
| 656 this.timeByCategory = timeByCategory; | 689 this.timeByCategory = timeByCategory; |
| 657 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ | 690 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ |
| 658 this.paints = []; | 691 this.paints = []; |
| 659 /** @type {number|undefined} */ | 692 /** @type {number|undefined} */ |
| 660 this.mainFrameId = undefined; | 693 this.mainFrameId = undefined; |
| 694 this.triggerTime = triggerTime; |
| 661 } | 695 } |
| OLD | NEW |