You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by lu...@apache.org on 2019/07/10 08:05:09 UTC

[incubator-weex] branch master updated: Add render time origin fix. Fix issue that interaction time calculated by heron is much different with platform. (#2666)

This is an automated email from the ASF dual-hosted git repository.

luckychen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git


The following commit(s) were added to refs/heads/master by this push:
     new 354c15d  Add render time origin fix. Fix issue that interaction time calculated by heron is much different with platform. (#2666)
354c15d is described below

commit 354c15de6f7d28e59cf369bd3c7df9f9ea209d08
Author: wqyfavor <qi...@alibaba-inc.com>
AuthorDate: Wed Jul 10 16:05:05 2019 +0800

    Add render time origin fix. Fix issue that interaction time calculated by heron is much different with platform. (#2666)
---
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m          | 14 ++++++++++----
 ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h |  2 +-
 ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m |  9 ++++++---
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index b01c263..cb46690 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -396,9 +396,12 @@ typedef enum : NSUInteger {
     }
 
     self.performance.renderTimeOrigin = CACurrentMediaTime()*1000;
-    [WXCoreBridge setPageArgument:_instanceId key:@"renderTimeOrigin" value:[NSString stringWithFormat:@"%lld", (long long)([[NSDate date] timeIntervalSince1970] * 1000)]];
     self.performance.renderUnixTimeOrigin = [WXUtility getUnixFixTimeMillis];
-    [self.apmInstance onStage:KEY_PAGE_STAGES_RENDER_ORGIGIN];
+    long renderOriginTimePlatform = [self.apmInstance onStage:KEY_PAGE_STAGES_RENDER_ORGIGIN];
+    
+    // pass render origin time to page
+    [WXCoreBridge setPageArgument:_instanceId key:@"renderTimeOrigin" value:[NSString stringWithFormat:@"%lld", (long long)([[NSDate date] timeIntervalSince1970] * 1000)]];
+    [WXCoreBridge setPageArgument:_instanceId key:@"renderTimeOriginPlatform" value:[NSString stringWithFormat:@"%lld", (long long)renderOriginTimePlatform]];
 
     if (![WXUtility isBlankString:self.pageName]) {
         WXLog(@"Start rendering page:%@", self.pageName);
@@ -479,9 +482,12 @@ typedef enum : NSUInteger {
     }
     
     self.performance.renderTimeOrigin = CACurrentMediaTime()*1000;
-    [WXCoreBridge setPageArgument:_instanceId key:@"renderTimeOrigin" value:[NSString stringWithFormat:@"%lld", (long long)([[NSDate date] timeIntervalSince1970] * 1000)]];
     self.performance.renderUnixTimeOrigin = [WXUtility getUnixFixTimeMillis];
-    [self.apmInstance onStage:KEY_PAGE_STAGES_RENDER_ORGIGIN];
+    long renderOriginTimePlatform = [self.apmInstance onStage:KEY_PAGE_STAGES_RENDER_ORGIGIN];
+    
+    // pass render origin time to page
+    [WXCoreBridge setPageArgument:_instanceId key:@"renderTimeOrigin" value:[NSString stringWithFormat:@"%lld", (long long)([[NSDate date] timeIntervalSince1970] * 1000)]];
+    [WXCoreBridge setPageArgument:_instanceId key:@"renderTimeOriginPlatform" value:[NSString stringWithFormat:@"%lld", (long long)renderOriginTimePlatform]];
     
     if (![WXUtility isBlankString:self.pageName]) {
         WXLog(@"Start rendering page:%@", self.pageName);
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
index 1e254dd..d6f3d45 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
@@ -119,7 +119,7 @@ extern NSString* const VALUE_ERROR_CODE_DEFAULT;
 #pragma mark - basic method
 
 - (void) onEvent:(NSString *)name withValue:(id)value;
-- (void) onStage:(NSString *)name;
+- (long) onStage:(NSString *)name;
 - (void) onStageWithTime:(NSString*)name time:(long)unixTime;
 - (void) setProperty:(NSString *)name withValue:(id)value;
 - (void) setStatistic:(NSString *)name withValue:(double)value;
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
index 85946c7..2e3d1a9 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
@@ -160,12 +160,15 @@ NSString* const VALUE_ERROR_CODE_DEFAULT = @"0";
     [self.apmProtocolInstance onEvent:name withValue:value];
 }
 
-- (void) onStage:(NSString *)name
+- (long) onStage:(NSString *)name
 {
     if(_isEnd){
-        return;
+        return 0;
     }
-    [self onStageWithTime:name time:[WXUtility getUnixFixTimeMillis]];
+    
+    long result = [WXUtility getUnixFixTimeMillis];
+    [self onStageWithTime:name time:result];
+    return result;
 }
 
 - (void) onStageWithTime:(NSString*)name time:(long)unixTime