Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[Android] Android] restart weexCoreThread when reload JSEngine becaus… #2824

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,14 @@ public int callRefreshFinish(String instanceId, String callback) {

}

public void restartWeexCoreThread(){
WXLogUtils.e("weex","restartWeexCoreThread");
WXThread oldThread = mJSThread;
mJSThread = new WXThread("WeexJSBridgeThread", this);
mJSHandler = mJSThread.getHandler();
oldThread.quit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

程序还在运行, 直接 quit 有风险吗? 有发过灰度吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. HanderThread quit是比较安全的,remove 消息队列里面的所有消息,然后thread没有消息,loop结束,线程自然回收
  2. 灰度同步进行

}

public int callReportCrashReloadPage(String instanceId, String crashFile) {
boolean isCrashFileEmpty = TextUtils.isEmpty(crashFile);
try {
Expand Down Expand Up @@ -914,6 +922,17 @@ public int callReportCrashReloadPage(String instanceId, String crashFile) {
if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) {
boolean reloadThisInstance = shouldReloadCurrentInstance(
WXSDKManager.getInstance().getSDKInstance(instanceId).getBundleUrl());
boolean restartCoreThread = true;
IWXConfigAdapter adapter = WXSDKManager.getInstance().getWxConfigAdapter();
if (null != adapter){
String config = adapter.getConfig("wxapm","restartCoreThread","true");
restartCoreThread = Boolean.valueOf(config);
}
if (restartCoreThread){
WXBridgeManager.getInstance().restartWeexCoreThread();
}
WXSDKManager.getInstance().getSDKInstance(instanceId).getContainerInfo()
.put("restartWeexCoreThread",String.valueOf(restartCoreThread));
new ActionReloadPage(instanceId, reloadThisInstance).executeAction();
}

Expand Down