You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/01/03 12:39:37 UTC

[GitHub] zshshr closed pull request #2000: * [Android] feature :send performane info to js delay 8s

zshshr closed pull request #2000: * [Android] feature :send performane info to js delay 8s
URL: https://github.com/apache/incubator-weex/pull/2000
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/android/sdk/src/main/java/com/taobao/weex/performance/WXInstanceApm.java b/android/sdk/src/main/java/com/taobao/weex/performance/WXInstanceApm.java
index 777374fa61..c1d8330c7c 100644
--- a/android/sdk/src/main/java/com/taobao/weex/performance/WXInstanceApm.java
+++ b/android/sdk/src/main/java/com/taobao/weex/performance/WXInstanceApm.java
@@ -22,11 +22,14 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import android.graphics.Rect;
+import android.os.Handler;
+import android.os.Looper;
 import android.text.TextUtils;
 import android.util.Log;
 import com.taobao.weex.WXEnvironment;
 import com.taobao.weex.WXSDKInstance;
 import com.taobao.weex.WXSDKManager;
+import com.taobao.weex.bridge.WXBridgeManager;
 import com.taobao.weex.common.WXErrorCode;
 import com.taobao.weex.common.WXPerformance;
 import com.taobao.weex.common.WXRenderStrategy;
@@ -127,12 +130,14 @@
     public String reportPageName;
     public boolean hasReportLayerOverDraw = false;
     public boolean hasAddView;
+    private Handler mUIHandler;
 
     public WXInstanceApm(String instanceId) {
         mInstanceId = instanceId;
         extInfo = new ConcurrentHashMap<>();
         stageMap = new ConcurrentHashMap<>();
         IApmGenerator generator = WXSDKManager.getInstance().getApmGenerater();
+        mUIHandler = new Handler(Looper.getMainLooper());
         if (null != generator) {
             apmInstance = generator.generateApmInstance(WEEX_PAGE_TOPIC);
             recordStatsMap = new ConcurrentHashMap<>();
@@ -171,6 +176,10 @@ public void onStageWithTime(String name,long time){
             WXAnalyzerDataTransfer.transferPerformance(mInstanceId,"stage",name,time);
         }
 
+        if (KEY_PAGE_STAGES_RENDER_ORGIGIN.equalsIgnoreCase(name)){
+          mUIHandler.postDelayed(jsPerformanceCallBack,8000);
+        }
+
         if (null == apmInstance) {
             return;
         }
@@ -178,6 +187,12 @@ public void onStageWithTime(String name,long time){
         apmInstance.onStage(name, time);
     }
 
+    private Runnable jsPerformanceCallBack = new Runnable() {
+        @Override
+        public void run() {
+            sendPerformanceToJS();
+        }
+    };
 
     /**
      * record property
@@ -281,6 +296,7 @@ public void onEnd() {
         if (null == apmInstance || mEnd) {
             return;
         }
+        mUIHandler.removeCallbacks(jsPerformanceCallBack);
         onStage(KEY_PAGE_STAGES_DESTROY);
         apmInstance.onEnd();
         mEnd = true;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services