You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by GitBox <gi...@apache.org> on 2018/09/06 15:29:36 UTC

[GitHub] cxfeng1 closed pull request #1500: [WEEX-607][iOS] [weex monitor improvement

cxfeng1 closed pull request #1500: [WEEX-607][iOS] [weex monitor improvement
URL: https://github.com/apache/incubator-weex/pull/1500
 
 
   

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/ios/sdk/WeexSDK.xcodeproj/project.pbxproj b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
index 8a8ed3ba29..5f0e1ccb42 100644
--- a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
+++ b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
@@ -10,8 +10,6 @@
 		042013AD1E66CD6A001FC79C /* WXValidateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 042013AC1E66CD6A001FC79C /* WXValidateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		17036A4E20FDE72F0029AE3D /* WXApmForInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = 17036A4C20FDE72F0029AE3D /* WXApmForInstance.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		17036A4F20FDE72F0029AE3D /* WXApmForInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = 17036A4C20FDE72F0029AE3D /* WXApmForInstance.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		17036A5020FDE72F0029AE3D /* WXInstanceApm.m in Sources */ = {isa = PBXBuildFile; fileRef = 17036A4D20FDE72F0029AE3D /* WXInstanceApm.m */; };
-		17036A5120FDE72F0029AE3D /* WXInstanceApm.m in Sources */ = {isa = PBXBuildFile; fileRef = 17036A4D20FDE72F0029AE3D /* WXInstanceApm.m */; };
 		17036A5320FDE7490029AE3D /* WXApmProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 17036A5220FDE7490029AE3D /* WXApmProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		17036A5420FDE7490029AE3D /* WXApmProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 17036A5220FDE7490029AE3D /* WXApmProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		170B4664208733AF00562666 /* WXAnalyzerCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 17C74F092072145000AB4CAB /* WXAnalyzerCenter.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -23,6 +21,8 @@
 		176BE43C209172330086B6AF /* WXComponent+Layout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 176BE43B209172330086B6AF /* WXComponent+Layout.mm */; };
 		176BE43D209172A30086B6AF /* WXScrollerComponent+Layout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 17C7B4FF20452E1800A2296A /* WXScrollerComponent+Layout.mm */; };
 		176BE43E209172E20086B6AF /* WXScrollerComponent+Layout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 17C7B4FF20452E1800A2296A /* WXScrollerComponent+Layout.mm */; };
+		1771795521412A5D006F39A9 /* WXApmForInstance.m in Sources */ = {isa = PBXBuildFile; fileRef = 1771795421412A5D006F39A9 /* WXApmForInstance.m */; };
+		1771795621412A5D006F39A9 /* WXApmForInstance.m in Sources */ = {isa = PBXBuildFile; fileRef = 1771795421412A5D006F39A9 /* WXApmForInstance.m */; };
 		178EDF0D204FEC1300917F6B /* WXScrollerComponent+Layout.h in Headers */ = {isa = PBXBuildFile; fileRef = 17C7B50020452E1800A2296A /* WXScrollerComponent+Layout.h */; };
 		178EDF0F204FF11700917F6B /* WXCoreLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 17C7B50420452E1800A2296A /* WXCoreLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		17B122212090AA9300387E33 /* WXSDKInstance_performance.m in Sources */ = {isa = PBXBuildFile; fileRef = 17B1221F2090AA9300387E33 /* WXSDKInstance_performance.m */; };
@@ -652,11 +652,11 @@
 
 /* Begin PBXFileReference section */
 		042013AC1E66CD6A001FC79C /* WXValidateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXValidateProtocol.h; sourceTree = "<group>"; };
-		1746EA7220E9D253007E55BD /* WXComponent_performance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXComponent_performance.h; sourceTree = "<group>"; };
 		17036A4C20FDE72F0029AE3D /* WXApmForInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXApmForInstance.h; sourceTree = "<group>"; };
-		17036A4D20FDE72F0029AE3D /* WXInstanceApm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXInstanceApm.m; sourceTree = "<group>"; };
 		17036A5220FDE7490029AE3D /* WXApmProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXApmProtocol.h; sourceTree = "<group>"; };
+		1746EA7220E9D253007E55BD /* WXComponent_performance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXComponent_performance.h; sourceTree = "<group>"; };
 		176BE43B209172330086B6AF /* WXComponent+Layout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "WXComponent+Layout.mm"; path = "Layout/WXComponent+Layout.mm"; sourceTree = "<group>"; };
+		1771795421412A5D006F39A9 /* WXApmForInstance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXApmForInstance.m; sourceTree = "<group>"; };
 		17B1221F2090AA9300387E33 /* WXSDKInstance_performance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXSDKInstance_performance.m; sourceTree = "<group>"; };
 		17B122202090AA9300387E33 /* WXSDKInstance_performance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSDKInstance_performance.h; sourceTree = "<group>"; };
 		17B122232090AAB000387E33 /* WXSDKError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSDKError.h; sourceTree = "<group>"; };
@@ -1035,21 +1035,11 @@
 			isa = PBXGroup;
 			children = (
 				17036A4C20FDE72F0029AE3D /* WXApmForInstance.h */,
