Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/master' into core-feature-bridge
Browse files Browse the repository at this point in the history
* apache/master:
  [WEEX-542][Android] rm useless code
  [WEEX-535][iOS] add extMsg when reproteror for windmill
  * [iOS] parser type by reg
  [WEEX-541][iOS]Vertical Pan may not trigger 'start' event on some devices.
  [WEEX-495][iOS] Fix class_replaceMethod param error in WXSwizzleInstanceMethod.
  [WEEX-539][Android] report container info when report error or performance
  * [Android] Fix transition createLayoutPropertyValueHolder
  * [android] Use rint on getFloatByViewport.
  * [android] Fix setViewport when debug
  # This is a combination of 2 commits. # This is the 1st commit message:
  [jsfm] add try catch for callback function and event handler (apache#1373)
  [WEEX-538][Android] do not shutdown websocket when debug
  * [Android] Add more log when callNative failed.
  * [Android] Add JS Error Log in GraphicActionAddElement
  • Loading branch information
神漠 committed Jul 27, 2018
2 parents a8b5051 + e46a720 commit af24aca
Show file tree
Hide file tree
Showing 22 changed files with 466 additions and 233 deletions.
1 change: 0 additions & 1 deletion android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public static void initialize(Application application,InitConfig config){
registerApplicationOptions(application);
WXEnvironment.sSDKInitInvokeTime = System.currentTimeMillis()-start;
WXLogUtils.renderPerformanceLog("SDKInitInvokeTime", WXEnvironment.sSDKInitInvokeTime);
WXPerformance.init();
mIsInit = true;
}
}
Expand Down
24 changes: 21 additions & 3 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package com.taobao.weex;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -134,6 +135,8 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
private @NonNull
FlatGUIContext mFlatGUIContext =new FlatGUIContext();

private Map<String,String> mContainerInfo;

