Skip to content

Commit

Permalink
add a bunch of debug log statements
Browse files Browse the repository at this point in the history
Reviewed By: achen1

Differential Revision: D5216191

fbshipit-source-id: 8e8e05d4bcd8b2112fbd15b3809946f1caa0edbe
  • Loading branch information
aaronechiu authored and facebook-github-bot committed Jun 9, 2017
1 parent 4990c5c commit a1321ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -108,8 +109,6 @@
@ThreadSafe
public class ReactInstanceManager {

private static final String TAG = ReactInstanceManager.class.getSimpleName();

/**
* Listener interface for react instance events.
*/
Expand Down Expand Up @@ -225,7 +224,7 @@ public static ReactInstanceManagerBuilder builder() {
boolean setupReactContextInBackgroundEnabled,
boolean useSeparateUIBackgroundThread,
int minNumShakes) {

Log.d(ReactConstants.TAG, "ReactInstanceManager.ctor()");
initializeSoLoaderIfNecessary(applicationContext);

DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);
Expand Down Expand Up @@ -289,6 +288,7 @@ private static void initializeSoLoaderIfNecessary(Context applicationContext) {
* 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 " +
Expand Down Expand Up @@ -317,6 +317,7 @@ public void recreateReactContextInBackground() {

@ThreadConfined(UI)
private void recreateReactContextInBackgroundInner() {
Log.d(ReactConstants.TAG, "ReactInstanceManager.recreateReactContextInBackgroundInner()");
UiThreadUtil.assertOnUiThread();

if (mUseDeveloperSupport && mJSMainModuleName != null &&
Expand Down Expand Up @@ -360,6 +361,9 @@ public void run() {

@ThreadConfined(UI)
private void recreateReactContextInBackgroundFromBundleLoader() {
Log.d(
ReactConstants.TAG,
"ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()");
recreateReactContextInBackground(
new JSCJavaScriptExecutor.Factory(mJSCConfig.getConfigMap()),
mBundleLoader);
Expand Down Expand Up @@ -695,6 +699,7 @@ public int getMinNumShakes() {

@ThreadConfined(UI)
private void onReloadWithJSDebugger(JavaJSExecutor.Factory jsExecutorFactory) {
Log.d(ReactConstants.TAG, "ReactInstanceManager.onReloadWithJSDebugger()");
recreateReactContextInBackground(
new ProxyJavaScriptExecutor.Factory(jsExecutorFactory),
JSBundleLoader.createRemoteDebuggerBundleLoader(
Expand All @@ -704,6 +709,7 @@ private void onReloadWithJSDebugger(JavaJSExecutor.Factory jsExecutorFactory) {

@ThreadConfined(UI)
private void onJSBundleLoadedFromServer() {
Log.d(ReactConstants.TAG, "ReactInstanceManager.onJSBundleLoadedFromServer()");
recreateReactContextInBackground(
new JSCJavaScriptExecutor.Factory(mJSCConfig.getConfigMap()),
JSBundleLoader.createCachedBundleFromNetworkLoader(
Expand All @@ -715,6 +721,7 @@ private void onJSBundleLoadedFromServer() {
private void recreateReactContextInBackground(
JavaScriptExecutor.Factory jsExecutorFactory,
JSBundleLoader jsBundleLoader) {
Log.d(ReactConstants.TAG, "ReactInstanceManager.recreateReactContextInBackground()");
UiThreadUtil.assertOnUiThread();

final ReactContextInitParams initParams = new ReactContextInitParams(
Expand All @@ -729,6 +736,7 @@ private void recreateReactContextInBackground(

@ThreadConfined(UI)
private void runCreateReactContextOnNewThread(final ReactContextInitParams initParams) {
Log.d(ReactConstants.TAG, "ReactInstanceManager.runCreateReactContextOnNewThread()");
UiThreadUtil.assertOnUiThread();
if (mCurrentReactContext != null) {
tearDownReactContext(mCurrentReactContext);
Expand Down Expand Up @@ -791,6 +799,7 @@ public void run() {
}

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");
Expand Down Expand Up @@ -849,6 +858,7 @@ public void run() {
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();
Expand Down Expand Up @@ -878,12 +888,14 @@ public void run() {
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();
Expand All @@ -907,7 +919,7 @@ private void tearDownReactContext(ReactContext reactContext) {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -95,7 +96,7 @@ private CatalystInstanceImpl(
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(
Expand All @@ -110,7 +111,7 @@ private CatalystInstanceImpl(
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,
Expand All @@ -119,7 +120,7 @@ private CatalystInstanceImpl(
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 {
Expand Down Expand Up @@ -197,6 +198,7 @@ private native void initializeBridge(

@Override
public void runJSBundle() {
Log.d(ReactConstants.TAG, "CatalystInstanceImpl.runJSBundle()");
Assertions.assertCondition(!mJSBundleHasLoaded, "JS bundle was already loaded!");

// incrementPendingJSCalls();
Expand Down Expand Up @@ -279,6 +281,7 @@ public void invokeCallback(final int callbackID, final NativeArray arguments) {
*/
@Override
public void destroy() {
Log.d(ReactConstants.TAG, "CatalystInstanceImpl.destroy() start");
UiThreadUtil.assertOnUiThread();

if (mDestroyed) {
Expand All @@ -304,6 +307,7 @@ public void run() {
mHybridData.resetNative();
// Kill non-UI threads from UI thread.
getReactQueueConfiguration().destroy();
Log.d(ReactConstants.TAG, "CatalystInstanceImpl.destroy() end");
}
});
}
Expand All @@ -324,6 +328,7 @@ public boolean isDestroyed() {
@VisibleForTesting
@Override
public void initialize() {
Log.d(ReactConstants.TAG, "CatalystInstanceImpl.initialize()");
Assertions.assertCondition(
!mInitialized,
"This catalyst instance has already been initialized");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

public class ReactConstants {

public static final String TAG = "React";
public static final String TAG = "ReactNative";
}

0 comments on commit a1321ae

Please sign in to comment.