-				17036A4D20FDE72F0029AE3D /* WXInstanceApm.m */,
+				1771795421412A5D006F39A9 /* WXApmForInstance.m */,
 			);
 			path = Performance;
 			sourceTree = "<group>";
 		};
-		17B12228209170CF00387E33 /* Recovered References */ = {
-			isa = PBXGroup;
-			children = (
-				8431F8DD1F9EFCC100C76E1E /* WXScrollerComponent+Layout.mm */,
-				59D3CA461CFC3CC0008835DC /* WXSliderComponent.mm */,
-				847E1DE01F9A1BCF00A48124 /* WXCoreStyle.h */,
-			);
-			name = "Recovered References";
-			sourceTree = "<group>";
-		};
 		2A42AF861C23B33E00818EA6 /* WeexSDK_MTL */ = {
 			isa = PBXGroup;
 			children = (
@@ -2252,6 +2242,7 @@
 				74A4BA9B1CB3BAA100195969 /* WXThreadSafeMutableDictionary.m in Sources */,
 				77E65A1A1C155F25008B8775 /* WXScrollerComponent.mm in Sources */,
 				747A787D1D1BAAC900DED9D0 /* WXComponent+ViewManagement.mm in Sources */,
+				1771795521412A5D006F39A9 /* WXApmForInstance.m in Sources */,
 				C4E375371E5FCBD3009B2D9C /* WXComponent+BoxShadow.m in Sources */,
 				C43C03E91EC8ACA40044C7FF /* WXPrerenderManager.m in Sources */,
 				2A837AB51CD9DE9200AEDF03 /* WXLoadingIndicator.m in Sources */,
@@ -2324,7 +2315,6 @@
 				74862F821E03A24500B7A041 /* WXComponentMethod.m in Sources */,
 				77E65A121C155EA8008B8775 /* WXImageComponent.m in Sources */,
 				74CFDD3E1F459400007A1A66 /* WXRecycleListDataManager.m in Sources */,
-				17036A5020FDE72F0029AE3D /* WXInstanceApm.m in Sources */,
 				2A837AB31CD9DE9200AEDF03 /* WXLoadingComponent.mm in Sources */,
 				2AE5B7531CAB7DBD0082FDDB /* WXAComponent.m in Sources */,
 				176BE43C209172330086B6AF /* WXComponent+Layout.mm in Sources */,
@@ -2415,7 +2405,6 @@
 				DCA445511EFA55B300D0CFA8 /* WXCycleSliderComponent.mm in Sources */,
 				DCE2CF9D1F46D4370021BDC4 /* WXVoiceOverModule.m in Sources */,
 				DCA445531EFA55B300D0CFA8 /* WXCellComponent.mm in Sources */,
-				17036A5120FDE72F0029AE3D /* WXInstanceApm.m in Sources */,
 				DCA445541EFA55B300D0CFA8 /* WXListComponent.mm in Sources */,
 				DCA445551EFA55B300D0CFA8 /* WXIndicatorComponent.m in Sources */,
 				17E5ACDB2091F05700EE81F1 /* WXComponent+Layout.mm in Sources */,
@@ -2485,6 +2474,7 @@
 				DCA4458C1EFA55B300D0CFA8 /* WXServiceFactory.m in Sources */,
 				DCA4458D1EFA55B300D0CFA8 /* WXInvocationConfig.m in Sources */,
 				DCA4458E1EFA55B300D0CFA8 /* WXDatePickerManager.m in Sources */,
+				1771795621412A5D006F39A9 /* WXApmForInstance.m in Sources */,
 				DCA4458F1EFA55B300D0CFA8 /* WXSDKManager.m in Sources */,
 				DCA445901EFA55B300D0CFA8 /* WXBridgeManager.m in Sources */,
 				DCA445911EFA55B300D0CFA8 /* WXModuleFactory.m in Sources */,
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 89ce8dd7e5..a13a1ba48f 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -429,20 +429,23 @@ - (void)updateImage
                 }
                 [strongSelf fireEvent:@"load" params:@{ @"success": error? @false : @true,@"size":sizeDict}];
             }
