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

Commit c72e6b5

Browse files
lucky-chenDarin726
authored andcommitted
[Android] Android] restart weexCoreThread when reload JSEngine because thread maybe in lock state and can't execute reload action (block) (#2824)
1 parent ff2c079 commit c72e6b5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,14 @@ public int callRefreshFinish(String instanceId, String callback) {
867867

868868
}
869869

870+
public void restartWeexCoreThread(){
871+
WXLogUtils.e("weex","restartWeexCoreThread");
872+
WXThread oldThread = mJSThread;
873+
mJSThread = new WXThread("WeexJSBridgeThread", this);
874+
mJSHandler = mJSThread.getHandler();
875+
oldThread.quit();
876+
}
877+
870878
public int callReportCrashReloadPage(String instanceId, String crashFile) {
871879
boolean isCrashFileEmpty = TextUtils.isEmpty(crashFile);
872880
try {
@@ -914,6 +922,17 @@ public int callReportCrashReloadPage(String instanceId, String crashFile) {
914922
if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) {
915923
boolean reloadThisInstance = shouldReloadCurrentInstance(
916924
WXSDKManager.getInstance().getSDKInstance(instanceId).getBundleUrl());
925+
boolean restartCoreThread = true;
926+
IWXConfigAdapter adapter = WXSDKManager.getInstance().getWxConfigAdapter();
927+
if (null != adapter){
928+
String config = adapter.getConfig("wxapm","restartCoreThread","true");
929+
restartCoreThread = Boolean.valueOf(config);
930+
}
931+
if (restartCoreThread){
932+
WXBridgeManager.getInstance().restartWeexCoreThread();
933+
}
934+
WXSDKManager.getInstance().getSDKInstance(instanceId).getContainerInfo()
935+
.put("restartWeexCoreThread",String.valueOf(restartCoreThread));
917936
new ActionReloadPage(instanceId, reloadThisInstance).executeAction();
918937
}
919938

0 commit comments

Comments
 (0)