[
https://issues.apache.org/jira/browse/WEEX-609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16608694#comment-16608694
]
ASF GitHub Bot commented on WEEX-609:
-------------------------------------
cxfeng1 closed pull request #1505: [WEEX-609][iOS]apm monitor logic modify
URL: https://github.com/apache/incubator-weex/pull/1505
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/Sources/Bridge/WXBridgeContext.m
b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index 3e99033691..a3b7bac6e0 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -597,29 +597,55 @@ - (void)createInstance:(NSString *)instanceIdString
sdkInstance.executeRaxApiResult = [NSString
stringWithFormat:@"%@",
[[sdkInstance.instanceJavaScriptContext.javaScriptContext.globalObject
toDictionary] allKeys]];
}
+ [sdkInstance.apmInstance
onStage:KEY_PAGE_STAGES_LOAD_BUNDLE_END];
if ([NSURL URLWithString:sdkInstance.pageName] ||
sdkInstance.scriptURL) {
[sdkInstance.instanceJavaScriptContext
executeJavascript:jsBundleString withSourceURL:[NSURL
URLWithString:sdkInstance.pageName]?:sdkInstance.scriptURL];
} else {
[sdkInstance.instanceJavaScriptContext
executeJavascript:jsBundleString];
}
WX_MONITOR_INSTANCE_PERF_END(WXPTJSCreateInstance,
[WXSDKManager instanceForID:instanceIdString]);
- [sdkInstance.apmInstance
onStage:KEY_PAGE_STAGES_LOAD_BUNDLE_END];
}];
}
} else {
[sdkInstance.apmInstance setProperty:KEY_PAGE_PROPERTIES_BUNDLE_TYPE
withValue:@"other"];
+ [sdkInstance.apmInstance onStage:KEY_PAGE_STAGES_LOAD_BUNDLE_END];
if (data){
args = @[instanceIdString, jsBundleString, options ?: @{}, data];
} else {
args = @[instanceIdString, jsBundleString, options ?: @{}];
}
+ [self _mountInstanceInfoToGlobalContext:sdkInstance];
[self callJSMethod:@"createInstance" args:args];
WX_MONITOR_INSTANCE_PERF_END(WXPTJSCreateInstance, [WXSDKManager
instanceForID:instanceIdString]);
- [sdkInstance.apmInstance onStage:KEY_PAGE_STAGES_LOAD_BUNDLE_END];
}
}
+- (BOOL) _shouldMountExtInfoToInstanceContxt
+{
+ id configCenter = [WXSDKEngine
handlerForProtocol:@protocol(WXConfigCenterProtocol)];
+ BOOL shouldMountInstanceContextExtInfo = YES;
+ if ([configCenter
respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) {
+ shouldMountInstanceContextExtInfo = [[configCenter
configForKey:@"iOS_weex_ext_config.shouldMountInstanceContextExtInfo"
defaultValue:@YES isDefault:NULL] boolValue];
+ }
+ return shouldMountInstanceContextExtInfo;
+}
+
+- (void) _mountInstanceInfoToGlobalContext:(WXSDKInstance*) instance
+{
+ if (![self _shouldMountExtInfoToInstanceContxt]) {
+ return;
+ }
+ JSContext* globalContext = self.jsBridge.javaScriptContext;
+ if (!globalContext && [globalContext.name isEqualToString:@"Weex
Context"]) {
+ return;
+ }
+ NSMutableDictionary *extInfo = [NSMutableDictionary
dictionaryWithDictionary:@{
+ @"wxInstanceId":instance.instanceId?:@"unSetInstanceId"
+ }];
+ globalContext[@"wxInstanceExtInfo"] = extInfo;
+}
+
- (NSString *)_pareJSBundleType:(NSString*)instanceIdString
jsBundleString:(NSString*)jsBundleString
{
NSString * bundleType = nil;
@@ -1018,6 +1044,7 @@ + (void)mountContextEnvironment:(JSContext*)context
gInExceptionHandler = YES;
@try {
+ BOOL tryFindInstanceInfoInGlobalContext = NO;
context.exception = exception;
NSString *errorCode = [NSString stringWithFormat:@"%d",
WX_KEY_EXCEPTION_WXBRIDGE];;
NSString *bundleUrl = nil;
@@ -1038,19 +1065,30 @@ + (void)mountContextEnvironment:(JSContext*)context
}
} else {
// weex-main-jsfm.js runtime exception throws
- message = [NSString
stringWithFormat:@"[WX_KEY_EXCEPTION_WXBRIDGE] [%@:%@:%@] %@\n%@",
exception[@"sourceURL"], exception[@"line"], exception[@"column"], [exception
toString], [exception[@"stack"] toObject]];
+ message = [NSString
stringWithFormat:@"[WX_KEY_EXCEPTION_WXBRIDGE] [%@:%@:%@] %@ js stack: %@",
exception[@"sourceURL"], exception[@"line"], exception[@"column"], [exception
toString], [exception[@"stack"] toObject]];
if (!JSValueIsUndefined(context.JSGlobalContextRef,
exception[@"sourceURL"].JSValueRef)) {
bundleUrl = exception[@"sourceURL"].toString;
} else {
bundleUrl = @"weex-main-jsfm";
}
userInfo = [NSDictionary dictionary];
+ tryFindInstanceInfoInGlobalContext = YES;
+ JSValue* instanceExtInfoValue = [context
objectForKeyedSubscript:@"wxInstanceExtInfo"];
+ if (nil != instanceExtInfoValue) {
+ NSDictionary* instanceInfo = [instanceExtInfoValue
toDictionary];
+ NSString* exceptionInstanceId = [instanceInfo
objectForKey:@"wxInstanceId"];
+ if (nil != exceptionInstanceId) {
+ instance = [WXSDKManager
instanceForID:exceptionInstanceId];
+ }
+ }
+ errorCode = [NSString stringWithFormat:@"%d",
WX_KEY_EXCEPTION_EMPTY_SCREEN_JS];
}
} else {
instance = [WXSDKEngine topInstance];
}
- if (instance) {
+
+ if (instance && !tryFindInstanceInfoInGlobalContext) {
bundleUrl = instance.pageName?:([instance.scriptURL
absoluteString]?:@"WX_KEY_EXCEPTION_WXBRIDGE");
message = [NSString
stringWithFormat:@"[WX_KEY_EXCEPTION_WXBRIDGE] [%@:%@:%@]
%@\n%@\n%@\n%@\n%@\n%@", exception[@"sourceURL"], exception[@"line"],
exception[@"column"], [exception toString], [exception[@"stack"] toObject],
instance.scriptURL.absoluteString, instance.callCreateInstanceContext?:@"",
instance.createInstanceContextResult?:@"", instance.executeRaxApiResult?:@""];
userInfo =
@{@"jsMainBundleStringContentLength":instance.userInfo[@"jsMainBundleStringContentLength"]?:@"",
@@ -1060,9 +1098,9 @@ + (void)mountContextEnvironment:(JSContext*)context
if (commitException) {
WXJSExceptionInfo * jsExceptionInfo = [[WXJSExceptionInfo
alloc] initWithInstanceId:instance.instanceId bundleUrl:bundleUrl
errorCode:errorCode functionName:@"" exception:message userInfo:[userInfo
mutableCopy]];
- [WXExceptionUtils commitCriticalExceptionRT:jsExceptionInfo];
+ [WXExceptionUtils
commitCriticalExceptionRT:jsExceptionInfo.instanceId
errCode:jsExceptionInfo.errorCode function:@"exceptionHandler"
exception:jsExceptionInfo.exception extParams:jsExceptionInfo.userInfo];
WX_MONITOR_FAIL(WXMTJSBridge, WX_ERR_JS_EXECUTE, message);
- if (instance.onJSRuntimeException) {
+ if (instance.onJSRuntimeException &&
!tryFindInstanceInfoInGlobalContext) {
instance.onJSRuntimeException(jsExceptionInfo);
}
}
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m
b/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m
index 0a99d890a1..4c95e511ce 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m
@@ -165,6 +165,7 @@ - (void)_renderWithURL:(NSURL *)sourceURL
};
_embedInstance.onFailed = ^(NSError *error) {
+ weakSelf.weexInstance.apmInstance.isDegrade = YES;
dispatch_async(dispatch_get_main_queue(), ^{
if (weakSelf.errorView) {
return ;
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
index 818fa80029..bbc8f90d72 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
@@ -72,6 +72,9 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent
withModifyTime:(double)
if (diff > 8000) {
return;
}
+ if ([targetComponent.type isEqualToString:@"_root"]) {
+ return;
+ }
if (diff < self.interactionTime) {
//useless calulcate ,for imporove performance
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m
b/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m
index 276fad397c..169047004c 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.m
@@ -72,11 +72,11 @@ + (void)commitCriticalExceptionRT:(NSString *)instanceId
errCode:(NSString *)err
}
WXJSExceptionInfo * jsExceptionInfo = [[WXJSExceptionInfo alloc]
initWithInstanceId:instanceIdCommit bundleUrl:bundleUrlCommit errorCode:errCode
functionName:function exception:exception userInfo: [extInfo mutableCopy]];
- //record top5 erromsg ,if errorType is not WX_RENDER_ERROR
- WXSDKErrorType type = [WXSDKErrCodeUtil
getErrorTypeByCode:errCode.intValue];
- if (type != WX_RENDER_ERROR && nil != instance) {
- [instance.apmInstance recordErrorMsg:jsExceptionInfo];
- }
+// //record top5 erromsg ,if errorType is not WX_RENDER_ERROR
+// WXSDKErrorType type = [WXSDKErrCodeUtil
getErrorTypeByCode:errCode.intValue];
+// if (type != WX_RENDER_ERROR && nil != instance) {
+// [instance.apmInstance recordErrorMsg:jsExceptionInfo];
+// }
[WXExceptionUtils commitCriticalExceptionRT:jsExceptionInfo];
});
}
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
index 1ed72ea3f1..281da83ae0 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
@@ -350,47 +350,47 @@ - (void) recordErrorMsg:(WXJSExceptionInfo *)exception
- (void) _checkScreenEmptyAndReport
{
- if(self.isDownLoadFailed || self.hasAddView || !self.isStartRender ||
self.isDegrade){
- return;
- }
- if (![self _isReportEmptyScreenError]) {
- return;
- }
- __weak WXApmForInstance* weakSelf = self;
- WXPerformBlockOnComponentThread(^{
- __strong WXApmForInstance* strongSelf = weakSelf;
- if (nil == strongSelf) {
- return;
- }
- long curTime = [WXUtility getUnixFixTimeMillis];
- NSNumber* startExecJsTime = [strongSelf.stageDic
objectForKey:KEY_PAGE_STAGES_LOAD_BUNDLE_END];
- if (nil == startExecJsTime) {
- return;
- }
- long jsExecTime = curTime - startExecJsTime.longValue;
- if (jsExecTime < 3000) {
- return;
- }
-
- NSString *codeStr = [NSString
stringWithFormat:@"%d",WX_KEY_EXCEPTION_EMPTY_SCREEN_JS];
- NSDictionary* extInfo = @{
- @"wxBeginRender":@(strongSelf.isStartRender),
- @"wxHasAddView":@(strongSelf.hasAddView),
- @"wxHasDegrade":@(strongSelf.isDegrade),
- @"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:errorMsg
extParams:extInfo];
- });
+// if(self.isDownLoadFailed || self.hasAddView || !self.isStartRender ||
self.isDegrade){
+// return;
+// }
+// if (![self _isReportEmptyScreenError]) {
+// return;
+// }
+// __weak WXApmForInstance* weakSelf = self;
+// WXPerformBlockOnComponentThread(^{
+// __strong WXApmForInstance* strongSelf = weakSelf;
+// if (nil == strongSelf) {
+// return;
+// }
+// if (nil == [strongSelf.stageDic
objectForKey:KEY_PAGE_STAGES_CREATE_FINISH]) {
+// return;
+// }
+// long curTime = [WXUtility getUnixFixTimeMillis];
+// NSNumber* startExecJsTime = [strongSelf.stageDic
objectForKey:KEY_PAGE_STAGES_LOAD_BUNDLE_END];
+// if (nil == startExecJsTime) {
+// return;
+// }
+// long jsExecTime = curTime - startExecJsTime.longValue;
+// if (jsExecTime < 4000) {
+// return;
+// }
+//
+// NSString *codeStr = [NSString
stringWithFormat:@"%d",WX_KEY_EXCEPTION_EMPTY_SCREEN_JS];
+// NSDictionary* extInfo = @{
+// @"wxBeginRender":@(strongSelf.isStartRender),
+// @"wxHasAddView":@(strongSelf.hasAddView),
+// @"wxHasDegrade":@(strongSelf.isDegrade),
+// @"wxJSExecTime":@(jsExecTime)
+// };
+// NSString* errorMsg;
+// if(self.errorList.count<=0){
+// errorMsg = @"whiteScreen :never add view until page destroy(js
has execute > 3s)";
+// }else {
+// errorMsg = [NSString stringWithFormat:@"writeScreen :history
exception :%@",[strongSelf _convertTopExceptionListToStr]];
+// }
+// [WXExceptionUtils commitCriticalExceptionRT:strongSelf.instanceId
errCode:codeStr function:@"_checkScreenEmptyAndReport"
+// exception:errorMsg
extParams:extInfo];
+// });
}
- (NSString *)_convertTopExceptionListToStr
----------------------------------------------------------------
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:
[email protected]
> [iOS] apm monitor logic modify
> ------------------------------
>
> Key: WEEX-609
> URL: https://issues.apache.org/jira/browse/WEEX-609
> Project: Weex
> Issue Type: Improvement
> Components: iOS
> Reporter: peihan
> Assignee: XuYouyang
> Priority: Major
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)