Repository: incubator-weex Updated Branches: refs/heads/master 939be31e6 -> dc1936ef0
[WEEX-465][Android]fix performance point interactionTime record bug Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/dc1936ef Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/dc1936ef Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/dc1936ef Branch: refs/heads/master Commit: dc1936ef0fbbb851d2a9c1c65623873ca7aa8ca2 Parents: 939be31 Author: zhongcang <qh438406...@gmail.com> Authored: Wed Jun 20 15:04:00 2018 +0800 Committer: zhongcang <qh438406...@gmail.com> Committed: Wed Jun 20 15:04:00 2018 +0800 ---------------------------------------------------------------------- .../java/com/taobao/weex/WXSDKInstance.java | 8 ++++--- .../weex/ui/action/GraphicActionAddElement.java | 4 +++- .../ui/action/GraphicActionMoveElement.java | 5 ----- .../ui/action/GraphicActionRemoveElement.java | 9 +++++++- .../taobao/weex/ui/component/WXComponent.java | 3 ++- .../taobao/weex/ui/module/WXTimerModule.java | 22 ++++++-------------- 6 files changed, 24 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dc1936ef/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java ---------------------------------------------------------------------- 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 9f59e30..99680f7 100644 --- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java +++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java @@ -106,6 +106,7 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan //Performance public boolean mEnd = false; + public boolean isJSCreateFinish =false; public static final String BUNDLE_URL = "bundleUrl"; private IWXUserTrackAdapter mUserTrackAdapter; private IWXRenderListener mRenderListener; @@ -1121,6 +1122,7 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan } public void onRenderSuccess(final int width, final int height) { + isJSCreateFinish = true; firstScreenRenderFinished(); long time = System.currentTimeMillis() - mRenderStartTime; @@ -1181,10 +1183,10 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan } /** - * when add/rm/mv element + * when add/rm element */ - public void onElementChange(){ - if (isDestroy() || !mEnd ||null == mRenderContainer || mRenderContainer.isPageHasEvent() || + public void onElementChange(boolean afterJSCreateFinish){ + if (isDestroy() || !afterJSCreateFinish ||null == mRenderContainer || mRenderContainer.isPageHasEvent() || mWXPerformance == null){ return; } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dc1936ef/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java index c73e704..5aa7b61 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java @@ -39,6 +39,7 @@ public class GraphicActionAddElement extends GraphicActionAbstractAddElement { private WXComponent child; private GraphicPosition layoutPosition; private GraphicSize layoutSize; + private boolean isJSCreateFinish = false; public GraphicActionAddElement(String pageId, String ref, String componentType, String parentRef, @@ -72,6 +73,7 @@ public class GraphicActionAddElement extends GraphicActionAbstractAddElement { mParentRef); child = createComponent(instance, parent, basicComponentData); child.setTransition(WXTransition.fromMap(child.getStyles(), child)); + isJSCreateFinish = instance.isJSCreateFinish; if (child == null || parent == null) { return; @@ -122,7 +124,7 @@ public class GraphicActionAddElement extends GraphicActionAbstractAddElement { child.bindData(child); WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId()); if (null!=instance){ - instance.onElementChange(); + instance.onElementChange(isJSCreateFinish); // instance.setma } } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dc1936ef/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java index 3cec87c..ac6474b 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java @@ -18,7 +18,6 @@ */ package com.taobao.weex.ui.action; -import com.taobao.weex.WXSDKInstance; import com.taobao.weex.WXSDKManager; import com.taobao.weex.ui.component.WXComponent; import com.taobao.weex.ui.component.WXVContainer; @@ -49,9 +48,5 @@ public class GraphicActionMoveElement extends BasicGraphicAction { if (!component.isVirtualComponent()) { ((WXVContainer) newParent).addSubView(component.getHostView(), mIndex); } - WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId()); - if (null!=instance){ - instance.onElementChange(); - } } } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dc1936ef/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java index 2b24eab..11ff2e0 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java @@ -25,8 +25,15 @@ import com.taobao.weex.ui.component.WXVContainer; public class GraphicActionRemoveElement extends BasicGraphicAction { + private boolean isJSCreateFinish = false; + public GraphicActionRemoveElement(String pageId, String ref) { super(pageId, ref); + WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId()); + if (null != instance){ + isJSCreateFinish = instance.isJSCreateFinish; + } + } @Override @@ -55,7 +62,7 @@ public class GraphicActionRemoveElement extends BasicGraphicAction { } WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId()); if (null!=instance){ - instance.onElementChange(); + instance.onElementChange(isJSCreateFinish); } } } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dc1936ef/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java index 072d8f4..3851c1b 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java @@ -85,6 +85,7 @@ import com.taobao.weex.ui.animation.WXAnimationBean; import com.taobao.weex.ui.animation.WXAnimationModule; import com.taobao.weex.ui.component.basic.WXBasicComponent; import com.taobao.weex.ui.component.binding.Statements; +import com.taobao.weex.ui.component.list.WXCell; import com.taobao.weex.ui.component.list.template.jni.NativeRenderObjectUtils; import com.taobao.weex.ui.component.pesudo.OnActivePseudoListner; import com.taobao.weex.ui.component.pesudo.PesudoStatus; @@ -929,7 +930,7 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent imple return; } - if (realHeight >= WXPerformance.VIEW_LIMIT_HEIGHT && realWidth>=WXPerformance.VIEW_LIMIT_WIDTH){ + if (this instanceof WXCell && realHeight >= WXPerformance.VIEW_LIMIT_HEIGHT && realWidth>=WXPerformance.VIEW_LIMIT_WIDTH){ mInstance.getWXPerformance().cellExceedNum++; } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dc1936ef/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java b/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java index de5a135..d2c711a 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java @@ -69,14 +69,9 @@ public class WXTimerModule extends WXModule implements Destroyable, Handler.Call public void setTimeout(@IntRange(from = 1) int funcId, @FloatRange(from = 0) float delay) { if(mWXSDKInstance != null) { postOrHoldMessage(MODULE_TIMEOUT, funcId, (int) delay, WXUtils.parseInt(mWXSDKInstance.getInstanceId())); - WXSDKManager.getInstance().postOnUiThread(new Runnable() { - @Override - public void run() { - if (null != mWXSDKInstance){ - mWXSDKInstance.getWXPerformance().timerInvokeCount++; - } - } - },0); + if (null != mWXSDKInstance.getWXPerformance()){ + mWXSDKInstance.getWXPerformance().timerInvokeCount++; + } } } @@ -84,14 +79,9 @@ public class WXTimerModule extends WXModule implements Destroyable, Handler.Call public void setInterval(@IntRange(from = 1) int funcId, @FloatRange(from = 0) float interval) { if(mWXSDKInstance != null) { postOrHoldMessage(MODULE_INTERVAL, funcId, (int) interval, WXUtils.parseInt(mWXSDKInstance.getInstanceId())); - WXSDKManager.getInstance().postOnUiThread(new Runnable() { - @Override - public void run() { - if (null != mWXSDKInstance){ - mWXSDKInstance.getWXPerformance().timerInvokeCount++; - } - } - },0); + if (null != mWXSDKInstance.getWXPerformance()){ + mWXSDKInstance.getWXPerformance().timerInvokeCount++; + } } }