+            NSString* curUrl = imageURL.absoluteString;
             //check view/img size
-            if (!error && image && strongSelf.view) {
-                double imageSize = image.size.width * image.scale * image.size.height * image.scale;
-                double viewSize = strongSelf.view.frame.size.height *  strongSelf.view.frame.size.width;
-                if (imageSize > viewSize+1) {
+            if (!error && image && imageView && ![curUrl isEqualToString:self.preUrl]) {
+                self.preUrl = curUrl;
+                CGFloat screenScale = [[UIScreen mainScreen] scale];
+                double imageSize = image.size.width*image.scale  * image.size.height*image.scale;
+                double viewSize = imageView.frame.size.height *screenScale*  imageView.frame.size.width * screenScale;
+                CGFloat sizeRatio = imageSize/viewSize;
+                
+                //minDiffSize limt 40*40
+                if (sizeRatio>1.2 && (imageSize-viewSize) > 1600) {
                     self.weexInstance.performance.imgWrongSizeNum++;
                     [self.weexInstance.apmInstance updateDiffStats:KEY_PAGE_STATS_WRONG_IMG_SIZE_COUNT withDiffValue:1];
                 }
-                NSString* curUrl = imageURL.absoluteString;
-                if (![curUrl isEqualToString:self.preUrl]) {
-                    self.preUrl = curUrl;
-                    if (image.size.width >1080 && image.size.height > 1920) {
-                        [self.weexInstance.apmInstance updateDiffStats:KEY_PAGE_STATS_LARGE_IMG_COUNT withDiffValue:1];
-                    }
+                    
+                if (image.size.width* image.scale > 720 && image.size.height * image.scale> 1080) {
+                    [self.weexInstance.apmInstance updateDiffStats:KEY_PAGE_STATS_LARGE_IMG_COUNT withDiffValue:1];
                 }
             }
         }];
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
index e7606669be..63f3593dc9 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
@@ -28,6 +28,7 @@
 #define WX_ERROR_TYPE_JS        @"JS_ERROR"
 #define WX_ERROR_TYPE_DEGRADE    @"DEGRADE_ERROR"
 #define WX_ERROR_TYPE_RENDER    @"RENDER_ERROR"
+#define WX_ERROR_TYPE_DOWNLOAD  @"DOWN_LOAD_ERROR"
 
 
 typedef NS_ENUM(int, WXSDKErrCode)
@@ -88,7 +89,8 @@ typedef NS_ENUM (NSInteger,WXSDKErrorType)
     WX_JS_ERROR,
     WX_NATIVE_ERROR,
     WX_RENDER_ERROR,
-    WX_DEGRADE_ERROR
+    WX_DEGRADE_ERROR,
+    WX_DOWN_LOAD_ERROR
 };
 
 typedef NS_ENUM (NSInteger,WXSDKErrorGroup){
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
index 48c046f107..ef205fe87d 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
@@ -84,7 +84,7 @@ +(NSDictionary *) getMap
                 
                 @(WX_KEY_EXCEPTION_SDK_INIT):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
                 @(WX_KEY_EXCEPTION_INVOKE):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
-                @(WX_KEY_EXCEPTION_JS_DOWNLOAD):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+                @(WX_KEY_EXCEPTION_JS_DOWNLOAD):@{ERROR_TYPE:@(WX_DOWN_LOAD_ERROR),ERROR_GROUP:@(WX_NATIVE)},
                 @(WX_KEY_EXCEPTION_DOM):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
                 @(WX_KEY_EXCEPTION_WXBRIDGE):@{ERROR_TYPE:@(WX_JS_ERROR),ERROR_GROUP:@(WX_JS)},
                 
@@ -115,6 +115,8 @@ + (NSString *) convertTypeToStringName:(WXSDKErrorType)type
             return WX_ERROR_TYPE_RENDER;
         case WX_DEGRADE_ERROR:
             return WX_ERROR_TYPE_DEGRADE;
+        case WX_DOWN_LOAD_ERROR:
+            return WX_ERROR_TYPE_DOWNLOAD;
         case WX_NATIVE_ERROR:
         default:
             return WX_ERROR_TYPE_NATIVE;
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index 69ee169722..d10d868362 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -195,6 +195,12 @@ - (void)setFrame:(CGRect)frame
 #endif
     if (!CGRectEqualToRect(frame, _frame)) {
         _frame = frame;
+        CGFloat screenHeight =  [[UIScreen mainScreen] bounds].size.height;
+        if (screenHeight>0) {
+            CGFloat pageRatio = frame.size.height/screenHeight *100;
+            pageRatio = pageRatio>100?100:pageRatio;
+            [self.apmInstance setStatistic:KEY_PAGE_STATS_BODY_RATIO withValue:pageRatio];
+        }
         WXPerformBlockOnMainThread(^{
             if (_rootView) {
                 _rootView.frame = frame;
@@ -398,7 +404,6 @@ - (void)_renderWithRequest:(WXResourceRequest *)request options:(NSDictionary *)
      [self.apmInstance onStage:KEY_PAGE_STAGES_DOWN_BUNDLE_START];
     _mainBundleLoader.onFinished = ^(WXResourceResponse *response, NSData *data) {
         __strong typeof(weakSelf) strongSelf = weakSelf;
-        [strongSelf.apmInstance onStage:KEY_PAGE_STAGES_DOWN_BUNDLE_END];
         NSError *error = nil;
         if ([response isKindOfClass:[NSHTTPURLResponse class]] && ((NSHTTPURLResponse *)response).statusCode != 200) {
             error = [NSError errorWithDomain:WX_ERROR_DOMAIN
@@ -414,8 +419,13 @@ - (void)_renderWithRequest:(WXResourceRequest *)request options:(NSDictionary *)
         }
         
         if (error) {
-            WXJSExceptionInfo * jsExceptionInfo = [[WXJSExceptionInfo alloc] initWithInstanceId:@"" bundleUrl:[request.URL absoluteString] errorCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_JS_DOWNLOAD] functionName:@"_renderWithRequest:options:data:" exception:[error localizedDescription]  userInfo:nil];
-            [WXExceptionUtils commitCriticalExceptionRT:jsExceptionInfo];
+            [WXExceptionUtils commitCriticalExceptionRT:strongSelf.instanceId
+                                                errCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_JS_DOWNLOAD]
+                                               function:@"_renderWithRequest:options:data:"
+                                              exception:[NSString stringWithFormat:@"download bundle error :%@",[error localizedDescription]]
+                                              extParams:nil];
+        
+            strongSelf.apmInstance.isDownLoadFailed = YES;
             [strongSelf.apmInstance setProperty:KEY_PROPERTIES_ERROR_CODE withValue:[@(WX_KEY_EXCEPTION_JS_DOWNLOAD) stringValue]];
             return;
         }
@@ -423,13 +433,16 @@ - (void)_renderWithRequest:(WXResourceRequest *)request options:(NSDictionary *)
         if (!data) {
             NSString *errorMessage = [NSString stringWithFormat:@"Request to %@ With no data return", request.URL];
             WX_MONITOR_FAIL_ON_PAGE(WXMTJSDownload, WX_ERR_JSBUNDLE_DOWNLOAD, errorMessage, strongSelf.pageName);
-
-            WXJSExceptionInfo * jsExceptionInfo = [[WXJSExceptionInfo alloc] initWithInstanceId:@"" bundleUrl:[request.URL absoluteString] errorCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_JS_DOWNLOAD] functionName:@"_renderWithRequest:options:data:" exception:@"no data return"  userInfo:nil];
-            [WXExceptionUtils commitCriticalExceptionRT:jsExceptionInfo];
+            [WXExceptionUtils commitCriticalExceptionRT:strongSelf.instanceId
+                                                errCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_JS_DOWNLOAD]
+                                               function:@"_renderWithRequest:options:data:"
+                                              exception:@"no data return"
+                                              extParams:nil];
             
             if (strongSelf.onFailed) {
                 strongSelf.onFailed(error);
             }
+            strongSelf.apmInstance.isDownLoadFailed = YES;
             [strongSelf.apmInstance setProperty:KEY_PROPERTIES_ERROR_CODE withValue:[@(WX_KEY_EXCEPTION_JS_DOWNLOAD) stringValue]];
             return;
         }
@@ -458,7 +471,10 @@ - (void)_renderWithRequest:(WXResourceRequest *)request options:(NSDictionary *)
                 return;
             }
         }
+      
         
+        [strongSelf.apmInstance onStage:KEY_PAGE_STAGES_DOWN_BUNDLE_END];
+        [strongSelf.apmInstance updateExtInfoFromResponseHeader:response.allHeaderFields];
         [strongSelf _renderWithMainBundleString:jsBundleString];
         [WXTracingManager setBundleJSType:jsBundleString instanceId:weakSelf.instanceId];
         [WXMonitor performanceFinishWithState:DebugAfterRequest instance:strongSelf];
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
index 7b2f7f082d..818fa80029 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
@@ -116,6 +116,10 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent withModifyTime:(double)
           NSStringFromCGRect(targetComponent.weexInstance.rootView.frame)
           );
 #endif
