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,12 +830,15 @@ 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 {
catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue(
new Callable<Void>() {
@Override @Override
public void run() { public Void call() throws Exception {
reactContext.initializeWithInstance(catalystInstance);
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle");
try { try {
catalystInstance.runJSBundle(); catalystInstance.runJSBundle();
@ -843,8 +846,12 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(RUN_JS_BUNDLE_END); ReactMarker.logMarker(RUN_JS_BUNDLE_END);
} }
return null;
}
}).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
} }
});
return reactContext; return reactContext;
} }