From c82856fb7a519edfd3d7b5c31e308e702fdb6237 Mon Sep 17 00:00:00 2001 From: Aaron Chiu Date: Fri, 27 May 2016 04:59:46 -0700 Subject: [PATCH] unbreak RN startup Reviewed By: lexs Differential Revision: D3352709 fbshipit-source-id: 56cdec2dee46ab1f011bed9aadd14ea464ec4163 --- .../react/XReactInstanceManagerImpl.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java index 57601d12f..1b72f4d0a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java @@ -764,7 +764,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; NativeModuleRegistry.Builder nativeRegistryBuilder = new NativeModuleRegistry.Builder(); JavaScriptModuleRegistry.Builder jsModulesBuilder = new JavaScriptModuleRegistry.Builder(); - ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext); + final ReactApplicationContext reactContext = new ReactApplicationContext(mApplicationContext); if (mUseDeveloperSupport) { reactContext.setNativeModuleCallExceptionHandler(mDevSupportManager); } @@ -830,21 +830,28 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener); } - reactContext.initializeWithInstance(catalystInstance); ReactMarker.logMarker(RUN_JS_BUNDLE_START); - catalystInstance.getReactQueueConfiguration().getJSQueueThread().runOnQueue(new Runnable() { - @Override - public void run() { - Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); - try { - catalystInstance.runJSBundle(); - } finally { - Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); - ReactMarker.logMarker(RUN_JS_BUNDLE_END); - } - } - }); + try { + catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue( + new Callable() { + @Override + public Void call() throws Exception { + reactContext.initializeWithInstance(catalystInstance); + + Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); + 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; }