From a1321aedd7f139cefa2d05bdd09866e0969120d4 Mon Sep 17 00:00:00 2001 From: Aaron Chiu Date: Fri, 9 Jun 2017 15:36:31 -0700 Subject: [PATCH] add a bunch of debug log statements Reviewed By: achen1 Differential Revision: D5216191 fbshipit-source-id: 8e8e05d4bcd8b2112fbd15b3809946f1caa0edbe --- .../facebook/react/ReactInstanceManager.java | 20 +++++++++++++++---- .../react/bridge/CatalystInstanceImpl.java | 11 +++++++--- .../facebook/react/common/ReactConstants.java | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index bf0b9b5c5..6a8c9fabe 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Process; +import android.util.Log; import android.view.View; import com.facebook.common.logging.FLog; @@ -108,8 +109,6 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JSC_CALLS; @ThreadSafe public class ReactInstanceManager { - private static final String TAG = ReactInstanceManager.class.getSimpleName(); - /** * Listener interface for react instance events. */ @@ -225,7 +224,7 @@ public class ReactInstanceManager { boolean setupReactContextInBackgroundEnabled, boolean useSeparateUIBackgroundThread, int minNumShakes) { - + Log.d(ReactConstants.TAG, "ReactInstanceManager.ctor()"); initializeSoLoaderIfNecessary(applicationContext); DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext); @@ -289,6 +288,7 @@ public class ReactInstanceManager { * Called from UI thread. */ public void createReactContextInBackground() { + Log.d(ReactConstants.TAG, "ReactInstanceManager.createReactContextInBackground()"); Assertions.assertCondition( !mHasStartedCreatingInitialContext, "createReactContextInBackground should only be called when creating the react " + @@ -317,6 +317,7 @@ public class ReactInstanceManager { @ThreadConfined(UI) private void recreateReactContextInBackgroundInner() { + Log.d(ReactConstants.TAG, "ReactInstanceManager.recreateReactContextInBackgroundInner()"); UiThreadUtil.assertOnUiThread(); if (mUseDeveloperSupport && mJSMainModuleName != null && @@ -360,6 +361,9 @@ public class ReactInstanceManager { @ThreadConfined(UI) private void recreateReactContextInBackgroundFromBundleLoader() { + Log.d( + ReactConstants.TAG, + "ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()"); recreateReactContextInBackground( new JSCJavaScriptExecutor.Factory(mJSCConfig.getConfigMap()), mBundleLoader); @@ -695,6 +699,7 @@ public class ReactInstanceManager { @ThreadConfined(UI) private void onReloadWithJSDebugger(JavaJSExecutor.Factory jsExecutorFactory) { + Log.d(ReactConstants.TAG, "ReactInstanceManager.onReloadWithJSDebugger()"); recreateReactContextInBackground( new ProxyJavaScriptExecutor.Factory(jsExecutorFactory), JSBundleLoader.createRemoteDebuggerBundleLoader( @@ -704,6 +709,7 @@ public class ReactInstanceManager { @ThreadConfined(UI) private void onJSBundleLoadedFromServer() { + Log.d(ReactConstants.TAG, "ReactInstanceManager.onJSBundleLoadedFromServer()"); recreateReactContextInBackground( new JSCJavaScriptExecutor.Factory(mJSCConfig.getConfigMap()), JSBundleLoader.createCachedBundleFromNetworkLoader( @@ -715,6 +721,7 @@ public class ReactInstanceManager { private void recreateReactContextInBackground( JavaScriptExecutor.Factory jsExecutorFactory, JSBundleLoader jsBundleLoader) { + Log.d(ReactConstants.TAG, "ReactInstanceManager.recreateReactContextInBackground()"); UiThreadUtil.assertOnUiThread(); final ReactContextInitParams initParams = new ReactContextInitParams( @@ -729,6 +736,7 @@ public class ReactInstanceManager { @ThreadConfined(UI) private void runCreateReactContextOnNewThread(final ReactContextInitParams initParams) { + Log.d(ReactConstants.TAG, "ReactInstanceManager.runCreateReactContextOnNewThread()"); UiThreadUtil.assertOnUiThread(); if (mCurrentReactContext != null) { tearDownReactContext(mCurrentReactContext); @@ -791,6 +799,7 @@ public class ReactInstanceManager { } private void setupReactContext(ReactApplicationContext reactContext) { + Log.d(ReactConstants.TAG, "ReactInstanceManager.setupReactContext()"); ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END); ReactMarker.logMarker(SETUP_REACT_CONTEXT_START); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext"); @@ -849,6 +858,7 @@ public class ReactInstanceManager { private void attachRootViewToInstance( final ReactRootView rootView, CatalystInstance catalystInstance) { + Log.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()"); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachRootViewToInstance"); if (!mSetupReactContextInBackgroundEnabled) { UiThreadUtil.assertOnUiThread(); @@ -878,12 +888,14 @@ public class ReactInstanceManager { private void detachViewFromInstance( ReactRootView rootView, CatalystInstance catalystInstance) { + Log.d(ReactConstants.TAG, "ReactInstanceManager.detachViewFromInstance()"); UiThreadUtil.assertOnUiThread(); catalystInstance.getJSModule(AppRegistry.class) .unmountApplicationComponentAtRootTag(rootView.getId()); } private void tearDownReactContext(ReactContext reactContext) { + Log.d(ReactConstants.TAG, "ReactInstanceManager.tearDownReactContext()"); UiThreadUtil.assertOnUiThread(); if (mLifecycleState == LifecycleState.RESUMED) { reactContext.onHostPause(); @@ -907,7 +919,7 @@ public class ReactInstanceManager { private ReactApplicationContext createReactContext( JavaScriptExecutor jsExecutor, JSBundleLoader jsBundleLoader) { - FLog.i(ReactConstants.TAG, "Creating react context."); + Log.d(ReactConstants.TAG, "ReactInstanceManager.createReactContext()"); ReactMarker.logMarker(CREATE_REACT_CONTEXT_START); final ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext); NativeModuleRegistryBuilder nativeModuleRegistryBuilder = new NativeModuleRegistryBuilder( diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 2dccb7580..b6c350093 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -18,6 +18,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicInteger; import android.content.res.AssetManager; +import android.util.Log; import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; @@ -95,7 +96,7 @@ public class CatalystInstanceImpl implements CatalystInstance { final JavaScriptModuleRegistry jsModuleRegistry, final JSBundleLoader jsBundleLoader, NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) { - FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge."); + Log.d(ReactConstants.TAG, "Initializing React Xplat Bridge."); mHybridData = initHybrid(); mReactQueueConfiguration = ReactQueueConfigurationImpl.create( @@ -110,7 +111,7 @@ public class CatalystInstanceImpl implements CatalystInstance { mUIBackgroundQueueThread = mReactQueueConfiguration.getUIBackgroundQueueThread(); mTraceListener = new JSProfilerTraceListener(this); - FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge"); + Log.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge"); initializeBridge( new BridgeCallback(this), jsExecutor, @@ -119,7 +120,7 @@ public class CatalystInstanceImpl implements CatalystInstance { mUIBackgroundQueueThread, mJavaRegistry.getJavaModules(this), mJavaRegistry.getCxxModules()); - FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge"); + Log.d(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge"); } private static class BridgeCallback implements ReactCallback { @@ -197,6 +198,7 @@ public class CatalystInstanceImpl implements CatalystInstance { @Override public void runJSBundle() { + Log.d(ReactConstants.TAG, "CatalystInstanceImpl.runJSBundle()"); Assertions.assertCondition(!mJSBundleHasLoaded, "JS bundle was already loaded!"); // incrementPendingJSCalls(); @@ -279,6 +281,7 @@ public class CatalystInstanceImpl implements CatalystInstance { */ @Override public void destroy() { + Log.d(ReactConstants.TAG, "CatalystInstanceImpl.destroy() start"); UiThreadUtil.assertOnUiThread(); if (mDestroyed) { @@ -304,6 +307,7 @@ public class CatalystInstanceImpl implements CatalystInstance { mHybridData.resetNative(); // Kill non-UI threads from UI thread. getReactQueueConfiguration().destroy(); + Log.d(ReactConstants.TAG, "CatalystInstanceImpl.destroy() end"); } }); } @@ -324,6 +328,7 @@ public class CatalystInstanceImpl implements CatalystInstance { @VisibleForTesting @Override public void initialize() { + Log.d(ReactConstants.TAG, "CatalystInstanceImpl.initialize()"); Assertions.assertCondition( !mInitialized, "This catalyst instance has already been initialized"); diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/ReactConstants.java b/ReactAndroid/src/main/java/com/facebook/react/common/ReactConstants.java index 9023f4150..7de8d922f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/ReactConstants.java +++ b/ReactAndroid/src/main/java/com/facebook/react/common/ReactConstants.java @@ -11,5 +11,5 @@ package com.facebook.react.common; public class ReactConstants { - public static final String TAG = "React"; + public static final String TAG = "ReactNative"; }