/**
* bundle type
*/
Expand Down Expand Up @@ -385,15 +388,22 @@ public void removeOnInstanceVisibleListener(OnInstanceVisibleListener l){

public void init(Context context) {
mContext = context;
mContainerInfo = new HashMap<>(4);
mNativeInvokeHelper = new NativeInvokeHelper(mInstanceId);

mWXPerformance = new WXPerformance();
mWXPerformance = new WXPerformance(mInstanceId);
mWXPerformance.WXSDKVersion = WXEnvironment.WXSDK_VERSION;
mWXPerformance.JSLibInitTime = WXEnvironment.sJSLibInitTime;

mUserTrackAdapter=WXSDKManager.getInstance().getIWXUserTrackAdapter();

WXSDKManager.getInstance().getAllInstanceMap().put(mInstanceId,this);

mContainerInfo.put(Dimension.activity.toString(), context instanceof Activity
? context.getClass().getSimpleName()
:"unKnowContainer"
);
mContainerInfo.put(Dimension.instanceType.toString(),"page");
}

/**
Expand Down Expand Up @@ -447,6 +457,14 @@ public WXScrollView.WXScrollViewListener getScrollViewListener() {
public void setIWXUserTrackAdapter(IWXUserTrackAdapter adapter) {
}

public void setContainerInfo(String key,String val){
mContainerInfo.put(key,val);
}

public Map<String, String> getContainerInfo() {
return mContainerInfo;
}

/**
* Render template asynchronously, use {@link WXRenderStrategy#APPEND_ASYNC} as render strategy
* @param template bundle js
Expand Down Expand Up @@ -1163,7 +1181,7 @@ public void run() {
if (mRenderListener != null && mContext != null) {
mRenderListener.onRenderSuccess(WXSDKInstance.this, width, height);
if (mUserTrackAdapter != null) {
WXPerformance performance=new WXPerformance();
WXPerformance performance=new WXPerformance(mInstanceId);
performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode();
performance.args=getBundleUrl();
mUserTrackAdapter.commit(mContext,null,IWXUserTrackAdapter.JS_BRIDGE,performance,getUserTrackParams());
Expand Down Expand Up @@ -1837,7 +1855,7 @@ public void onHttpFinish(WXResponse response) {
mWXPerformance.zCacheInfo = zCacheInfo instanceof String?(String)zCacheInfo:"";

if(isNet(mWXPerformance.requestType) && mUserTrackAdapter!=null){
WXPerformance performance=new WXPerformance();
WXPerformance performance=new WXPerformance(mInstanceId);
if(!TextUtils.isEmpty(mBundleUrl)){
try {
performance.args= Uri.parse(mBundleUrl).buildUpon().clearQuery().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ private void initWXBridge(boolean remoteDebug) {
WXEnvironment.sDebugServerConnectable = true;
}

if (mWxDebugProxy != null) {
mWxDebugProxy.stop(false);
}
// if (mWxDebugProxy != null) {
// mWxDebugProxy.stop(false);
// }
if (WXEnvironment.sDebugServerConnectable && (WXEnvironment.isApkDebugable() || WXEnvironment.sForceEnableDevTool)) {
if (WXEnvironment.getApplication() != null) {
try {
Expand Down Expand Up @@ -341,7 +341,19 @@ public Object callModuleMethod(String instanceId, String moduleStr, String metho
return validateInfo;
}
}
return WXModuleManager.callModuleMethod(instanceId, moduleStr, methodStr, args);
try {
return WXModuleManager.callModuleMethod(instanceId, moduleStr, methodStr, args);
}catch(NumberFormatException e){
ArrayMap<String, String> ext = new ArrayMap<>();
ext.put("moduleName", moduleStr);
ext.put("methodName", methodStr);
ext.put("args", args.toJSONString());
WXLogUtils.e("[WXBridgeManager] callNative : numberFormatException when parsing string to numbers in args", ext.toString());
WXExceptionUtils.commitCriticalExceptionRT(instanceId,
WXErrorCode.WX_KEY_EXCEPTION_INVOKE, "callNative",
"[WXBridgeManager] callNative : numberFormatException when parsing string to numbers in args" , ext);
return null;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import android.support.annotation.RestrictTo;

import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.utils.WXViewUtils;

import java.util.HashMap;
Expand All @@ -42,6 +44,8 @@ public enum Dimension {
networkType,
connectionType,
zcacheInfo,
activity,
instanceType,
wxdim1,
wxdim2,
wxdim3,
Expand Down Expand Up @@ -363,11 +367,11 @@ public double getMaxRange() {
public int mActionAddElementCount = 0;
public int mActionAddElementSumTime = 0;

public WXPerformance(){
mErrMsgBuilder=new StringBuilder();
}
private String mInstanceId;

public static void init() {
public WXPerformance(String instanceId){
mErrMsgBuilder=new StringBuilder();
mInstanceId = instanceId;
}

public Map<String, Double> getMeasureMap() {
Expand Down Expand Up @@ -455,6 +459,12 @@ public Map<String, String> getDimensionMap() {
quotas.put(Dimension.cacheType.toString(), cacheType);
quotas.put(Dimension.useScroller.toString(), String.valueOf(useScroller));

WXSDKInstance sdkInstance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
String keyActivity = Dimension.activity.toString();
quotas.put(keyActivity, null == sdkInstance? "unKnow" : sdkInstance.getContainerInfo().get(keyActivity));
String keyType = Dimension.instanceType.toString();
quotas.put(keyType,sdkInstance == null ?"unKnow": sdkInstance.getContainerInfo().get(keyType));

// TODO These attribute will be moved to elsewhere
// Extra Dimension for 3rd developers.
quotas.put(Dimension.wxdim1.toString(), wxDims[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import android.support.annotation.NonNull;
import android.support.annotation.RestrictTo;
import android.support.annotation.RestrictTo.Scope;
import android.text.TextUtils;
import com.taobao.weex.dom.CSSShorthand.CSSProperty;
import java.util.Arrays;

Expand Down Expand Up @@ -109,4 +111,10 @@ private void setInternal(@NonNull Enum<? extends CSSProperty> edge, float value)
private float getInternal(@NonNull Enum<? extends CSSProperty> edge){
return (edge == EDGE.ALL || edge == CORNER.ALL) ? 0 : values[edge.ordinal()];
}

@Override
@RestrictTo(Scope.LIBRARY)
public String toString() {
return TextUtils.isEmpty(values.toString()) ? "" : Arrays.toString(values);
}
}
8 changes: 8 additions & 0 deletions android/sdk/src/main/java/com/taobao/weex/dom/WXAttr.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package com.taobao.weex.dom;

import android.support.annotation.RestrictTo;
import android.support.annotation.RestrictTo.Scope;
import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
Expand Down Expand Up @@ -581,4 +583,10 @@ public WXAttr clone() {
}
return wxAttr;
}

@RestrictTo(Scope.LIBRARY)
@Override
public String toString() {
return attr.toString();
}
}
7 changes: 7 additions & 0 deletions android/sdk/src/main/java/com/taobao/weex/dom/WXStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.annotation.RestrictTo.Scope;
import android.support.v4.util.ArrayMap;
import android.text.Layout;
import android.text.TextUtils;
Expand Down Expand Up @@ -545,4 +547,9 @@ public WXStyle clone(){
return style;
}

@Override
@RestrictTo(Scope.LIBRARY)
public String toString() {
return mStyles.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -472,22 +472,22 @@ private PropertyValuesHolder createLayoutPropertyValueHolder(String property, Ob
}
break;
case Constants.Name.LEFT:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.LEFT, mWXComponent.getPadding().get(CSSShorthand.EDGE.LEFT),
holder = PropertyValuesHolder.ofFloat(Constants.Name.LEFT, mWXComponent.getLayoutPosition().getLeft(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, mWXComponent.getViewPortWidth()), mWXComponent.getViewPortWidth()));
}
break;
case Constants.Name.RIGHT:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.RIGHT, mWXComponent.getPadding().get(CSSShorthand.EDGE.RIGHT),
holder = PropertyValuesHolder.ofFloat(Constants.Name.RIGHT, mWXComponent.getLayoutPosition().getRight(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, mWXComponent.getViewPortWidth()), mWXComponent.getViewPortWidth()));
}
break;
case Constants.Name.BOTTOM:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.BOTTOM, mWXComponent.getPadding().get(CSSShorthand.EDGE.BOTTOM),
holder = PropertyValuesHolder.ofFloat(Constants.Name.BOTTOM, mWXComponent.getLayoutPosition().getBottom(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, mWXComponent.getViewPortWidth()), mWXComponent.getViewPortWidth()));
}
break;
case Constants.Name.TOP:{
holder = PropertyValuesHolder.ofFloat(Constants.Name.TOP, mWXComponent.getPadding().get(CSSShorthand.EDGE.TOP),
holder = PropertyValuesHolder.ofFloat(Constants.Name.TOP, mWXComponent.getLayoutPosition().getTop(),
WXViewUtils.getRealPxByWidth(WXUtils.getFloatByViewport(value, mWXComponent.getViewPortWidth()), mWXComponent.getViewPortWidth()));
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import android.support.annotation.RestrictTo;
import android.support.annotation.RestrictTo.Scope;
import android.support.annotation.WorkerThread;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.common.WXErrorCode;
Expand All @@ -31,6 +31,7 @@
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.utils.WXExceptionUtils;
import com.taobao.weex.utils.WXLogUtils;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -79,14 +80,59 @@ public GraphicActionAddElement(String pageId, String ref,
return;
}
}catch (ClassCastException e){
Map<String, String> ext = new ArrayMap<>();
WXComponent parent = WXSDKManager.getInstance().getWXRenderManager()
.getWXComponent(getPageId(), mParentRef);

if (mStyle != null && !mStyle.isEmpty()) {
ext.put("child.style", mStyle.toString());
}
if (parent != null && parent.getStyles() != null && !parent.getStyles().isEmpty()) {
ext.put("parent.style", parent.getStyles().toString());
}

if (mAttributes != null && !mAttributes.isEmpty()) {
ext.put("child.attr", mAttributes.toString());
}
if (parent != null && parent.getAttrs() != null && !parent.getAttrs().isEmpty()) {
ext.put("parent.attr", parent.getAttrs().toString());
}

if (mEvents != null && !mEvents.isEmpty()) {
ext.put("child.event", mEvents.toString());
}
if (parent != null && parent.getEvents() != null && !parent.getEvents().isEmpty()) {
ext.put("parent.event", parent.getEvents().toString());
}

if (mMargins != null && mMargins.length > 0) {
ext.put("child.margin", Arrays.toString(mMargins));
}
if (parent != null && parent.getMargin() != null) {
ext.put("parent.margin", parent.getMargin().toString());
}

if (mPaddings != null && mPaddings.length > 0) {
ext.put("child.padding", Arrays.toString(mPaddings));
}
if (parent != null && parent.getPadding() != null) {
ext.put("parent.padding", parent.getPadding().toString());
}

if (mBorders != null && mBorders.length > 0) {
ext.put("child.border", Arrays.toString(mBorders));
}
if (parent != null && parent.getBorder() != null) {
ext.put("parent.border", parent.getBorder().toString());
}

WXExceptionUtils.commitCriticalExceptionRT(instance.getInstanceId(),
WXErrorCode.WX_RENDER_ERR_CONTAINER_TYPE,
"GraphicActionAddElement",
String.format(Locale.ENGLISH,"You are trying to add a %s (ref: %s) to a %3$s (ref: %4$s), which is illegal as %3$s (ref: %4$s) is not a container",
componentType, ref,
WXSDKManager.getInstance().getWXRenderManager().getWXComponent(getPageId(), mParentRef).getComponentType(),
parentRef),
null);
String.format(Locale.ENGLISH,"You are trying to add a %s to a %2$s, which is illegal as %2$s is not a container",
componentType,
WXSDKManager.getInstance().getWXRenderManager().getWXComponent(getPageId(), mParentRef).getComponentType()),
ext);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,9 @@ protected void createViewImpl() {
}
if (mHost != null) {
mHost.setId(WXViewUtils.generateViewId());
if(TextUtils.isEmpty(mHost.getContentDescription()) && WXEnvironment.isApkDebugable()){
mHost.setContentDescription(getRef());
}
ComponentObserver observer;
if ((observer = getInstance().getComponentObserver()) != null) {
observer.onViewCreated(this, mHost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.taobao.weex.common.Constants;
import com.taobao.weex.common.WXErrorCode;
import com.taobao.weex.common.WXPerformance;
import com.taobao.weex.common.WXPerformance.Dimension;
import com.taobao.weex.common.WXRenderStrategy;
import com.taobao.weex.ui.action.BasicComponentData;
import com.taobao.weex.utils.WXLogUtils;
Expand Down Expand Up @@ -288,6 +289,8 @@ public void setPriority(String priority) {
*/
protected void loadContent(){
mNestedInstance = createInstance();
mNestedInstance.setContainerInfo(Dimension.instanceType.toString(),"embed");
mNestedInstance.setContainerInfo("parentPage",getInstance().getBundleUrl());
if(mListener != null && mListener.mEventListener != null){
if(!mListener.mEventListener.onPreCreate(this,src)){
//cancel render
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ public static void commitCriticalExceptionRT(@Nullable final String instanceId,
instanceIdCommit = instanceId;
instance = WXSDKManager.getInstance().getAllInstanceMap().get(instanceId);

if (null != instance && instance.getContainerView() != null){
Context c = instance.getContainerView().getContext();
if (c instanceof Activity){
commitMap.put("activity",c.getClass().getSimpleName());
}
}

if (null != instance) {
bundleUrlCommit = instance.getBundleUrl();
commitMap.put("templateInfo",instance.getTemplateInfo());
Expand All @@ -93,6 +86,9 @@ public static void commitCriticalExceptionRT(@Nullable final String instanceId,
} else
bundleUrlCommit = WXSDKInstance.requestUrl;
}
for (Map.Entry<String,String> entry: instance.getContainerInfo().entrySet()){
commitMap.put(entry.getKey(),entry.getValue());
}
}
} else {//instance is null for instance id is null
if (!TextUtils.isEmpty(WXSDKInstance.requestUrl)) {
Expand Down
Loading

0 comments on commit af24aca

Please sign in to comment.