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:
Spencer Ahrens
2017-04-07 00:48:49 -07:00
committed by Facebook Github Bot
parent b5327dd388
commit f72d9dd08b
6 changed files with 387 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ const BugReporting = require('BugReporting');
const FrameRateLogger = require('FrameRateLogger');
const NativeModules = require('NativeModules');
const ReactNative = require('ReactNative');
const SceneTracker = require('SceneTracker');
const infoLog = require('infoLog');
const invariant = require('fbjs/lib/invariant');
@@ -56,6 +57,8 @@ const sections: Runnables = {};
const tasks: Map<string, TaskProvider> = new Map();
let componentProviderInstrumentationHook: ComponentProviderInstrumentationHook =
(component: ComponentProvider) => component();
let _frameRateLoggerSceneListener = null;
/**
* `AppRegistry` is the JS entry point to running all React Native apps. App
@@ -173,7 +176,12 @@ const AppRegistry = {
'This error can also happen due to a require() error during ' +
'initialization or failure to call AppRegistry.registerComponent.\n\n'
);
FrameRateLogger.setContext(appKey);
if (!_frameRateLoggerSceneListener) {
_frameRateLoggerSceneListener = SceneTracker.addActiveSceneChangedListener(
(scene) => FrameRateLogger.setContext(scene.name)
);
}
SceneTracker.setActiveScene({name: appKey});
runnables[appKey].run(appParameters);
},