+    if (!targetComponent.weexInstance.apmInstance.hasRecordFirstInterationView) {
+        targetComponent.weexInstance.apmInstance.hasRecordFirstInterationView = YES;
+        [targetComponent.weexInstance.apmInstance onStage:KEY_PAGE_STAGES_FIRST_INTERACTION_VIEW];
+    }
     [targetComponent.weexInstance.apmInstance onStage:KEY_PAGE_STAGES_INTERACTION];
     self.interactionLimitAddOpCount++;
     self.interactionAddCount = self.interactionAddCountRecord;
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXAnalyzerCenter.m b/ios/sdk/WeexSDK/Sources/Monitor/WXAnalyzerCenter.m
index 0796602c43..3e900964bf 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXAnalyzerCenter.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXAnalyzerCenter.m
@@ -200,9 +200,9 @@ +(void)transErrorInfo:(WXJSExceptionInfo *)errorInfo
         return;
     }
     NSDictionary *dic= @{
-                         @"errorCode":errorInfo.errorCode,
+                         @"errorCode":errorInfo.errorCode?:@"-1",
                          @"errorGroup":@"",
-                         @"errorMsg":errorInfo.exception
+                         @"errorMsg":errorInfo.exception?:@"unSetException"
                          };
     
     [self _transDataToAnaylzer:instance
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m b/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m
index 1c78fbbac9..276fad397c 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m
@@ -50,7 +50,22 @@ + (void)commitCriticalExceptionRT:(NSString *)instanceId errCode:(NSString *)err
                 }
                 [extInfo setObject:[self _convertInstanceStageToStr:instance] forKey:@"wxStageList"];
                 [extInfo setObject:instance.pageName?:@"unKnowPageNameCaseUnSet" forKey:@"wxPageName"];
