forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1107949-framerate-e10s.patch
227 lines (214 loc) · 7.77 KB
/
1107949-framerate-e10s.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
From: Jordan Santell <[email protected]>
Date: Mon, 9 Feb 2015 17:17:43 -0800
Subject: Bug 1107949 - framerate actor now continues recording in e10s after a page refresh. r=vp
diff --git a/browser/devtools/performance/test/browser.ini b/browser/devtools/performance/test/browser.ini
index 0688697..50c3262 100644
--- a/browser/devtools/performance/test/browser.ini
+++ b/browser/devtools/performance/test/browser.ini
@@ -56,16 +56,17 @@ support-files =
[browser_perf-overview-render-03.js]
[browser_perf-overview-selection-01.js]
[browser_perf-overview-selection-02.js]
[browser_perf-overview-selection-03.js]
[browser_perf-overview-time-interval.js]
[browser_perf-shared-connection-02.js]
[browser_perf-shared-connection-03.js]
[browser_perf-states.js]
+[browser_perf-refresh.js]
[browser_perf-ui-recording.js]
[browser_perf-recording-notices-01.js]
[browser_perf-recording-notices-02.js]
[browser_perf_recordings-io-01.js]
[browser_perf_recordings-io-02.js]
[browser_perf_recordings-io-03.js]
[browser_perf_recordings-io-04.js]
# [browser_perf-range-changed-render.js] bug 1130669 crash
diff --git a/browser/devtools/performance/test/browser_perf-refresh.js b/browser/devtools/performance/test/browser_perf-refresh.js
new file mode 100644
index 0000000..ee4cdcb
--- /dev/null
+++ b/browser/devtools/performance/test/browser_perf-refresh.js
@@ -0,0 +1,42 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Rough test that the recording still continues after a refresh.
+ */
+function spawnTest () {
+ let { panel, target } = yield initPerformance(SIMPLE_URL);
+ let { EVENTS, PerformanceController } = panel.panelWin;
+
+ // Enable memory to test all the overview graphs.
+ Services.prefs.setBoolPref(MEMORY_PREF, true);
+
+ yield startRecording(panel);
+
+ yield reload(target)
+
+ let rec = PerformanceController.getCurrentRecording();
+ let { markers, memory, ticks } = rec.getAllData();
+ // Store current length of items
+ let markersLength = markers.length;
+ let memoryLength = memory.length;
+ let ticksLength = ticks.length;
+
+ ok(rec.isRecording(), "RecordingModel should still be recording after reload");
+
+ yield busyWait(100);
+ yield waitUntil(() => rec.getMarkers().length > markersLength);
+ yield waitUntil(() => rec.getMemory().length > memoryLength);
+ yield waitUntil(() => rec.getTicks().length > ticksLength);
+ ok("Markers, memory and ticks continue after reload");
+
+ yield stopRecording(panel);
+
+ let { allocations, profile, frames } = rec.getAllData();
+ ok(allocations, "allocations exist after refresh");
+ ok(profile, "profile exists after refresh");
+ ok(frames, "frames exist after refresh");
+
+ yield teardown(panel);
+ finish();
+}
diff --git a/browser/devtools/performance/test/head.js b/browser/devtools/performance/test/head.js
index 272be3f..9619e41 100644
--- a/browser/devtools/performance/test/head.js
+++ b/browser/devtools/performance/test/head.js
@@ -408,8 +408,13 @@ function getSourceActor(aSources, aURL) {
}
/**
* Fires a key event, like "VK_UP", "VK_DOWN", etc.
*/
function fireKey (e) {
EventUtils.synthesizeKey(e, {});
}
+
+function reload (aTarget, aEvent = "navigate") {
+ aTarget.activeTab.reload();
+ return once(aTarget, aEvent);
+}
diff --git a/toolkit/devtools/server/actors/framerate.js b/toolkit/devtools/server/actors/framerate.js
index 1726f5c..fe69a89 100644
--- a/toolkit/devtools/server/actors/framerate.js
+++ b/toolkit/devtools/server/actors/framerate.js
@@ -15,36 +15,39 @@ const {method, custom, Arg, Option, RetVal} = protocol;
/**
* A very simple utility for monitoring framerate.
*/
let FramerateActor = exports.FramerateActor = protocol.ActorClass({
typeName: "framerate",
initialize: function(conn, tabActor) {
protocol.Actor.prototype.initialize.call(this, conn);
this.tabActor = tabActor;
- this._chromeWin = getChromeWin(tabActor.window);
+ this._contentWin = tabActor.window;
this._onRefreshDriverTick = this._onRefreshDriverTick.bind(this);
+ this._onGlobalCreated = this._onGlobalCreated.bind(this);
+ on(this.tabActor, "window-ready", this._onGlobalCreated);
},
destroy: function(conn) {
+ off(this.tabActor, "window-ready", this._onGlobalCreated);
protocol.Actor.prototype.destroy.call(this, conn);
this.stopRecording();
},
/**
* Starts monitoring framerate, storing the frames per second.
*/
startRecording: method(function() {
if (this._recording) {
return;
}
this._recording = true;
this._ticks = [];
- this._startTime = this._chromeWin.performance.now();
- this._rafID = this._chromeWin.requestAnimationFrame(this._onRefreshDriverTick);
+ this._startTime = this._contentWin.performance.now();
+ this._rafID = this._contentWin.requestAnimationFrame(this._onRefreshDriverTick);
}, {
}),
/**
* Stops monitoring framerate, returning the recorded values.
*/
stopRecording: method(function(beginAt = 0, endAt = Number.MAX_SAFE_INTEGER) {
if (!this._recording) {
@@ -60,17 +63,17 @@ let FramerateActor = exports.FramerateActor = protocol.ActorClass({
},
response: { ticks: RetVal("array:number") }
}),
/**
* Stops monitoring framerate, without returning the recorded values.
*/
cancelRecording: method(function() {
- this._chromeWin.cancelAnimationFrame(this._rafID);
+ this._contentWin.cancelAnimationFrame(this._rafID);
this._recording = false;
this._ticks = null;
this._rafID = -1;
}, {
}),
/**
* Returns whether this actor is currently active.
@@ -99,22 +102,37 @@ let FramerateActor = exports.FramerateActor = protocol.ActorClass({
/**
* Function invoked along with the refresh driver.
*/
_onRefreshDriverTick: function() {
if (!this._recording) {
return;
}
- this._rafID = this._chromeWin.requestAnimationFrame(this._onRefreshDriverTick);
+ this._rafID = this._contentWin.requestAnimationFrame(this._onRefreshDriverTick);
// Store the amount of time passed since the recording started.
- let currentTime = this._chromeWin.performance.now();
- let elapsedTime = currentTime - this._startTime;
- this._ticks.push(elapsedTime);
+ let currentTime = this._contentWin.performance.now();
+
+ // Store _elapsedTime so we can use this as a new starting time on a page refresh
+ // to normalize times.
+ this._elapsedTime = currentTime - this._startTime;
+ this._ticks.push(this._elapsedTime);
+ },
+
+ /**
+ * When the content window for the tab actor is created.
+ */
+ _onGlobalCreated: function (win) {
+ if (this._recording) {
+ // Set _startTime to the currently elapsed time so we can get a wholistic
+ // elapsed time in _onRefreshDriverTick.
+ this._startTime = -this._elapsedTime;
+ this._rafID = this._contentWin.requestAnimationFrame(this._onRefreshDriverTick);
+ }
}
});
/**
* The corresponding Front object for the FramerateActor.
*/
let FramerateFront = exports.FramerateFront = protocol.FrontClass(FramerateActor, {
initialize: function(client, { framerateActor }) {
@@ -166,23 +184,8 @@ FramerateFront.plotFPS = function(ticks, interval = 100, clamp = 60) {
timeline.push({ delta: currTime, value: framerate });
frameCount = 0;
prevTime = currTime;
}
return timeline;
};
-
-/**
- * Gets the top level browser window from a content window.
- *
- * @param nsIDOMWindow innerWin
- * The content window to query.
- * @return nsIDOMWindow
- * The top level browser window.
- */
-function getChromeWin(innerWin) {
- return innerWin
- .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
- .QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
- .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
-}
--
2.2.1