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