From 1296cb29ebf4e47333047897051bf084cf158e22 Mon Sep 17 00:00:00 2001 From: Aaron Chiu Date: Fri, 7 Oct 2016 05:31:30 -0700 Subject: [PATCH] add flag to enable lazy view managers Reviewed By: achen1 Differential Revision: D3981171 fbshipit-source-id: 2f6b8370064a5835e2e3636d4c1a7f42cc28ccaf --- Libraries/Utilities/UIManager.js | 2 ++ .../main/java/com/facebook/react/CoreModulesPackage.java | 6 +++--- .../java/com/facebook/react/ReactInstanceManager.java | 9 ++++++++- .../com/facebook/react/XReactInstanceManagerImpl.java | 9 +++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Libraries/Utilities/UIManager.js b/Libraries/Utilities/UIManager.js index 9b2f3e950..f902a78d3 100644 --- a/Libraries/Utilities/UIManager.js +++ b/Libraries/Utilities/UIManager.js @@ -98,6 +98,8 @@ if (Platform.OS === 'ios') { }); } }); +} else if (Platform.OS === 'android' && UIManager.AndroidLazyViewManagersEnabled) { + // TODO fill this out } module.exports = UIManager; diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index 5cfef3068..648116a18 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -71,9 +71,9 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_M private final UIImplementationProvider mUIImplementationProvider; CoreModulesPackage( - ReactInstanceManager reactInstanceManager, - DefaultHardwareBackBtnHandler hardwareBackBtnHandler, - UIImplementationProvider uiImplementationProvider) { + ReactInstanceManager reactInstanceManager, + DefaultHardwareBackBtnHandler hardwareBackBtnHandler, + UIImplementationProvider uiImplementationProvider) { mReactInstanceManager = reactInstanceManager; mHardwareBackBtnHandler = hardwareBackBtnHandler; mUIImplementationProvider = uiImplementationProvider; diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index c35b3dfc1..13b739c36 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -235,6 +235,7 @@ public abstract class ReactInstanceManager { protected @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler; protected @Nullable RedBoxHandler mRedBoxHandler; protected boolean mLazyNativeModulesEnabled; + protected boolean mLazyViewManagersEnabled; protected Builder() { } @@ -372,6 +373,11 @@ public abstract class ReactInstanceManager { return this; } + public Builder setLazyViewManagersEnabled(boolean lazyViewManagersEnabled) { + mLazyViewManagersEnabled = lazyViewManagersEnabled; + return this; + } + /** * Instantiates a new {@link ReactInstanceManagerImpl}. * Before calling {@code build}, the following must be called: @@ -415,7 +421,8 @@ public abstract class ReactInstanceManager { mNativeModuleCallExceptionHandler, mJSCConfig, mRedBoxHandler, - mLazyNativeModulesEnabled); + mLazyNativeModulesEnabled, + mLazyViewManagersEnabled); } } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java index 91e8f0c95..039288bfb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java @@ -86,8 +86,6 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGER import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGERS_START; import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_PACKAGES_END; import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_PACKAGES_START; -import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_END; -import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_START; import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_END; import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_START; import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; @@ -139,6 +137,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; private final @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler; private final JSCConfig mJSCConfig; private final boolean mLazyNativeModulesEnabled; + private final boolean mLazyViewManagersEnabled; private final ReactInstanceDevCommandsHandler mDevInterface = new ReactInstanceDevCommandsHandler() { @@ -297,7 +296,8 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler, JSCConfig jscConfig, @Nullable RedBoxHandler redBoxHandler, - boolean lazyNativeModulesEnabled) { + boolean lazyNativeModulesEnabled, + boolean lazyViewManagersEnabled) { initializeSoLoaderIfNecessary(applicationContext); @@ -325,6 +325,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler; mJSCConfig = jscConfig; mLazyNativeModulesEnabled = lazyNativeModulesEnabled; + mLazyViewManagersEnabled = lazyViewManagersEnabled; } @Override @@ -857,7 +858,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; "createAndProcessCoreModulesPackage"); try { CoreModulesPackage coreModulesPackage = - new CoreModulesPackage(this, mBackBtnHandler, mUIImplementationProvider); + new CoreModulesPackage(this, mBackBtnHandler, mUIImplementationProvider); processPackage( coreModulesPackage, reactContext,