mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-28 16:34:49 +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
30
Libraries/Utilities/__tests__/SceneTracker-test.js
Normal file
30
Libraries/Utilities/__tests__/SceneTracker-test.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
jest.unmock('SceneTracker');
|
||||
|
||||
const SceneTracker = require('SceneTracker');
|
||||
|
||||
describe('setActiveScene', function() {
|
||||
|
||||
it('can handle multiple listeners and unsubscribe', function() {
|
||||
const listeners = [jest.fn(), jest.fn(), jest.fn()];
|
||||
const subscriptions = listeners.map(
|
||||
(listener) => SceneTracker.addActiveSceneChangedListener(listener)
|
||||
);
|
||||
subscriptions[1].remove();
|
||||
const newScene = {name: 'scene1'};
|
||||
SceneTracker.setActiveScene(newScene);
|
||||
expect(listeners[0]).toBeCalledWith(newScene);
|
||||
expect(listeners[1]).not.toBeCalled();
|
||||
expect(listeners[2]).toBeCalledWith(newScene);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user