Eagerly create FBMarketplaceNativeModule [2/N]

Summary:
The full idea for eagerly creating Native Modules is articulated here https://fb.quip.com/vWcLAup3a6kR

TLDR:
1) Move lazy native module work from the mqt_js thread to the background thread which processes packages. This also moves it from post-network to pre-network.
2) For a quick test, decide which modules to eagerly create with a QE flag.
3) Eagerly create the modules by opting-out of the ReactModuleInfo pipeline which was built for lazy native modules.

Reviewed By: achen1

Differential Revision: D9503934

fbshipit-source-id: 0cd8337ad294cd0f8be692fecbf4292d204f3ec4
This commit is contained in:
Peter Argany 2018-08-28 10:58:24 -07:00 committed by Facebook Github Bot
parent e8c7cb1c04
commit 58409be6b4
2 changed files with 10 additions and 1 deletions

View File

@ -96,6 +96,14 @@ public abstract class LazyReactPackage implements ReactPackage {
return modules;
}
/**
* @return list of native modules which should be eagerly initialized.
*/
public List<String> getEagerNativeModules() {
return Collections.emptyList();
}
/**
* @param reactContext react application context that can be used to create View Managers.
* @return list of module specs that can create the View Managers.

View File

@ -45,6 +45,7 @@ public class NativeModuleRegistryBuilder {
if (reactPackage instanceof LazyReactPackage) {
LazyReactPackage lazyReactPackage = (LazyReactPackage) reactPackage;
List<ModuleSpec> moduleSpecs = lazyReactPackage.getNativeModules(mReactApplicationContext);
List<String> eagerNativeModules = lazyReactPackage.getEagerNativeModules();
Map<String, ReactModuleInfo> reactModuleInfoMap =
lazyReactPackage.getReactModuleInfoProvider().getReactModuleInfos();
@ -52,7 +53,7 @@ public class NativeModuleRegistryBuilder {
String className = moduleSpec.getClassName();
ReactModuleInfo reactModuleInfo = reactModuleInfoMap.get(className);
ModuleHolder moduleHolder;
if (reactModuleInfo == null) {
if (reactModuleInfo == null || eagerNativeModules.contains(className)) {
NativeModule module;
ReactMarker.logMarker(
ReactMarkerConstants.CREATE_MODULE_START,