If fbsystrace is running when catalyst starts, it asserts

Summary: registering with systrace checks if the bridge is
initialized, which it's not yet in the ctor.  Defer registration until
after the bridge is created, and only unregister in that case.
public

Reviewed By: astreet, dreiss

Differential Revision: D2651244

fb-gh-sync-id: 8da1108e9d15fddde48d06f4ed61ee0f787016ad
This commit is contained in:
Marc Horowitz 2015-11-20 09:09:36 -08:00 committed by facebook-github-bot-0
parent 7febd13676
commit 67209e6396
1 changed files with 3 additions and 2 deletions

View File

@ -82,7 +82,6 @@ public class CatalystInstance {
mJSBundleLoader = jsBundleLoader; mJSBundleLoader = jsBundleLoader;
mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler; mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
mTraceListener = new JSProfilerTraceListener(); mTraceListener = new JSProfilerTraceListener();
Systrace.registerListener(mTraceListener);
final CountDownLatch initLatch = new CountDownLatch(1); final CountDownLatch initLatch = new CountDownLatch(1);
mCatalystQueueConfiguration.getJSQueueThread().runOnQueue( mCatalystQueueConfiguration.getJSQueueThread().runOnQueue(
@ -116,6 +115,8 @@ public class CatalystInstance {
mBridge.setGlobalVariable( mBridge.setGlobalVariable(
"__fbBatchedBridgeConfig", "__fbBatchedBridgeConfig",
buildModulesConfigJSONProperty(mJavaRegistry, jsModulesConfig)); buildModulesConfigJSONProperty(mJavaRegistry, jsModulesConfig));
Systrace.registerListener(mTraceListener);
} }
public void runJSBundle() { public void runJSBundle() {
@ -239,7 +240,7 @@ public class CatalystInstance {
} }
} }
if (mTraceListener != null) { if (mBridge != null) {
Systrace.unregisterListener(mTraceListener); Systrace.unregisterListener(mTraceListener);
} }