-                [extInfo setObject:instance.bundleTemplate?:@"has recycle" forKey:@"wxTemplateOfBundle"];
+                NSString* bundleTemplateCommit = @"has recycle";
+                if (nil != instance.bundleTemplate) {
+                    NSUInteger strLength = instance.bundleTemplate.length;
+                    bundleTemplateCommit = [instance.bundleTemplate substringWithRange:NSMakeRange(0, strLength>300?300:strLength)];
+                }
+                [extInfo setObject:bundleTemplateCommit forKey:@"wxTemplateOfBundle"];
+                [extInfo setObject:[instance.apmInstance templateInfo] forKey:@"templateInfo"];
+                NSNumber* pageStartTime = [instance.apmInstance.stageDic objectForKey:KEY_PAGE_STAGES_DOWN_BUNDLE_START];
+                if (nil == pageStartTime) {
+                    pageStartTime = [instance.apmInstance.stageDic objectForKey:KEY_PAGE_STAGES_RENDER_ORGIGIN];
+                }
+                if (nil != pageStartTime) {
+                    long useTime = [WXUtility getUnixFixTimeMillis] - pageStartTime.longValue;
+                    [extInfo setObject:@(useTime) forKey:@"wxUseTime"];
+                }
+                
             }else if([instanceIdCommit hasPrefix:@"WX_KEY_EXCEPTION"]){
                 bundleUrlCommit = instanceId;
             }
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
index 585add2dfb..e775a461f7 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
@@ -69,6 +69,8 @@ extern NSString* const KEY_PAGE_STATS_IMG_LOAD_FAIL_NUM;
 extern NSString* const KEY_PAGE_STATS_NET_NUM;
 extern NSString* const KEY_PAGE_STATS_NET_SUCCESS_NUM;
 extern NSString* const KEY_PAGE_STATS_NET_FAIL_NUM;
+extern NSString* const KEY_PAGE_STAGES_FIRST_INTERACTION_VIEW;
+extern NSString* const KEY_PAGE_STATS_BODY_RATIO;
 
 ///************** value *****************/
 extern NSString* const VALUE_ERROR_CODE_DEFAULT;
@@ -83,6 +85,8 @@ extern NSString* const VALUE_ERROR_CODE_DEFAULT;
 @property (nonatomic, assign) BOOL hasAddView;
 @property (nonatomic, assign) BOOL isDegrade;
 @property (nonatomic, assign) BOOL isStartRender;
+@property (nonatomic,assign)  BOOL  hasRecordFirstInterationView;
+@property (nonatomic, assign) BOOL isDownLoadFailed;
 
 #pragma mark - basic method
 
