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

Commit

Permalink
[WEEX-623][Android] pageName check and revert interaction time top10 …
Browse files Browse the repository at this point in the history
…logic (#1543)

* before render time ,check pagename ,if isempty ,try set activityname
* revert interaction countdown top10 logic
* report white screen error if createInstance error
  • Loading branch information
lucky-chen authored and YorkShen committed Sep 20, 2018
1 parent 6879915 commit 4567898
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 40 deletions.
3 changes: 2 additions & 1 deletion android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ private void renderByUrlInternal(String pageName,
}

mApmForInstance.doInit();
mApmForInstance.setPageName(pageName);

Uri uri = Uri.parse(url);
if (uri != null && TextUtils.equals(uri.getScheme(), "file")) {
Expand Down Expand Up @@ -735,6 +736,7 @@ private void renderByUrlInternal(String pageName,
WXHttpListener httpListener =
new WXHttpListener(pageName, renderOptions, jsonInitData, flag, System.currentTimeMillis());
httpListener.setSDKInstance(this);
mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START);
adapter.sendRequest(wxRequest, (IWXHttpAdapter.OnHttpListener) httpListener);
}

Expand Down Expand Up @@ -1876,7 +1878,6 @@ public void onHttpStart() {
&& this.instance.getWXStatisticsListener() != null) {
this.instance.getWXStatisticsListener().onHttpStart();
}
mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2097,6 +2097,7 @@ public void reportJSException(String instanceId, String function,
+ ", exception function:" + function + ", exception:"
+ exception);
WXSDKInstance instance = null;
WXErrorCode reportErrorCode = WXErrorCode.WX_ERR_JS_EXECUTE;
if (instanceId != null && (instance = WXSDKManager.getInstance().getSDKInstance(instanceId)) != null) {
exception += "\n getTemplateInfo==" +instance.getTemplateInfo();//add network header info
if (METHOD_CREATE_INSTANCE.equals(function) || !instance.isContentMd5Match()) {
Expand Down Expand Up @@ -2127,12 +2128,17 @@ public void reportJSException(String instanceId, String function,
e.printStackTrace();
}
}
instance.onJSException(WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception);
if (METHOD_CREATE_INSTANCE.equals(function) && !instance.getExceptionRecorder().hasAddView.get()){
reportErrorCode = WXErrorCode.WX_RENDER_ERR_JS_CREATE_INSTANCE;
}else if ( METHOD_CREATE_INSTANCE_CONTEXT.equals(function) && !instance.getExceptionRecorder().hasAddView.get()){
reportErrorCode = WXErrorCode.WX_RENDER_ERR_JS_CREATE_INSTANCE_CONTEXT;
}
instance.onJSException(reportErrorCode.getErrorCode(), function, exception);
}
doReportJSException(instanceId,function,exception);
doReportJSException(instanceId,function,reportErrorCode,exception);
}

