This is an automated email from the ASF dual-hosted git repository. luckychen pushed a commit to branch feature/master_ab_new in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
commit abbe788de85171d1a9a7186cda4a0863ed804214 Author: chen <qh438406...@gmail.com> AuthorDate: Mon Sep 16 16:16:56 2019 +0800 [Android] add mode check --- .../main/java/com/taobao/weex/WXEnvironment.java | 2 ++ .../main/java/com/taobao/weex/WXSDKInstance.java | 3 +++ .../com/taobao/weex/adapter/IWXConfigAdapter.java | 1 + .../com/taobao/weex/bridge/WXBridgeManager.java | 23 ++++++++++++++++++---- .../com/taobao/weex/performance/WXStateRecord.java | 8 ++++---- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java index 9d3250d..0df6105 100644 --- a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java +++ b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java @@ -114,6 +114,8 @@ public class WXEnvironment { public static long sJSFMStartListenerTime=0; + public static volatile boolean isWsFixMode = true; + /** * component and modules ready * */ diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java index 4d55d45..d16585f 100644 --- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java +++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java @@ -1718,6 +1718,9 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan } public void onRenderError(final String errCode, final String msg) { + if (WXEnvironment.isWsFixMode){ + hasException = true; + } WXStateRecord.getInstance().recordException(getInstanceId(),"onRenderError,"+errCode+","+msg); if (mRenderListener != null && mContext != null) { WXLogUtils.e("onRenderError "+errCode +","+msg); diff --git a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXConfigAdapter.java b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXConfigAdapter.java index 84de459..953bf2c 100644 --- a/android/sdk/src/main/java/com/taobao/weex/adapter/IWXConfigAdapter.java +++ b/android/sdk/src/main/java/com/taobao/weex/adapter/IWXConfigAdapter.java @@ -25,4 +25,5 @@ package com.taobao.weex.adapter; public interface IWXConfigAdapter { String getConfig(String nameSpace,String key,String defaultValue); String getConfigWhenInit(String nameSpace,String key,String defaultValue); + boolean checkMode(String name); } diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java index 8c31da1..bd1e968 100755 --- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java +++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java @@ -890,10 +890,10 @@ public class WXBridgeManager implements Callback, BactchExecutor { } catch (Throwable e) { WXLogUtils.e(WXLogUtils.getStackTrace(e)); } - WXStateRecord.getInstance().onJSCCrash(); + WXStateRecord.getInstance().onJSCCrash(TextUtils.isEmpty(instanceId)?"null":instanceId); callReportCrash(crashFile, instanceId, url,extInfo); } else { - WXStateRecord.getInstance().onJSEngineReload(); + WXStateRecord.getInstance().onJSEngineReload(TextUtils.isEmpty(instanceId)?"null":instanceId); commitJscCrashAlarmMonitor(IWXUserTrackAdapter.JS_BRIDGE, WXErrorCode.WX_ERR_RELOAD_PAGE, "reboot jsc Engine", instanceId, url,extInfo); } @@ -1046,8 +1046,18 @@ public class WXBridgeManager implements Callback, BactchExecutor { post(new Runnable() { @Override public void run() { + WXSDKInstance instance = WXSDKManager.getInstance().getAllInstanceMap().get(instanceId); + if (null != instance && !isSkipFrameworkInit(instance) && !isJSFrameworkInit()) { + String err = "[WXBridgeManager] invokeCreateInstance: framework.js uninitialized."; + instance.onRenderError( + WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorCode(), + WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorMsg() + ); + WXLogUtils.e(err); + instance.getApmForInstance().onStage("framework.js uninitialized and return"); + return; + } invokeExecJSOnInstance(instanceId, js, -1); - WXSDKInstance instance = WXSDKManager.getInstance().getAllInstanceMap().get(instanceId); if (null != instance && instance.isPreInitMode()){ instance.getApmForInstance().onStage(WXInstanceApm.KEY_PAGE_STAGES_LOAD_BUNDLE_END); instance.getApmForInstance().onStageWithTime(WXInstanceApm.KEY_PAGE_STAGES_END_EXCUTE_BUNDLE,WXUtils.getFixUnixTime()+600); @@ -2278,7 +2288,12 @@ public class WXBridgeManager implements Callback, BactchExecutor { IWXConfigAdapter adapter = WXSDKManager.getInstance().getWxConfigAdapter(); if (null != adapter){ try { - enableAlarmSignal = adapter.getConfigWhenInit("wxapm","enableAlarmSignal",enableAlarmSignal); + if (adapter.checkMode("white_screen_fix_open")){ + WXEnvironment.isWsFixMode = true; + }else { + enableAlarmSignal = adapter.getConfigWhenInit("wxapm","enableAlarmSignal",enableAlarmSignal); + WXEnvironment.isWsFixMode = "true".equalsIgnoreCase(enableAlarmSignal); + } }catch (Exception e){ e.printStackTrace(); } diff --git a/android/sdk/src/main/java/com/taobao/weex/performance/WXStateRecord.java b/android/sdk/src/main/java/com/taobao/weex/performance/WXStateRecord.java index a95e957..ee6390d 100644 --- a/android/sdk/src/main/java/com/taobao/weex/performance/WXStateRecord.java +++ b/android/sdk/src/main/java/com/taobao/weex/performance/WXStateRecord.java @@ -102,15 +102,15 @@ public class WXStateRecord { /** * check onJSEngineReload time,and we know how many times reload and each reload time */ - public void onJSEngineReload() { - recordCommon(mJscReloadHistory,new Info(WXUtils.getFixUnixTime(), "", "onJSEngineReload")); + public void onJSEngineReload(String instanceId) { + recordCommon(mJscReloadHistory,new Info(WXUtils.getFixUnixTime(), instanceId, "onJSEngineReload")); } /** * check jsc crash time,and we know how many times jscCrash and each crash time */ - public void onJSCCrash() { - recordCommon(mJscCrashHistory,new Info(WXUtils.getFixUnixTime(), "", "onJSCCrash")); + public void onJSCCrash(String instanceId) { + recordCommon(mJscCrashHistory,new Info(WXUtils.getFixUnixTime(), instanceId, "onJSCCrash")); } private void recordCommon(RecordList<Info> list ,Info info){