@@ -99,7 +103,7 @@ extern NSString* const VALUE_ERROR_CODE_DEFAULT;
 - (void) updateFSDiffStats:(NSString *)name withDiffValue:(double)diff;
 - (void) updateDiffStats:(NSString *)name withDiffValue:(double)diff;
 - (void) updateMaxStats:(NSString *)name curMaxValue:(double)maxValue;
-- (void) updateExtInfo:(NSDictionary*) extInfo;
+- (void) updateExtInfoFromResponseHeader:(NSDictionary*) extInfo;
 
 
 #pragma mark - called by IWXHttpAdapter implementer
@@ -114,4 +118,7 @@ extern NSString* const VALUE_ERROR_CODE_DEFAULT;
 #pragma mark record top5 errorMsg
 - (void) recordErrorMsg:(WXJSExceptionInfo *)exception;
 - (NSDictionary<NSString*,NSNumber*>*) stageDic;
+
+#pragma templateinfo
+- (NSString*) templateInfo;
 @end
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXInstanceApm.m b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
similarity index 81%
rename from ios/sdk/WeexSDK/Sources/Performance/WXInstanceApm.m
rename to ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
index 0c3050a23e..1ed72ea3f1 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXInstanceApm.m
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
@@ -79,16 +79,22 @@
 NSString* const KEY_PAGE_STATS_NET_NUM  = @"wxNetworkRequestCount";
 NSString* const KEY_PAGE_STATS_NET_SUCCESS_NUM = @"wxNetworkRequestSuccessCount";
 NSString* const KEY_PAGE_STATS_NET_FAIL_NUM = @"wxNetworkRequestFailCount";
+NSString* const KEY_PAGE_STAGES_FIRST_INTERACTION_VIEW = @"wxFirstInteractionView";
+NSString* const KEY_PAGE_STATS_BODY_RATIO = @"wxBodyRatio";
 
 ///************** value *****************/
 NSString* const VALUE_ERROR_CODE_DEFAULT = @"0";
 
 @interface WXApmForInstance ()
+{
+    BOOL _isRecord;
+    BOOL _isEnd;
+    NSDictionary* _responseHeader;
+}
+
 @property (nonatomic,strong) id<WXApmProtocol> apmProtocolInstance;
 @property (nonatomic,strong) NSString* instanceId;
 @property (nonatomic,strong) NSMutableDictionary<NSString*,NSNumber*>* recordStatsMap;
-@property (nonatomic,assign) BOOL isRecord;
-@property (nonatomic,assign) BOOL isEnd;
 @property (nonatomic,strong) NSMutableDictionary<NSString*,NSNumber*>* recordStageMap;
 @property (nonatomic,strong) NSMutableArray<WXJSExceptionInfo*>* errorList;
 @end