private void doReportJSException(String instanceId, String function, String exception){
private void doReportJSException(String instanceId, String function,WXErrorCode reportCode, String exception){
WXSDKInstance instance = WXSDKManager.getInstance().getAllInstanceMap().get(instanceId);
IWXJSExceptionAdapter adapter = WXSDKManager.getInstance().getIWXJSExceptionAdapter();
if (adapter != null) {
Expand Down Expand Up @@ -2182,18 +2188,9 @@ private void doReportJSException(String instanceId, String function, String exce
}


WXErrorCode errorCode;
if (METHOD_CREATE_INSTANCE.equals(function)){
errorCode = WXErrorCode.WX_RENDER_ERR_JS_CREATE_INSTANCE;
}else if ( METHOD_CREATE_INSTANCE_CONTEXT.equals(function)){
errorCode = WXErrorCode.WX_RENDER_ERR_JS_CREATE_INSTANCE_CONTEXT;
}else {
errorCode = WXErrorCode.WX_KEY_EXCEPTION_WXBRIDGE;
}

WXExceptionUtils.commitCriticalExceptionRT(exceptionId, errorCode,
WXExceptionUtils.commitCriticalExceptionRT(exceptionId, reportCode,
function,
errorCode.getErrorMsg() + exception,
reportCode.getErrorMsg() + exception,
null);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package com.taobao.weex.performance;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -116,12 +114,10 @@ public class WXInstanceApm {
private boolean mEnd = false;
private boolean hasRecordFistInteractionView =false;
public final Map<String,Object> extInfo;
private List<WXComponent> mCountDownInteractionComponentList;

public WXInstanceApm(String instanceId) {
mInstanceId = instanceId;
extInfo = new ConcurrentHashMap<>();
mCountDownInteractionComponentList = new ArrayList<>(10);
IApmGenerator generator = WXSDKManager.getInstance().getApmGenerater();
if (null != generator) {
apmInstance = generator.generateApmInstance(WEEX_PAGE_TOPIC);
Expand Down Expand Up @@ -262,46 +258,35 @@ public void arriveFSRenderTime() {
if (null == apmInstance){
return;
}
isFSEnd = true;
onStage(WXInstanceApm.KEY_PAGE_STAGES_FSRENDER);
}

public void arriveInteraction(WXComponent targetComponent) {
if (null == apmInstance || null == targetComponent || targetComponent.getInstance() == null ) {
return;
}
targetComponent.interactionTime = WXUtils.getFixUnixTime();
WXPerformance performanceRecord = targetComponent.getInstance().getWXPerformance();
if (null == performanceRecord){
return;
}

if (BuildConfig.DEBUG){
Log.d("wxapm", "screenComponent ["+targetComponent.getComponentType()+","+targetComponent.getRef()
+"], renderTime:"+ (targetComponent.interactionTime -performanceRecord.renderTimeOrigin)
+",style:"+targetComponent.getStyles()
+",attrs:"+targetComponent.getAttrs());
}

if (!hasRecordFistInteractionView){
onStage(KEY_PAGE_STAGES_FIRST_INTERACTION_VIEW);
hasRecordFistInteractionView = true;
}
if (mCountDownInteractionComponentList.size() <10){
mCountDownInteractionComponentList.add(targetComponent);
return;
}
mCountDownInteractionComponentList.add(targetComponent);
WXComponent preComponent = mCountDownInteractionComponentList.remove(0);
if (null == preComponent){
return;
}

long curTIme = WXUtils.getFixUnixTime();

if (BuildConfig.DEBUG){
Log.d("wxapm", "interaction record component ["+preComponent.getComponentType()+","+preComponent.getRef());
Log.d("wxapm", "screenComponent ["+targetComponent.getComponentType()+","+targetComponent.getRef()
+"], renderTime:"+ (curTIme -performanceRecord.renderTimeOrigin)
+",style:"+targetComponent.getStyles()
+",attrs:"+targetComponent.getAttrs());
}

performanceRecord.interactionTime = preComponent.interactionTime - performanceRecord.renderTimeOrigin;
onStageWithTime(KEY_PAGE_STAGES_INTERACTION,preComponent.interactionTime);
performanceRecord.interactionTime = curTIme - performanceRecord.renderTimeOrigin;
onStageWithTime(KEY_PAGE_STAGES_INTERACTION,curTIme);

updateDiffStats(KEY_PAGE_STATS_I_SCREEN_VIEW_COUNT, 1);
updateMaxStats(KEY_PAGE_STATS_I_ALL_VIEW_COUNT, performanceRecord.localInteractionViewAddCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent imple
private String mLastBoxShadowId;
public int mDeepInComponentTree = 0;
public boolean mIsAddElementToTree = false;
public long interactionTime;

public WXTracing.TraceInfo mTraceInfo = new WXTracing.TraceInfo();

Expand Down

0 comments on commit 4567898

Please sign in to comment.