Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 * @param {!SDK.TracingModel.Event} event | 637 * @param {!SDK.TracingModel.Event} event |
| 638 * @return {boolean} | 638 * @return {boolean} |
| 639 */ | 639 */ |
| 640 _processEvent(event) { | 640 _processEvent(event) { |
| 641 var eventStack = this._eventStack; | 641 var eventStack = this._eventStack; |
| 642 while (eventStack.length && eventStack.peekLast().endTime <= event.startTime ) | 642 while (eventStack.length && eventStack.peekLast().endTime <= event.startTime ) |
| 643 eventStack.pop(); | 643 eventStack.pop(); |
| 644 | 644 |
| 645 var recordTypes = TimelineModel.TimelineModel.RecordType; | 645 var recordTypes = TimelineModel.TimelineModel.RecordType; |
| 646 | 646 |
| 647 if (!eventStack.length) { | |
| 648 if (this._currentTaskLayoutAndRecalcEvents && this._currentTaskLayoutAndRe calcEvents.length) { | |
|
alph
2016/11/19 05:36:27
It won't work for the very last top level event.
| |
| 649 var totalTime = this._currentTaskLayoutAndRecalcEvents.reduce((time, eve nt) => time + event.duration, 0); | |
|
alph
2016/11/19 05:36:27
We use const if the value is never changed.
| |
| 650 if (totalTime > TimelineModel.TimelineModel.Thresholds.ForcedLayout) { | |
| 651 for (var e of this._currentTaskLayoutAndRecalcEvents) { | |
| 652 var timelineData = TimelineModel.TimelineData.forEvent(e); | |
|
caseq
2016/11/19 05:51:08
This has the same name as a different variable bel
| |
| 653 timelineData.warning = e.name === recordTypes.Layout ? | |
| 654 TimelineModel.TimelineModel.WarningType.ForcedLayout : | |
| 655 TimelineModel.TimelineModel.WarningType.ForcedStyle; | |
| 656 } | |
| 657 } | |
| 658 } | |
| 659 this._currentTaskLayoutAndRecalcEvents = []; | |
| 660 } | |
| 661 | |
| 647 if (this._currentScriptEvent && event.startTime > this._currentScriptEvent.e ndTime) | 662 if (this._currentScriptEvent && event.startTime > this._currentScriptEvent.e ndTime) |
| 648 this._currentScriptEvent = null; | 663 this._currentScriptEvent = null; |
| 649 | 664 |
| 650 var eventData = event.args['data'] || event.args['beginData'] || {}; | 665 var eventData = event.args['data'] || event.args['beginData'] || {}; |
| 651 var timelineData = TimelineModel.TimelineData.forEvent(event); | 666 var timelineData = TimelineModel.TimelineData.forEvent(event); |
| 652 if (eventData['stackTrace']) | 667 if (eventData['stackTrace']) |
| 653 timelineData.stackTrace = eventData['stackTrace']; | 668 timelineData.stackTrace = eventData['stackTrace']; |
| 654 if (timelineData.stackTrace && event.name !== recordTypes.JSSample) { | 669 if (timelineData.stackTrace && event.name !== recordTypes.JSSample) { |
| 655 // TraceEvents come with 1-based line & column numbers. The frontend code | 670 // TraceEvents come with 1-based line & column numbers. The frontend code |
| 656 // requires 0-based ones. Adjust the values. | 671 // requires 0-based ones. Adjust the values. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 675 this._lastScheduleStyleRecalculation[eventData['frame']] = event; | 690 this._lastScheduleStyleRecalculation[eventData['frame']] = event; |
| 676 break; | 691 break; |
| 677 | 692 |
| 678 case recordTypes.UpdateLayoutTree: | 693 case recordTypes.UpdateLayoutTree: |
| 679 case recordTypes.RecalculateStyles: | 694 case recordTypes.RecalculateStyles: |
| 680 this._invalidationTracker.didRecalcStyle(event); | 695 this._invalidationTracker.didRecalcStyle(event); |
| 681 if (event.args['beginData']) | 696 if (event.args['beginData']) |
| 682 timelineData.setInitiator(this._lastScheduleStyleRecalculation[event.a rgs['beginData']['frame']]); | 697 timelineData.setInitiator(this._lastScheduleStyleRecalculation[event.a rgs['beginData']['frame']]); |
| 683 this._lastRecalculateStylesEvent = event; | 698 this._lastRecalculateStylesEvent = event; |
| 684 if (this._currentScriptEvent) | 699 if (this._currentScriptEvent) |
| 685 timelineData.warning = TimelineModel.TimelineModel.WarningType.ForcedS tyle; | 700 this._currentTaskLayoutAndRecalcEvents.push(event); |
| 686 break; | 701 break; |
| 687 | 702 |
| 688 case recordTypes.ScheduleStyleInvalidationTracking: | 703 case recordTypes.ScheduleStyleInvalidationTracking: |
| 689 case recordTypes.StyleRecalcInvalidationTracking: | 704 case recordTypes.StyleRecalcInvalidationTracking: |
| 690 case recordTypes.StyleInvalidatorInvalidationTracking: | 705 case recordTypes.StyleInvalidatorInvalidationTracking: |
| 691 case recordTypes.LayoutInvalidationTracking: | 706 case recordTypes.LayoutInvalidationTracking: |
| 692 case recordTypes.LayerInvalidationTracking: | 707 case recordTypes.LayerInvalidationTracking: |
| 693 case recordTypes.PaintInvalidationTracking: | 708 case recordTypes.PaintInvalidationTracking: |
| 694 case recordTypes.ScrollInvalidationTracking: | 709 case recordTypes.ScrollInvalidationTracking: |
| 695 this._invalidationTracker.addInvalidation(new TimelineModel.Invalidation TrackingEvent(event)); | 710 this._invalidationTracker.addInvalidation(new TimelineModel.Invalidation TrackingEvent(event)); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 708 | 723 |
| 709 case recordTypes.Layout: | 724 case recordTypes.Layout: |
| 710 this._invalidationTracker.didLayout(event); | 725 this._invalidationTracker.didLayout(event); |
| 711 var frameId = event.args['beginData']['frame']; | 726 var frameId = event.args['beginData']['frame']; |
| 712 timelineData.setInitiator(this._layoutInvalidate[frameId]); | 727 timelineData.setInitiator(this._layoutInvalidate[frameId]); |
| 713 // In case we have no closing Layout event, endData is not available. | 728 // In case we have no closing Layout event, endData is not available. |
| 714 if (event.args['endData']) | 729 if (event.args['endData']) |
| 715 timelineData.backendNodeId = event.args['endData']['rootNode']; | 730 timelineData.backendNodeId = event.args['endData']['rootNode']; |
| 716 this._layoutInvalidate[frameId] = null; | 731 this._layoutInvalidate[frameId] = null; |
| 717 if (this._currentScriptEvent) | 732 if (this._currentScriptEvent) |
| 718 timelineData.warning = TimelineModel.TimelineModel.WarningType.ForcedL ayout; | 733 this._currentTaskLayoutAndRecalcEvents.push(event); |
| 719 break; | 734 break; |
| 720 | 735 |
| 721 case recordTypes.FunctionCall: | 736 case recordTypes.FunctionCall: |
| 722 // Compatibility with old format. | 737 // Compatibility with old format. |
| 723 if (typeof eventData['scriptName'] === 'string') | 738 if (typeof eventData['scriptName'] === 'string') |
| 724 eventData['url'] = eventData['scriptName']; | 739 eventData['url'] = eventData['scriptName']; |
| 725 if (typeof eventData['scriptLine'] === 'number') | 740 if (typeof eventData['scriptLine'] === 'number') |
| 726 eventData['lineNumber'] = eventData['scriptLine']; | 741 eventData['lineNumber'] = eventData['scriptLine']; |
| 742 | |
| 743 if (event.duration > TimelineModel.TimelineModel.Thresholds.Handler) { | |
| 744 var parentEvent = eventStack.peekLast(); | |
| 745 if (parentEvent && parentEvent.name === recordTypes.EventDispatch) { | |
|
caseq
2016/11/19 05:51:08
Why do it here? Let's do it when handling correspo
| |
| 746 TimelineModel.TimelineData.forEvent(parentEvent).warning = | |
| 747 TimelineModel.TimelineModel.WarningType.LongHandler; | |
| 748 } | |
| 749 } | |
| 750 | |
| 751 if (event.duration > TimelineModel.TimelineModel.Thresholds.RecurringHan dler) { | |
| 752 var parentEvent = eventStack.peekLast(); | |
| 753 if (parentEvent && | |
| 754 (parentEvent.name === recordTypes.TimerFire || parentEvent.name == = recordTypes.FireAnimationFrame)) { | |
|
caseq
2016/11/19 05:51:08
ditto.
| |
| 755 TimelineModel.TimelineData.forEvent(parentEvent).warning = | |
| 756 TimelineModel.TimelineModel.WarningType.LongRecurringHandler; | |
| 757 } | |
| 758 } | |
| 759 | |
| 727 // Fallthrough. | 760 // Fallthrough. |
| 761 | |
| 728 case recordTypes.EvaluateScript: | 762 case recordTypes.EvaluateScript: |
| 729 case recordTypes.CompileScript: | 763 case recordTypes.CompileScript: |
| 730 if (typeof eventData['lineNumber'] === 'number') | 764 if (typeof eventData['lineNumber'] === 'number') |
| 731 --eventData['lineNumber']; | 765 --eventData['lineNumber']; |
| 732 if (typeof eventData['columnNumber'] === 'number') | 766 if (typeof eventData['columnNumber'] === 'number') |
| 733 --eventData['columnNumber']; | 767 --eventData['columnNumber']; |
| 768 | |
| 734 // Fallthrough intended. | 769 // Fallthrough intended. |
| 770 | |
| 735 case recordTypes.RunMicrotasks: | 771 case recordTypes.RunMicrotasks: |
| 736 // Microtasks technically are not necessarily scripts, but for purpose o f | 772 // Microtasks technically are not necessarily scripts, but for purpose o f |
| 737 // forced sync style recalc or layout detection they are. | 773 // forced sync style recalc or layout detection they are. |
| 738 if (!this._currentScriptEvent) | 774 if (!this._currentScriptEvent) |
| 739 this._currentScriptEvent = event; | 775 this._currentScriptEvent = event; |
| 740 break; | 776 break; |
| 741 | 777 |
| 742 case recordTypes.SetLayerTreeId: | 778 case recordTypes.SetLayerTreeId: |
| 743 this._inspectedTargetLayerTreeId = event.args['layerTreeId'] || event.ar gs['data']['layerTreeId']; | 779 this._inspectedTargetLayerTreeId = event.args['layerTreeId'] || event.ar gs['data']['layerTreeId']; |
| 744 break; | 780 break; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 this._hadCommitLoad = true; | 857 this._hadCommitLoad = true; |
| 822 this._firstCompositeLayers = null; | 858 this._firstCompositeLayers = null; |
| 823 break; | 859 break; |
| 824 | 860 |
| 825 case recordTypes.CompositeLayers: | 861 case recordTypes.CompositeLayers: |
| 826 if (!this._firstCompositeLayers && this._hadCommitLoad) | 862 if (!this._firstCompositeLayers && this._hadCommitLoad) |
| 827 this._firstCompositeLayers = event; | 863 this._firstCompositeLayers = event; |
| 828 break; | 864 break; |
| 829 | 865 |
| 830 case recordTypes.FireIdleCallback: | 866 case recordTypes.FireIdleCallback: |
| 831 if (event.duration > eventData['allottedMilliseconds']) | 867 if (event.duration > |
| 868 eventData['allottedMilliseconds'] + TimelineModel.TimelineModel.Thre sholds.IdleCallbackAddon) | |
| 832 timelineData.warning = TimelineModel.TimelineModel.WarningType.IdleDea dlineExceeded; | 869 timelineData.warning = TimelineModel.TimelineModel.WarningType.IdleDea dlineExceeded; |
| 833 | |
| 834 break; | 870 break; |
| 835 } | 871 } |
| 836 if (SDK.TracingModel.isAsyncPhase(event.phase)) | 872 if (SDK.TracingModel.isAsyncPhase(event.phase)) |
| 837 return true; | 873 return true; |
| 838 var duration = event.duration; | 874 var duration = event.duration; |
| 839 if (!duration) | 875 if (!duration) |
| 840 return true; | 876 return true; |
| 841 if (eventStack.length) { | 877 if (eventStack.length) { |
| 842 var parent = eventStack.peekLast(); | 878 var parent = eventStack.peekLast(); |
| 843 parent.selfTime -= duration; | 879 parent.selfTime -= duration; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1243 LatencyInfo: 'latencyInfo' | 1279 LatencyInfo: 'latencyInfo' |
| 1244 }; | 1280 }; |
| 1245 | 1281 |
| 1246 /** | 1282 /** |
| 1247 * @enum {string} | 1283 * @enum {string} |
| 1248 */ | 1284 */ |
| 1249 TimelineModel.TimelineModel.WarningType = { | 1285 TimelineModel.TimelineModel.WarningType = { |
| 1250 ForcedStyle: 'ForcedStyle', | 1286 ForcedStyle: 'ForcedStyle', |
| 1251 ForcedLayout: 'ForcedLayout', | 1287 ForcedLayout: 'ForcedLayout', |
| 1252 IdleDeadlineExceeded: 'IdleDeadlineExceeded', | 1288 IdleDeadlineExceeded: 'IdleDeadlineExceeded', |
| 1289 LongHandler: 'LongHandler', | |
| 1290 LongRecurringHandler: 'LongRecurringHandler', | |
| 1253 V8Deopt: 'V8Deopt' | 1291 V8Deopt: 'V8Deopt' |
| 1254 }; | 1292 }; |
| 1255 | 1293 |
| 1256 TimelineModel.TimelineModel.MainThreadName = 'main'; | 1294 TimelineModel.TimelineModel.MainThreadName = 'main'; |
| 1257 TimelineModel.TimelineModel.WorkerThreadName = 'DedicatedWorker Thread'; | 1295 TimelineModel.TimelineModel.WorkerThreadName = 'DedicatedWorker Thread'; |
| 1258 TimelineModel.TimelineModel.RendererMainThreadName = 'CrRendererMain'; | 1296 TimelineModel.TimelineModel.RendererMainThreadName = 'CrRendererMain'; |
| 1259 | 1297 |
| 1260 /** | 1298 /** |
| 1261 * @enum {symbol} | 1299 * @enum {symbol} |
| 1262 */ | 1300 */ |
| 1263 TimelineModel.TimelineModel.AsyncEventGroup = { | 1301 TimelineModel.TimelineModel.AsyncEventGroup = { |
| 1264 animation: Symbol('animation'), | 1302 animation: Symbol('animation'), |
| 1265 console: Symbol('console'), | 1303 console: Symbol('console'), |
| 1266 userTiming: Symbol('userTiming'), | 1304 userTiming: Symbol('userTiming'), |
| 1267 input: Symbol('input') | 1305 input: Symbol('input') |
| 1268 }; | 1306 }; |
| 1269 | 1307 |
| 1270 | 1308 |
| 1271 TimelineModel.TimelineModel.DevToolsMetadataEvent = { | 1309 TimelineModel.TimelineModel.DevToolsMetadataEvent = { |
| 1272 TracingStartedInBrowser: 'TracingStartedInBrowser', | 1310 TracingStartedInBrowser: 'TracingStartedInBrowser', |
| 1273 TracingStartedInPage: 'TracingStartedInPage', | 1311 TracingStartedInPage: 'TracingStartedInPage', |
| 1274 TracingSessionIdForWorker: 'TracingSessionIdForWorker', | 1312 TracingSessionIdForWorker: 'TracingSessionIdForWorker', |
| 1275 }; | 1313 }; |
| 1276 | 1314 |
| 1315 TimelineModel.TimelineModel.Thresholds = { | |
| 1316 Handler: 150, | |
|
alph
2016/11/19 05:36:27
Perhaps, there should be different types of handle
| |
| 1317 RecurringHandler: 50, | |
| 1318 ForcedLayout: 30, | |
| 1319 IdleCallbackAddon: 5 | |
| 1320 }; | |
| 1321 | |
| 1277 /** | 1322 /** |
| 1278 * @unrestricted | 1323 * @unrestricted |
| 1279 */ | 1324 */ |
| 1280 TimelineModel.TimelineModel.VirtualThread = class { | 1325 TimelineModel.TimelineModel.VirtualThread = class { |
| 1281 /** | 1326 /** |
| 1282 * @param {string} name | 1327 * @param {string} name |
| 1283 */ | 1328 */ |
| 1284 constructor(name) { | 1329 constructor(name) { |
| 1285 this.name = name; | 1330 this.name = name; |
| 1286 /** @type {!Array<!SDK.TracingModel.Event>} */ | 1331 /** @type {!Array<!SDK.TracingModel.Event>} */ |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1988 var data = event[TimelineModel.TimelineData._symbol]; | 2033 var data = event[TimelineModel.TimelineData._symbol]; |
| 1989 if (!data) { | 2034 if (!data) { |
| 1990 data = new TimelineModel.TimelineData(); | 2035 data = new TimelineModel.TimelineData(); |
| 1991 event[TimelineModel.TimelineData._symbol] = data; | 2036 event[TimelineModel.TimelineData._symbol] = data; |
| 1992 } | 2037 } |
| 1993 return data; | 2038 return data; |
| 1994 } | 2039 } |
| 1995 }; | 2040 }; |
| 1996 | 2041 |
| 1997 TimelineModel.TimelineData._symbol = Symbol('timelineData'); | 2042 TimelineModel.TimelineData._symbol = Symbol('timelineData'); |
| OLD | NEW |