@@ -122,7 +128,7 @@ - (void) onEvent:(NSString *)name withValue:(id)value
 
 - (void) onStage:(NSString *)name
 {
-    if (nil == _apmProtocolInstance) {
+    if (nil == _apmProtocolInstance || _isEnd) {
         return;
     }
     long time = [WXUtility getUnixFixTimeMillis];
@@ -135,7 +141,7 @@ - (void) onStage:(NSString *)name
 
 - (void) setProperty:(NSString *)name withValue:(id)value
 {
-    if (nil == _apmProtocolInstance) {
+    if (nil == _apmProtocolInstance || _isEnd) {
         return;
     }
     [self.apmProtocolInstance addProperty:name withValue:value];
@@ -143,7 +149,7 @@ - (void) setProperty:(NSString *)name withValue:(id)value
 
 - (void) setStatistic:(NSString *)name withValue:(double)value
 {
-    if (nil == _apmProtocolInstance) {
+    if (nil == _apmProtocolInstance || _isEnd) {
         return;
     }
     [self.apmProtocolInstance addStatistic:name withValue:value];
@@ -153,10 +159,10 @@ - (void) setStatistic:(NSString *)name withValue:(double)value
 
 - (void) startRecord:(NSString*) instanceId
 {
-    if (nil == _apmProtocolInstance || self.isRecord) {
+    if (nil == _apmProtocolInstance || _isRecord) {
         return;
     }
-    self.isRecord = YES;
+    _isRecord = YES;
     _instanceId = instanceId;
     
     [self.apmProtocolInstance onStart:instanceId topic:WEEX_PAGE_TOPIC];
@@ -191,10 +197,10 @@ - (void) startRecord:(NSString*) instanceId
 
 - (void) endRecord;
 {
-    if (nil == _apmProtocolInstance || self.isEnd) {
+    if (nil == _apmProtocolInstance || _isEnd) {
         return;
     }
-    self.isEnd = YES;
+    _isEnd = YES;
     
     [self onStage:KEY_PAGE_STAGES_DESTROY];
     [self.apmProtocolInstance onEnd];
@@ -203,16 +209,17 @@ - (void) endRecord;
 
 - (void) arriveFSRenderTime
 {
-    if (nil == _apmProtocolInstance || self.isFSEnd) {
+    if (nil == _apmProtocolInstance || _isFSEnd) {
         return;
     }
     self.isFSEnd = true;
+    
     [self onStage:KEY_PAGE_STAGES_FSRENDER];
 }
 
 - (void) updateFSDiffStats:(NSString *)name withDiffValue:(double)diff
 {
-    if (nil == _apmProtocolInstance || self.isFSEnd) {
+    if (nil == _apmProtocolInstance || _isFSEnd) {
         return;
     }
     [self updateDiffStats:name withDiffValue:diff];
@@ -225,7 +232,7 @@ - (void) updateDiffStats:(NSString *)name withDiffValue:(double)diff
     }
     __weak typeof(self) weakSelf = self;
     WXPerformBlockOnComponentThread(^{
-        NSNumber* preNumber = [self.recordStatsMap objectForKey:name];
+        NSNumber* preNumber = [weakSelf.recordStatsMap objectForKey:name];
         double preVal = nil == preNumber?0:preNumber.doubleValue;
         double currentVal = preVal + diff;
         [weakSelf.recordStatsMap setObject:@(currentVal) forKey:name];
@@ -251,8 +258,9 @@ - (void) updateMaxStats:(NSString *)name curMaxValue:(double)currentValue
     });
 }
 
-- (void) updateExtInfo:(NSDictionary*) extInfo
+- (void) updateExtInfoFromResponseHeader:(NSDictionary*) extInfo
 {
+    _responseHeader = extInfo;
     if (nil == _apmProtocolInstance || nil == extInfo) {
         return;
     }
@@ -268,7 +276,7 @@ - (void) updateExtInfo:(NSDictionary*) extInfo
         [self  setStatistic:KEY_PAGE_STATS_ACTUAL_DOWNLOAD_TIME withValue:value];
     }
     
-    id wxZcacheInfo = [extInfo objectForKey:KEY_PAGE_PROPERTIES_Z_CACHE_INFO];
+    id wxZcacheInfo = [extInfo objectForKey:@"X-ZCache-Info"];
     if (nil !=wxZcacheInfo && [wxZcacheInfo isKindOfClass: NSString.class]) {
         [self setProperty:KEY_PAGE_PROPERTIES_Z_CACHE_INFO withValue:wxZcacheInfo];
     }
@@ -342,7 +350,10 @@ - (void) recordErrorMsg:(WXJSExceptionInfo *)exception
 
 - (void) _checkScreenEmptyAndReport
 {
-    if(self.hasAddView || !self.isStartRender || self.isDegrade){
+    if(self.isDownLoadFailed || self.hasAddView || !self.isStartRender || self.isDegrade){
+        return;
+    }
+    if (![self _isReportEmptyScreenError]) {
         return;
     }
     __weak WXApmForInstance* weakSelf = self;
@@ -351,49 +362,34 @@ - (void) _checkScreenEmptyAndReport
         if (nil == strongSelf) {
             return;
         }
-        
-        NSInteger LIMIT_TIME_FROM_RENDER_URL = 2000;
-        NSInteger LIMIT_TIME_FROM_RENDER_TEMPLATE = 1000;
-        
         long curTime = [WXUtility getUnixFixTimeMillis];
-        BOOL sholudReportByTime;
-        long useTime;
-        NSString* useTimeFrom;
-        
-        NSNumber* startTime = [strongSelf.stageDic objectForKey:KEY_PAGE_STAGES_DOWN_BUNDLE_START];
-        if (nil != startTime) {
-            useTime = curTime - startTime.longValue;
-            useTimeFrom = KEY_PAGE_STAGES_DOWN_BUNDLE_START;
-            sholudReportByTime = useTime > LIMIT_TIME_FROM_RENDER_URL;
-        }else{
-            startTime = [strongSelf.stageDic objectForKey:KEY_PAGE_STAGES_RENDER_ORGIGIN];
-            useTime = nil != startTime ? curTime -startTime.longValue : curTime;
-            useTimeFrom = KEY_PAGE_STAGES_RENDER_ORGIGIN;
-            sholudReportByTime = useTime > LIMIT_TIME_FROM_RENDER_TEMPLATE;
+        NSNumber* startExecJsTime = [strongSelf.stageDic objectForKey:KEY_PAGE_STAGES_LOAD_BUNDLE_END];
+        if (nil == startExecJsTime) {
+            return;
         }
-        
-        if (!sholudReportByTime) {
+        long jsExecTime = curTime - startExecJsTime.longValue;
+        if (jsExecTime < 3000) {
             return;
         }
         
-        WXSDKErrCode code = WX_KEY_EXCEPTION_EMPTY_SCREEN_NATIVE;
-        for (WXJSExceptionInfo* exception in strongSelf.errorList) {
-            WXSDKErrorGroup group = [WXSDKErrCodeUtil getErrorGroupByCode:exception.errorCode.intValue];
-            if(group == WX_JS){
-                code = WX_KEY_EXCEPTION_EMPTY_SCREEN_JS;
-                break;
-            }
-        }
-        NSString *codeStr = [NSString stringWithFormat:@"%d",code];
+        NSString *codeStr = [NSString stringWithFormat:@"%d",WX_KEY_EXCEPTION_EMPTY_SCREEN_JS];
         NSDictionary* extInfo = @{
             @"wxBeginRender":@(strongSelf.isStartRender),
             @"wxHasAddView":@(strongSelf.hasAddView),
             @"wxHasDegrade":@(strongSelf.isDegrade),
-            @"wxUseTime":@(useTime),
-            @"wxUseTimeFrom":useTimeFrom
+            @"wxJSExecTime":@(jsExecTime)
             };
+        NSString* errorMsg;
+        if(self.errorList.count<=0){
+            NSNumber* jsEndTime = [strongSelf.stageDic objectForKey:KEY_PAGE_STAGES_CREATE_FINISH];
+            errorMsg = nil != jsEndTime
+                ? @"writeScreen :never add view until page destroy(js has execute > 3s)"
+                : @"writeScreen :never add view even js executeTime > 3s";
+        }else {
+            errorMsg = [NSString stringWithFormat:@"writeScreen :history exception :%@",[strongSelf _convertTopExceptionListToStr]];
+        }
         [WXExceptionUtils commitCriticalExceptionRT:strongSelf.instanceId errCode:codeStr function:@"_checkScreenEmptyAndReport"
-                                          exception:[strongSelf _convertTopExceptionListToStr] extParams:extInfo];
+                                          exception:errorMsg extParams:extInfo];
     });
 }
 
@@ -402,17 +398,14 @@ - (NSString *)_convertTopExceptionListToStr
     if (!self.isOpenApm) {
         return @"";
     }
-    if (!self.errorList || self.errorList.count <= 0) {
-        return @"emptyTopErrorlist";
-    }
-    NSString* errorStr = @"========== topErrorList start ============";
+   
+    NSString* errorStr = @"";
     for (WXJSExceptionInfo* exception in self.errorList) {
         errorStr = [errorStr stringByAppendingFormat:
-                    @"%@ -> code:%@,func:%@,exception:%@ \n",
+                    @"%@ -> code:%@,func:%@,exception:%@ ========>",
                     errorStr,exception.errorCode,exception.functionName,exception.exception
                     ];
     }
-    errorStr = [errorStr stringByAppendingFormat:@"%@ ========== topErrorList start end ============\n",errorStr];
     return errorStr;
 }
 
@@ -432,5 +425,29 @@ - (BOOL) _loadApmSwitch
     return openApm;
 }
 
+- (BOOL) _isReportEmptyScreenError
+{
+    BOOL report = YES;
+    id<WXConfigCenterProtocol> configCenter = [WXSDKEngine handlerForProtocol:@protocol(WXConfigCenterProtocol)];
+    
+    if ([configCenter respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) {
+        report = [[configCenter configForKey:@"iOS_weex_ext_config.report_write_screen" defaultValue:@(YES) isDefault:NULL] boolValue];
+    }
+    return report;
+}
+
+- (NSString*) templateInfo
+{
+    
+    NSString* headerStr = [WXUtility JSONString:_responseHeader];
+    NSString* bundleVerfiInfo = nil;
+    WXSDKInstance* instance = [WXSDKManager instanceForID:self.instanceId];
+    if (nil != instance) {
+        bundleVerfiInfo = [WXUtility JSONString:instance.userInfo];
+    }
+    NSString* info = [NSString stringWithFormat:@"bundleVerfiInfo :%@, httpHeaderInfo:%@",bundleVerfiInfo?:@"unSetVerfiInfo",headerStr?:@"unSetHeader"];
+    return info;
+}
+
 @end
 


 

----------------------------------------------------------------
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