Revert "Report low FPS to analytics"
This reverts commit f0f3b29142
.
Reason for revert: We don't use this metric and it has high impact on CPU
Change-Id: Ic125966c765ff4625d6e1d34315f4e0d0b442be3
This commit is contained in:
@@ -1,61 +0,0 @@
|
|||||||
/**
|
|
||||||
* @license
|
|
||||||
* Copyright (C) 2016 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
(function() {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const JANK_SLEEP_TIME_MS = 1000;
|
|
||||||
|
|
||||||
const GrJankDetector = {
|
|
||||||
// Slowdowns counter.
|
|
||||||
jank: 0,
|
|
||||||
fps: 0,
|
|
||||||
_lastFrameTime: 0,
|
|
||||||
|
|
||||||
start() {
|
|
||||||
this._requestAnimationFrame(this._detect.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
_requestAnimationFrame(callback) {
|
|
||||||
window.requestAnimationFrame(callback);
|
|
||||||
},
|
|
||||||
|
|
||||||
_detect(now) {
|
|
||||||
if (this._lastFrameTime === 0) {
|
|
||||||
this._lastFrameTime = now;
|
|
||||||
this.fps = 0;
|
|
||||||
this._requestAnimationFrame(this._detect.bind(this));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const fpsNow = 1000/(now - this._lastFrameTime);
|
|
||||||
this._lastFrameTime = now;
|
|
||||||
// Calculate moving average within last 3 measurements.
|
|
||||||
this.fps = this.fps === 0 ? fpsNow : ((this.fps * 2 + fpsNow) / 3);
|
|
||||||
if (this.fps > 10) {
|
|
||||||
this._requestAnimationFrame(this._detect.bind(this));
|
|
||||||
} else {
|
|
||||||
this.jank++;
|
|
||||||
console.warn('JANK', this.jank);
|
|
||||||
this._lastFrameTime = 0;
|
|
||||||
window.setTimeout(
|
|
||||||
() => this._requestAnimationFrame(this._detect.bind(this)),
|
|
||||||
JANK_SLEEP_TIME_MS);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
window.GrJankDetector = GrJankDetector;
|
|
||||||
})();
|
|
@@ -1,80 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<!--
|
|
||||||
@license
|
|
||||||
Copyright (C) 2018 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
|
||||||
<title>gr-jank-detector</title>
|
|
||||||
<script src="/test/common-test-setup.js"></script>
|
|
||||||
<script src="/bower_components/webcomponentsjs/custom-elements-es5-adapter.js"></script>
|
|
||||||
|
|
||||||
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
|
|
||||||
<script src="/bower_components/web-component-tester/browser.js"></script>
|
|
||||||
<link rel="import" href="../../../test/common-test-setup.html"/>
|
|
||||||
|
|
||||||
<script src="gr-jank-detector.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
suite('gr-jank-detector tests', () => {
|
|
||||||
let sandbox;
|
|
||||||
let clock;
|
|
||||||
let instance;
|
|
||||||
|
|
||||||
const NOW_TIME = 100;
|
|
||||||
|
|
||||||
setup(() => {
|
|
||||||
sandbox = sinon.sandbox.create();
|
|
||||||
clock = sinon.useFakeTimers(NOW_TIME);
|
|
||||||
instance = GrJankDetector;
|
|
||||||
instance._lastFrameTime = 0;
|
|
||||||
sandbox.stub(instance, '_requestAnimationFrame');
|
|
||||||
});
|
|
||||||
|
|
||||||
teardown(() => {
|
|
||||||
sandbox.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('start() installs frame callback', () => {
|
|
||||||
sandbox.stub(instance, '_detect');
|
|
||||||
instance._requestAnimationFrame.callsArg(0);
|
|
||||||
instance.start();
|
|
||||||
assert.isTrue(instance._detect.calledOnce);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('measures fps', () => {
|
|
||||||
instance._detect(10);
|
|
||||||
instance._detect(30);
|
|
||||||
assert.equal(instance.fps, 50);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('detects jank', () => {
|
|
||||||
let now = 10;
|
|
||||||
instance._detect(now);
|
|
||||||
const fastFrame = () => instance._detect(now += 20);
|
|
||||||
const slowFrame = () => instance._detect(now += 300);
|
|
||||||
fastFrame();
|
|
||||||
assert.equal(instance.jank, 0);
|
|
||||||
_.times(4, slowFrame);
|
|
||||||
assert.equal(instance.jank, 0);
|
|
||||||
instance._requestAnimationFrame.reset();
|
|
||||||
slowFrame();
|
|
||||||
assert.equal(instance.jank, 1);
|
|
||||||
assert.isFalse(instance._requestAnimationFrame.called);
|
|
||||||
clock.tick(1000);
|
|
||||||
assert.isTrue(instance._requestAnimationFrame.called);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
@@ -18,6 +18,5 @@ limitations under the License.
|
|||||||
<link rel="import" href="/bower_components/polymer/polymer.html">
|
<link rel="import" href="/bower_components/polymer/polymer.html">
|
||||||
|
|
||||||
<dom-module id="gr-reporting">
|
<dom-module id="gr-reporting">
|
||||||
<script src="gr-jank-detector.js"></script>
|
|
||||||
<script src="gr-reporting.js"></script>
|
<script src="gr-reporting.js"></script>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@@ -49,14 +49,6 @@
|
|||||||
STARTED_HIDDEN: 'hidden',
|
STARTED_HIDDEN: 'hidden',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Frame rate related constants.
|
|
||||||
const JANK = {
|
|
||||||
TYPE: 'lifecycle',
|
|
||||||
CATEGORY: 'UI Latency',
|
|
||||||
// Reported events - alphabetize below.
|
|
||||||
COUNT: 'Jank count',
|
|
||||||
};
|
|
||||||
|
|
||||||
// Navigation reporting constants.
|
// Navigation reporting constants.
|
||||||
const NAVIGATION = {
|
const NAVIGATION = {
|
||||||
TYPE: 'nav-report',
|
TYPE: 'nav-report',
|
||||||
@@ -150,8 +142,6 @@
|
|||||||
};
|
};
|
||||||
catchErrors();
|
catchErrors();
|
||||||
|
|
||||||
GrJankDetector.start();
|
|
||||||
|
|
||||||
// The Polymer pass of JSCompiler requires this to be reassignable
|
// The Polymer pass of JSCompiler requires this to be reassignable
|
||||||
// eslint-disable-next-line prefer-const
|
// eslint-disable-next-line prefer-const
|
||||||
let GrReporting = Polymer({
|
let GrReporting = Polymer({
|
||||||
@@ -291,11 +281,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
beforeLocationChanged() {
|
beforeLocationChanged() {
|
||||||
if (GrJankDetector.jank > 0) {
|
|
||||||
this.reporter(
|
|
||||||
JANK.TYPE, JANK.CATEGORY, JANK.COUNT, GrJankDetector.jank);
|
|
||||||
GrJankDetector.jank = 0;
|
|
||||||
}
|
|
||||||
for (const prop of Object.keys(this._baselines)) {
|
for (const prop of Object.keys(this._baselines)) {
|
||||||
delete this._baselines[prop];
|
delete this._baselines[prop];
|
||||||
}
|
}
|
||||||
|
@@ -95,11 +95,7 @@ limitations under the License.
|
|||||||
test('beforeLocationChanged', () => {
|
test('beforeLocationChanged', () => {
|
||||||
element._baselines['garbage'] = 'monster';
|
element._baselines['garbage'] = 'monster';
|
||||||
sandbox.stub(element, 'time');
|
sandbox.stub(element, 'time');
|
||||||
GrJankDetector.jank = 42;
|
|
||||||
element.beforeLocationChanged();
|
element.beforeLocationChanged();
|
||||||
assert.equal(GrJankDetector.jank, 0);
|
|
||||||
assert.isTrue(element.reporter.calledWithExactly(
|
|
||||||
'lifecycle', 'UI Latency', 'Jank count', 42));
|
|
||||||
assert.isTrue(element.time.calledWithExactly('DashboardDisplayed'));
|
assert.isTrue(element.time.calledWithExactly('DashboardDisplayed'));
|
||||||
assert.isTrue(element.time.calledWithExactly('ChangeDisplayed'));
|
assert.isTrue(element.time.calledWithExactly('ChangeDisplayed'));
|
||||||
assert.isTrue(element.time.calledWithExactly('ChangeFullyLoaded'));
|
assert.isTrue(element.time.calledWithExactly('ChangeFullyLoaded'));
|
||||||
|
@@ -100,7 +100,6 @@ limitations under the License.
|
|||||||
'core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog_test.html',
|
'core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog_test.html',
|
||||||
'core/gr-main-header/gr-main-header_test.html',
|
'core/gr-main-header/gr-main-header_test.html',
|
||||||
'core/gr-navigation/gr-navigation_test.html',
|
'core/gr-navigation/gr-navigation_test.html',
|
||||||
'core/gr-reporting/gr-jank-detector_test.html',
|
|
||||||
'core/gr-reporting/gr-reporting_test.html',
|
'core/gr-reporting/gr-reporting_test.html',
|
||||||
'core/gr-router/gr-router_test.html',
|
'core/gr-router/gr-router_test.html',
|
||||||
'core/gr-search-bar/gr-search-bar_test.html',
|
'core/gr-search-bar/gr-search-bar_test.html',
|
||||||
|
Reference in New Issue
Block a user