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

Commit

Permalink
* [Android] edit interaction logic && edit exception report logic (#1835
Browse files Browse the repository at this point in the history
)

- determine if the element is on the screen (element edge)
- if component has "ignoreInteraction" attrs,componentTree will not calculate
- report pageName  (not url)
- every instance report one overlay exception at most
  • Loading branch information
lucky-chen authored and YorkShen committed Nov 28, 2018
1 parent 8d7e6de commit 5eb62df
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public void onDisappear() {
isAppear = false;
}

@Override
public String parseReportUrl(String originUrl) {
return originUrl;
}

private APMInfo getAndCheckAndSubProcedureMap(String procedureName) {
APMInfo info = mSubProcedureInfo.get(procedureName);
if (null != info) {
Expand Down
5 changes: 4 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 @@ -1359,9 +1359,12 @@ public void onRefreshSuccess(final int width, final int height) {

public void onChangeElement(WXComponent component, boolean isOutOfScreen) {

if (isDestroy() || null == mRenderContainer || mWXPerformance == null || "videoplus".equals(component.getComponentType())){
if (isDestroy() || null == mRenderContainer || mWXPerformance == null ){
return;
}
if (null == component || component.isIgnoreInteraction){
return;
}

if (mRenderContainer.hasConsumeEvent()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,15 @@ public Object callNativeComponent(String instanceId, String componentRef, String

try {
WXDomModule dom = WXModuleManager.getDomModule(instanceId);
dom.invokeMethod(componentRef, method, arguments);
if (null != dom){
dom.invokeMethod(componentRef, method, arguments);
}else {
WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId);
if(null == instance || !instance.isDestroy()){
WXLogUtils.e("WXBridgeManager","callNativeComponent exception :null == dom ,method:"+method);
}
}

} catch (Exception e) {
WXLogUtils.e("[WXBridgeManager] callNativeComponent exception: ", e);
WXExceptionUtils.commitCriticalExceptionRT(instanceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ public interface IWXApmMonitorAdapter {

void onDisappear();

String parseReportUrl(String originUrl);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import android.graphics.Rect;
import android.text.TextUtils;
import android.util.Log;
import com.taobao.weex.BuildConfig;
Expand Down Expand Up @@ -116,6 +117,10 @@ public class WXInstanceApm {
private boolean mEnd = false;
private boolean hasRecordFistInteractionView =false;
public final Map<String,Object> extInfo;
public boolean forceStopRecordInteraction = false;
public Rect instanceRect;
public String reportPageName;
public boolean hasReportLayerOverDraw = false;

public WXInstanceApm(String instanceId) {
mInstanceId = instanceId;
Expand Down Expand Up @@ -223,8 +228,9 @@ public void setPageName(String pageName) {
pageName = instance.getContainerInfo().get(KEY_PAGE_PROPERTIES_CONTAINER_NAME);
}
}
String fixPageName = TextUtils.isEmpty(pageName) ? "emptyPageName" : pageName;
addProperty(KEY_PAGE_PROPERTIES_BIZ_ID, fixPageName);
reportPageName = null == apmInstance?pageName:apmInstance.parseReportUrl(pageName);
reportPageName = TextUtils.isEmpty(reportPageName) ? "emptyPageName" : reportPageName;
addProperty(KEY_PAGE_PROPERTIES_BIZ_ID, reportPageName);
}

public void onAppear(){
Expand Down Expand Up @@ -269,7 +275,7 @@ public void arriveFSRenderTime() {
}

public void arriveInteraction(WXComponent targetComponent) {
if (null == apmInstance || null == targetComponent || targetComponent.getInstance() == null ) {
if (null == apmInstance || null == targetComponent || targetComponent.getInstance() == null) {
return;
}
WXPerformance performanceRecord = targetComponent.getInstance().getWXPerformance();
Expand All @@ -281,6 +287,9 @@ public void arriveInteraction(WXComponent targetComponent) {
onStage(KEY_PAGE_STAGES_FIRST_INTERACTION_VIEW);
hasRecordFistInteractionView = true;
}
if (forceStopRecordInteraction){
return;
}

long curTime = WXUtils.getFixUnixTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public GraphicActionAddElement(@NonNull WXSDKInstance instance, String ref,
mParentRef);
child = createComponent(instance, parent, basicComponentData);
child.setTransition(WXTransition.fromMap(child.getStyles(), child));
if (null != parent && parent.isIgnoreInteraction){
child.isIgnoreInteraction = true;
}
if (null!= child && null != child.getAttrs() && "1".equals(child.getAttrs().get("ignoreInteraction"))){
child.isIgnoreInteraction = true;
}

} catch (ClassCastException e) {
Map<String, String> ext = new ArrayMap<>();
WXComponent parent = WXSDKManager.getInstance().getWXRenderManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent imple
public static final int TYPE_VIRTUAL = 1;

private boolean waste = false;
public boolean isIgnoreInteraction = false;

private ContentBoxMeasurement contentBoxMeasurement;
private WXTransition mTransition;
Expand Down Expand Up @@ -987,8 +988,20 @@ public void setLayout(WXComponent component) {
mAbsoluteY = (int) (nullParent ? 0 : mParent.getAbsoluteY() + getCSSLayoutTop());
mAbsoluteX = (int) (nullParent ? 0 : mParent.getAbsoluteX() + getCSSLayoutLeft());

if (mIsAddElementToTree)
mInstance.onChangeElement(this, mAbsoluteY > mInstance.getWeexHeight() + 1);
if (mIsAddElementToTree){
if (null == getInstance().getApmForInstance().instanceRect){
getInstance().getApmForInstance().instanceRect = new Rect();
}
Rect instanceRect = getInstance().getApmForInstance().instanceRect;
instanceRect.set(0,0,mInstance.getWeexWidth(),mInstance.getWeexHeight());
boolean inScreen =
instanceRect.contains(mAbsoluteX,mAbsoluteY) //leftTop
|| instanceRect.contains(mAbsoluteX+realWidth,mAbsoluteY)//rightTop
|| instanceRect.contains(mAbsoluteX,mAbsoluteY+realHeight)//leftBottom
|| instanceRect.contains(mAbsoluteX+realWidth,mAbsoluteY+realHeight);//rightBottom
mInstance.onChangeElement(this,!inScreen);
}


if (mHost == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ protected void dispatchDraw(Canvas canvas) {
} catch (Throwable e) {
if (getComponent() != null) {
notifyLayerOverFlow();
reportLayerOverFlowError();
if (null != getComponent()){
WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(getComponent().getInstanceId());
if (null != instance && null != instance.getApmForInstance() &&!instance.getApmForInstance().hasReportLayerOverDraw){
instance.getApmForInstance().hasReportLayerOverDraw = true;
reportLayerOverFlowError();
}
}
}
WXLogUtils.e("Layer overflow limit error", WXLogUtils.getStackTrace(e));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void commitCriticalExceptionWithDefaultUrl(
instance = WXSDKManager.getInstance().getAllInstanceMap().get(instanceId);

if (null != instance) {
bundleUrlCommit = instance.getBundleUrl();
bundleUrlCommit = instance.getApmForInstance().reportPageName;
commitMap.put("templateInfo",instance.getTemplateInfo());
if (TextUtils.isEmpty(bundleUrlCommit) || bundleUrlCommit.equals(WXPerformance.DEFAULT)) {
if (!TextUtils.equals(degradeUrl, "BundleUrlDefaultDegradeUrl")) {
Expand Down

0 comments on commit 5eb62df

Please sign in to comment.