mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-15 07:28:31 +08:00
Move thread jump for js loading into NativeToJSBridge, out of platform code
Reviewed By: javache Differential Revision: D3906009 fbshipit-source-id: b9782a6c209e3c1626899dac7fd50233cdef87f3
This commit is contained in:
committed by
Facebook Github Bot 7
parent
72e203bf95
commit
971cda8794
@@ -18,8 +18,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
@@ -924,33 +922,8 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
|
||||
}
|
||||
|
||||
ReactMarker.logMarker(RUN_JS_BUNDLE_START);
|
||||
try {
|
||||
catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue(
|
||||
new Callable<Void>() {
|
||||
@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 e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
if (e.getCause() instanceof RuntimeException) {
|
||||
throw (RuntimeException) e.getCause();
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
reactContext.initializeWithInstance(catalystInstance);
|
||||
catalystInstance.runJSBundle();
|
||||
|
||||
return reactContext;
|
||||
}
|
||||
|
||||
@@ -167,14 +167,14 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
@Override
|
||||
public void runJSBundle() {
|
||||
// This should really be done when we post the task that runs the JS bundle
|
||||
// (don't even need to wait for it to finish). Since that is currently done
|
||||
// synchronously, marking it here is fine.
|
||||
mAcceptCalls = true;
|
||||
Assertions.assertCondition(!mJSBundleHasLoaded, "JS bundle was already loaded!");
|
||||
mJSBundleHasLoaded = true;
|
||||
// incrementPendingJSCalls();
|
||||
mJSBundleLoader.loadScript(CatalystInstanceImpl.this);
|
||||
// Loading the bundle is queued on the JS thread, but may not have
|
||||
// run yet. It's save to set this here, though, since any work it
|
||||
// gates will be queued on the JS thread behind the load.
|
||||
mAcceptCalls = true;
|
||||
// This is registered after JS starts since it makes a JS call
|
||||
Systrace.registerListener(mTraceListener);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user