unbreak RN startup

Reviewed By: lexs

Differential Revision: D3352709

fbshipit-source-id: 56cdec2dee46ab1f011bed9aadd14ea464ec4163
This commit is contained in:
Aaron Chiu 2016-05-27 04:59:46 -07:00 committed by Facebook Github Bot 8
parent 3f2f773388
commit c82856fb7a
1 changed files with 21 additions and 14 deletions

View File

@ -764,7 +764,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
NativeModuleRegistry.Builder nativeRegistryBuilder = new NativeModuleRegistry.Builder(); NativeModuleRegistry.Builder nativeRegistryBuilder = new NativeModuleRegistry.Builder();
JavaScriptModuleRegistry.Builder jsModulesBuilder = new JavaScriptModuleRegistry.Builder(); JavaScriptModuleRegistry.Builder jsModulesBuilder = new JavaScriptModuleRegistry.Builder();
ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext); final ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext);
if (mUseDeveloperSupport) { if (mUseDeveloperSupport) {
reactContext.setNativeModuleCallExceptionHandler(mDevSupportManager); reactContext.setNativeModuleCallExceptionHandler(mDevSupportManager);
} }
@ -830,21 +830,28 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener); catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
} }
reactContext.initializeWithInstance(catalystInstance);
ReactMarker.logMarker(RUN_JS_BUNDLE_START); ReactMarker.logMarker(RUN_JS_BUNDLE_START);
catalystInstance.getReactQueueConfiguration().getJSQueueThread().runOnQueue(new Runnable() { try {
@Override catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue(
public void run() { new Callable<Void>() {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); @Override
try { public Void call() throws Exception {
catalystInstance.runJSBundle(); reactContext.initializeWithInstance(catalystInstance);
} finally {
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle");
ReactMarker.logMarker(RUN_JS_BUNDLE_END); try {
} catalystInstance.runJSBundle();
} } finally {
}); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(RUN_JS_BUNDLE_END);
}
return null;
}
}).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
return reactContext; return reactContext;
} }