React-Native-Remote-Update
React-Native-Remote-Update copied to clipboard
在0.17版本上,热更新报错
method.invoke(mReactInstanceManager,
new JSCJavaScriptExecutor(),
JSBundleLoader.createFileLoader(context, mainBundleFilePath));
在执行这一句时,抛出了一个IllegalAccessException异常,通过log可知是在ReactInstanceManagerImpl类中的下面这个方法中执行了UiThreadUtil.assertOnUiThread(); 该方法判断当前不在UI线程,于是抛出异常说“Expected to run on UI thread!”
private void recreateReactContextInBackgroundInner() {
UiThreadUtil.assertOnUiThread();
if (mUseDeveloperSupport && mJSMainModuleName != null) {
if (mDevSupportManager.hasUpToDateJSBundleInCache()) {
// If there is a up-to-date bundle downloaded from server, always use that
onJSBundleLoadedFromServer();
} else if (mJSBundleFile == null) {
mDevSupportManager.handleReloadJS();
} else {
mDevSupportManager.isPackagerRunning(
new DevServerHelper.PackagerStatusCallback() {
@Override
public void onPackagerStatusFetched(final boolean packagerIsRunning) {
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
public void run() {
if (packagerIsRunning) {
mDevSupportManager.handleReloadJS();
} else {
recreateReactContextInBackgroundFromBundleFile();
}
}
});
}
});
}
return;
}
recreateReactContextInBackgroundFromBundleFile();
}
那么。。。如果运行在UI线程里呢?