mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Add option to track when we're showing blankness during fast scrolling
Summary: If tracking is enabled and the sampling check passes on a scroll or layout event, we compare the scroll offset to the layout of the rendered items. If the items don't cover the visible area of the list, we fire an `onFillRateExceeded` call with relevant stats for logging the event through an analytics pipeline. The measurement methodology is a little jank because everything is async, but it seems directionally useful for getting ballpark numbers, catching regressions, and tracking improvements. Benchmark testing shows a ~2014 MotoX starts hitting the fill rate limit at about 2500 px / sec, which is pretty fast scrolling. This also reworks our frame rate stuff so we can use a shared `SceneTracking` thing and track blankness globally. Reviewed By: bvaughn Differential Revision: D4806867 fbshipit-source-id: 119bf177463c8c3aa51fa13d1a9d03b1a96042aa
This commit is contained in:
committed by
Facebook Github Bot
parent
b5327dd388
commit
f72d9dd08b
41
Libraries/Utilities/SceneTracker.js
Normal file
41
Libraries/Utilities/SceneTracker.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule SceneTracker
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
type Scene = {name: string};
|
||||
|
||||
let _listeners: Array<(scene: Scene) => void> = [];
|
||||
|
||||
let _activeScene = {name: 'default'};
|
||||
|
||||
const SceneTracker = {
|
||||
setActiveScene(scene: Scene) {
|
||||
_activeScene = scene;
|
||||
_listeners.forEach((listener) => listener(_activeScene));
|
||||
},
|
||||
|
||||
getActiveScene(): Scene {
|
||||
return _activeScene;
|
||||
},
|
||||
|
||||
addActiveSceneChangedListener(callback: (scene: Scene) => void): {remove: () => void} {
|
||||
_listeners.push(callback);
|
||||
return {
|
||||
remove: () => {
|
||||
_listeners = _listeners.filter((listener) => callback !== listener);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = SceneTracker;
|
||||
Reference in New Issue
Block a user