+ [ios] update tracing logic

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/4b80dac2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/4b80dac2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/4b80dac2

Branch: refs/heads/0.16-dev
Commit: 4b80dac218e41490e447978e03005a275cbad639
Parents: e4e0f49
Author: 齐山 <sunjjb...@163.com>
Authored: Fri Aug 4 15:40:37 2017 +0800
Committer: 齐山 <sunjjb...@163.com>
Committed: Fri Aug 4 15:40:37 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Bridge/WXBridgeContext.m    |  35 ++++---
 ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m |  10 +-
 .../WeexSDK/Sources/Manager/WXBridgeManager.m   |   4 +
 .../Sources/Manager/WXComponentFactory.h        |   1 +
 .../Sources/Manager/WXComponentFactory.m        |  23 ++++
 .../Sources/Manager/WXComponentManager.m        |  18 +++-
 .../WeexSDK/Sources/Manager/WXModuleFactory.h   |   6 ++
 .../WeexSDK/Sources/Manager/WXModuleFactory.m   |  24 +++++
 .../WeexSDK/Sources/Manager/WXTracingManager.h  |  20 +++-
 .../WeexSDK/Sources/Manager/WXTracingManager.m  | 104 ++++++++++++++-----
 ios/sdk/WeexSDK/Sources/Model/WXComponent.m     |   1 -
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m   |   6 +-
 .../Sources/View/WXComponent+ViewManagement.m   |   1 -
 13 files changed, 195 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m 
b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index 781dd05..ca57dc2 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -126,15 +126,16 @@ _Pragma("clang diagnostic pop") \
         if(![weakSelf checkInstance:instance]) {
             return -1;
         }
-        
+        [WXTracingManager startTracingWithInstanceId:instanceId 
ref:elementData[@"ref"] className:nil name:WXTJSCall phase:WXTracingEnd 
functionName:@"addElement" options:nil];
         WXPerformBlockOnComponentThread(^{
-            [WXTracingManager startTracingWithInstanceId:instanceId 
ref:elementData[@"ref"] className:nil name:WXTJSCall phase:WXTracingEnd 
functionName:@"addElement" options:nil];
             WXComponentManager *manager = instance.componentManager;
             if (!manager.isValid) {
                 return;
             }
+            [WXTracingManager startTracingWithInstanceId:instanceId 
ref:elementData[@"ref"] className:nil name:WXTDomCall phase:WXTracingBegin 
functionName:@"addElement" options:@{@"threadName":WXTDOMThread}];
             [manager startComponentTasks];
             [manager addComponent:elementData toSupercomponent:parentRef 
atIndex:index appendingInTree:NO];
+            [WXTracingManager startTracingWithInstanceId:instanceId 
ref:elementData[@"ref"] className:nil name:WXTDomCall phase:WXTracingEnd 
functionName:@"addElement" options:@{@"threadName":WXTDOMThread}];
         });
         
         return 0;
@@ -148,15 +149,17 @@ _Pragma("clang diagnostic pop") \
         if(![weakSelf checkInstance:instance]) {
             return -1;
         }
-        
+        [WXTracingManager startTracingWithInstanceId:instanceId 
ref:bodyData[@"ref"] className:nil name:WXTJSCall phase:WXTracingEnd 
functionName:@"createBody" options:@{@"threadName":WXTJSBridgeThread}];
         WXPerformBlockOnComponentThread(^{
             WXComponentManager *manager = instance.componentManager;
             if (!manager.isValid) {
                 return;
             }
+            [WXTracingManager startTracingWithInstanceId:instanceId 
ref:bodyData[@"ref"] className:nil name:WXTDomCall phase:WXTracingBegin 
functionName:@"createBody" options:@{@"threadName":WXTDOMThread}];
             [manager startComponentTasks];
             [manager createRoot:bodyData];
-            [WXTracingManager startTracingWithInstanceId:instanceId 
ref:bodyData[@"ref"] className:nil name:WXTJSCall phase:WXTracingEnd 
functionName:@"createBody" options:nil];
+            [WXTracingManager startTracingWithInstanceId:instanceId 
ref:bodyData[@"ref"] className:nil name:WXTDomCall phase:WXTracingEnd 
functionName:@"createBody" options:@{@"threadName":WXTDOMThread}];
+            
         });
         
         return 0;
@@ -170,15 +173,16 @@ _Pragma("clang diagnostic pop") \
         if(![weakSelf checkInstance:instance]) {
             return -1;
         }
-        
+        [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"removeElement" 
options:nil];
         WXPerformBlockOnComponentThread(^{
             WXComponentManager *manager = instance.componentManager;
             if (!manager.isValid) {
                 return;
             }
+            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTDomCall phase:WXTracingBegin 
functionName:@"removeElement" options:@{@"threadName":WXTDOMThread}];
             [manager startComponentTasks];
             [manager removeComponent:ref];
-            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"removeElement" 
options:nil];
+            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTDomCall phase:WXTracingEnd functionName:@"removeElement" 
options:@{@"threadName":WXTDOMThread}];
         });
         
         return 0;
@@ -192,7 +196,7 @@ _Pragma("clang diagnostic pop") \
         if(![weakSelf checkInstance:instance]) {
             return -1;
         }
-        
+        [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"moveElement" 
options:nil];
         WXPerformBlockOnComponentThread(^{
             WXComponentManager *manager = instance.componentManager;
             if (!manager.isValid) {
@@ -200,7 +204,6 @@ _Pragma("clang diagnostic pop") \
             }
             [manager startComponentTasks];
             [manager moveComponent:ref toSuper:parentRef atIndex:index];
-            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"moveElement" 
options:nil];
         });
         
         return 0;
@@ -215,14 +218,16 @@ _Pragma("clang diagnostic pop") \
             return -1;
         }
         
+        [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"updateAttrs" 
options:@{@"threadName":WXTJSBridgeThread}];
         WXPerformBlockOnComponentThread(^{
             WXComponentManager *manager = instance.componentManager;
             if (!manager.isValid) {
                 return;
             }
+            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTDomCall phase:WXTracingBegin functionName:@"updateAttrs" 
options:@{@"threadName":WXTDOMThread}];
             [manager startComponentTasks];
             [manager updateAttributes:attrsData forComponent:ref];
-            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"updateAttrs" 
options:nil];
+            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTDomCall phase:WXTracingEnd functionName:@"updateAttrs" 
options:@{@"threadName":WXTDOMThread}];
         });
         
         return 0;
@@ -236,7 +241,7 @@ _Pragma("clang diagnostic pop") \
         if(![weakSelf checkInstance:instance]) {
             return -1;
         }
-        
+        [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"updateStyles" 
options:@{@"threadName":WXTJSBridgeThread}];
         WXPerformBlockOnComponentThread(^{
             WXComponentManager *manager = instance.componentManager;
             if (!manager.isValid) {
@@ -244,7 +249,7 @@ _Pragma("clang diagnostic pop") \
             }
             [manager startComponentTasks];
             [manager updateStyles:stylesData forComponent:ref];
-            [WXTracingManager startTracingWithInstanceId:instanceId ref:ref 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"updateStyles" 
options:nil];
+            
         });
         
         return 0;
@@ -302,15 +307,17 @@ _Pragma("clang diagnostic pop") \
         if(![weakSelf checkInstance:instance]) {
             return -1;
         }
-        
+        [WXTracingManager startTracingWithInstanceId:instanceId ref:nil 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"createFinish" 
options:@{@"threadName":WXTJSBridgeThread}];
         WXPerformBlockOnComponentThread(^{
             WXComponentManager *manager = instance.componentManager;
             if (!manager.isValid) {
                 return;
             }
+            [WXTracingManager startTracingWithInstanceId:instanceId ref:nil 
className:nil name:WXTDomCall phase:WXTracingBegin functionName:@"createFinish" 
options:@{@"threadName":WXTDOMThread}];
             [manager startComponentTasks];
             [manager createFinish];
-            [WXTracingManager startTracingWithInstanceId:instanceId ref:nil 
className:nil name:WXTJSCall phase:WXTracingEnd functionName:@"createFinish" 
options:nil];
+            [WXTracingManager startTracingWithInstanceId:instanceId ref:nil 
className:nil name:WXTDomCall phase:WXTracingEnd functionName:@"createFinish" 
options:@{@"threadName":WXTDOMThread}];
+            
         });
         
         return 0;
@@ -398,7 +405,7 @@ _Pragma("clang diagnostic pop") \
             NSString *moduleName = task[@"module"];
             NSDictionary *options = task[@"options"];
             WXModuleMethod *method = [[WXModuleMethod alloc] 
initWithModuleName:moduleName methodName:methodName arguments:arguments 
options:options instance:instance];
-            [WXTracingManager startTracingWithInstanceId:instanceId ref:nil 
className:nil name:task[@"module"] phase:WXTracingBegin 
functionName:task[@"method"] options:nil];
+            [WXTracingManager startTracingWithInstanceId:instanceId ref:nil 
className:nil name:task[@"module"] phase:WXTracingBegin 
functionName:task[@"method"] options:@{@"threadName":WXTJSBridgeThread}];
             [method invoke];
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m 
b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
index 13d8578..09dc9d8 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
@@ -207,7 +207,7 @@
         NSDictionary *componentData = [element toDictionary];
         NSString *parentRef = [ref toString];
         NSInteger insertIndex = [[index toNumber] integerValue];
-        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:componentData[@"ref"] className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"addElement" options:nil];
+        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:componentData[@"ref"] className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"addElement" options:@{@"threadName":WXTJSBridgeThread}];
          WXLogDebug(@"callAddElement...%@, %@, %@, %ld", instanceIdString, 
parentRef, componentData, (long)insertIndex);
         
         return [JSValue 
valueWithInt32:(int32_t)callAddElement(instanceIdString, parentRef, 
componentData, insertIndex) inContext:[JSContext currentContext]];
@@ -224,7 +224,7 @@
         NSDictionary *bodyData = [body toDictionary];
         
         WXLogDebug(@"callCreateBody...%@, %@,", instanceIdString, bodyData);
-        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:bodyData[@"ref"] className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"createBody" options:nil];
+        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:bodyData[@"ref"] className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"createBody" options:@{@"threadName":WXTJSBridgeThread}];
         return [JSValue 
valueWithInt32:(int32_t)callCreateBody(instanceIdString, bodyData) 
inContext:[JSContext currentContext]];
     };
     
@@ -272,7 +272,7 @@
         NSDictionary *attrsData = [attrs toDictionary];
         
         WXLogDebug(@"callUpdateAttrs...%@, %@, %@", instanceIdString, 
refString,attrsData);
-        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:refString className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"updateAttrs" options:nil];
+        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:refString className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"updateAttrs" options:@{@"threadName":WXTJSBridgeThread}];
         return [JSValue 
valueWithInt32:(int32_t)callUpdateAttrs(instanceIdString, refString,attrsData) 
inContext:[JSContext currentContext]];
     };
     
@@ -288,7 +288,7 @@
         NSDictionary *stylessData = [styles toDictionary];
         
         WXLogDebug(@"callUpdateStyle...%@, %@, %@", instanceIdString, 
refString,stylessData);
-        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:refString className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"updateStyle" options:nil];
+        [WXTracingManager startTracingWithInstanceId:instanceIdString 
ref:refString className:nil name:WXTJSCall phase:WXTracingBegin 
functionName:@"updateStyle" options:@{@"threadName":WXTJSBridgeThread}];
         return [JSValue 
valueWithInt32:(int32_t)callUpdateStyle(instanceIdString, 
refString,stylessData) inContext:[JSContext currentContext]];
     };
     
@@ -334,7 +334,7 @@
         NSString *instanceIdString = [instanceId toString];
         
         WXLogDebug(@"callRCreateFinish...%@", instanceIdString);
-        [WXTracingManager startTracingWithInstanceId:instanceIdString ref:nil 
className:nil name:WXTJSCall phase:WXTracingBegin functionName:@"createFinish" 
options:nil];
+        [WXTracingManager startTracingWithInstanceId:instanceIdString ref:nil 
className:nil name:WXTJSCall phase:WXTracingBegin functionName:@"createFinish" 
options:@{@"threadName":WXTJSBridgeThread}];
         return [JSValue 
valueWithInt32:(int32_t)callCreateFinish(instanceIdString) inContext:[JSContext 
currentContext]];
     };
         

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m 
b/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m
index 07762ed..0bf5aca 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m
@@ -28,6 +28,7 @@
 #import "WXResourceRequest.h"
 #import "WXResourceLoader.h"
 #import "WXDebugTool.h"
+#import "WXTracingManager.h"
 
 @interface WXBridgeManager ()
 
@@ -143,10 +144,13 @@ void WXPerformBlockOnBridgeThread(void (^block)())
     }
     __weak typeof(self) weakSelf = self;
     WXPerformBlockOnBridgeThread(^(){
+        [WXTracingManager startTracingWithInstanceId:instance ref:nil 
className:nil name:WXTExecJS phase:WXTracingBegin 
functionName:@"createInstance" options:@{@"threadName":WXTJSBridgeThread}];
         [weakSelf.bridgeCtx createInstance:instance
                                   template:temp
                                    options:options
                                       data:data];
+        [WXTracingManager startTracingWithInstanceId:instance ref:nil 
className:nil name:WXTExecJS phase:WXTracingEnd functionName:@"createInstance" 
options:@{@"threadName":WXTJSBridgeThread}];
+        
     });
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.h 
b/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.h
index 9ff7034..f2d2f6a 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.h
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.h
@@ -37,6 +37,7 @@
 + (void)registerComponents:(NSArray *)components;
 
 + (NSMutableDictionary *)componentMethodMapsWithName:(NSString *)name;
++ (NSMutableDictionary *)componentSelectorMapsWithName:(NSString *)name;
 
 + (SEL)methodWithComponentName:(NSString *)name withMethod:(NSString *)method;
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.m 
b/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.m
index aa79bad..6970376 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.m
@@ -114,6 +114,11 @@
     return [[self sharedInstance] _componentMethodMapsWithName:name];
 }
 
++ (NSMutableDictionary *)componentSelectorMapsWithName:(NSString *)name
+{
+    return [[self sharedInstance] _componentSelectorMapsWithName:name];
+}
+
 #pragma mark Private
 
 - (NSMutableDictionary *)_componentMethodMapsWithName:(NSString *)name
@@ -134,6 +139,24 @@
     return dict;
 }
 
+- (NSMutableDictionary *)_componentSelectorMapsWithName:(NSString *)name
+{
+    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
+    NSMutableArray *methods = [NSMutableArray array];
+    
+    [_configLock lock];
+    [dict setValue:methods forKey:@"methods"];
+    
+    WXComponentConfig *config = _componentConfigs[name];
+    void (^mBlock)(id, id, BOOL *) = ^(id mKey, id mObj, BOOL * mStop) {
+        [methods addObject:mObj];
+    };
+    [config.asyncMethods enumerateKeysAndObjectsUsingBlock:mBlock];
+    [_configLock unlock];
+    
+    return dict;
+}
+
 - (SEL)_methodWithComponetName:(NSString *)name withMethod:(NSString *)method
 {
     WXAssert(name && method, @"Fail to find selector with module name and 
method, please check if the parameters are correct !");

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m 
b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
index 5513b64..76a8cf3 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
@@ -206,9 +206,11 @@ static NSThread *WXComponentThread;
     [self _initRootCSSNode];
     __weak typeof(self) weakSelf = self;
     [self _addUITask:^{
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:data[@"ref"] 
className:nil name:data[@"type"] phase:WXTracingBegin 
functionName:@"createBody" options:@{@"threadName":WXTUIThread}];
         __strong typeof(self) strongSelf = weakSelf;
         strongSelf.weexInstance.rootView.wx_component = 
strongSelf->_rootComponent;
         [strongSelf.weexInstance.rootView 
addSubview:strongSelf->_rootComponent.view];
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:data[@"ref"] 
className:nil name:data[@"type"] phase:WXTracingEnd functionName:@"createBody" 
options:@{@"threadName":WXTUIThread}];
     }];
 }
 
@@ -257,9 +259,11 @@ static css_node_t * rootNodeGetChild(void *context, int i)
         component->_lazyCreateView = YES;
     }
 
+    __weak typeof(self) weakSelf = self;
     [self _addUITask:^{
-        
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId 
ref:componentData[@"ref"] className:nil name:componentData[@"type"] 
phase:WXTracingBegin functionName:@"addElement" 
options:@{@"threadName":WXTUIThread}];
         [supercomponent insertSubview:component atIndex:index];
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId 
ref:componentData[@"ref"] className:nil name:componentData[@"type"] 
phase:WXTracingEnd functionName:@"addElement" 
options:@{@"threadName":WXTUIThread}];
     }];
 
     NSArray *subcomponentsData = [componentData valueForKey:@"children"];
@@ -293,9 +297,11 @@ static css_node_t * rootNodeGetChild(void *context, int i)
     }
     
     [component _moveToSupercomponent:newSupercomponent atIndex:index];
-    
+    __weak typeof(self) weakSelf = self;
     [self _addUITask:^{
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:ref 
className:nil name:nil phase:WXTracingBegin functionName:@"addElement" 
options:@{@"threadName":WXTUIThread}];
         [component moveToSuperview:newSupercomponent atIndex:index];
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:ref 
className:nil name:nil phase:WXTracingEnd functionName:@"addElement" 
options:@{@"threadName":WXTUIThread}];
     }];
 }
 
@@ -311,11 +317,14 @@ static css_node_t * rootNodeGetChild(void *context, int i)
     
     [_indexDict removeObjectForKey:ref];
     
+    __weak typeof(self) weakSelf = self;
     [self _addUITask:^{
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:ref 
className:nil name:nil phase:WXTracingBegin functionName:@"removeElement" 
options:@{@"threadName":WXTUIThread}];
         if (component.supercomponent) {
             [component.supercomponent willRemoveSubview:component];
         }
         [component removeFromSuperview];
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:ref 
className:nil name:nil phase:WXTracingEnd functionName:@"removeElement" 
options:@{@"threadName":WXTUIThread}];
     }];
     
     [self _checkFixedSubcomponentToRemove:component];
@@ -444,9 +453,12 @@ static css_node_t * rootNodeGetChild(void *context, int i)
     WXAssertComponentExist(component);
     
     [component _updateAttributesOnComponentThread:attributes];
+    __weak typeof(self) weakSelf = self;
     [self _addUITask:^{
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:ref 
className:nil name:nil phase:WXTracingBegin functionName:@"updateAttrs" 
options:@{@"threadName":WXTUIThread}];
         [component _updateAttributesOnMainThread:attributes];
         [component readyToRender];
+        [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:ref 
className:nil name:nil phase:WXTracingEnd functionName:@"updateAttrs" 
options:@{@"threadName":WXTUIThread}];
     }];
 }
 
@@ -522,7 +534,7 @@ static css_node_t * rootNodeGetChild(void *context, int i)
         WX_MONITOR_SUCCESS(WXMTNativeRender);
         
         if(instance.renderFinish){
-            [WXTracingManager startTracingWithInstanceId:instance.instanceId 
ref:nil className:nil name:nil phase:WXTracingInstant 
functionName:WXTRenderFinish options:nil];
+            [WXTracingManager startTracingWithInstanceId:instance.instanceId 
ref:nil className:nil name:nil phase:WXTracingInstant 
functionName:WXTRenderFinish options:@{@"threadName":WXTUIThread}];
             instance.renderFinish(rootView);
         }
     }];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.h 
b/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.h
index c4c13fc..53e6f0d 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.h
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.h
@@ -56,6 +56,12 @@
  **/
 + (NSMutableDictionary *)moduleMethodMapsWithName:(NSString *)name;
 
+/**
+ * @abstract Returns the export Selector in the specific module
+ *
+ * @param name The Selector name
+ **/
++ (NSMutableDictionary *)moduleSelectorMapsWithName:(NSString *)name;
 
 /**
  * @abstract Returns the registered modules.

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.m 
b/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.m
index a2b9963..6a05afd 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.m
@@ -152,6 +152,25 @@ static WXModuleFactory *_sharedInstance = nil;
     return dict;
 }
 
+- (NSMutableDictionary *)_moduleSelctorMapsWithName:(NSString *)name
+{
+    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
+    NSMutableArray *methods = [self _defaultModuleMethod];
+    
+    [_moduleLock lock];
+    [dict setValue:methods forKey:name];
+    
+    WXModuleConfig *config = _moduleMap[name];
+    void (^mBlock)(id, id, BOOL *) = ^(id mKey, id mObj, BOOL * mStop) {
+        [methods addObject:mObj];
+    };
+    [config.syncMethods enumerateKeysAndObjectsUsingBlock:mBlock];
+    [config.asyncMethods enumerateKeysAndObjectsUsingBlock:mBlock];
+    [_moduleLock unlock];
+    
+    return dict;
+}
+
 // module common method
 - (NSMutableArray*)_defaultModuleMethod
 {
@@ -196,4 +215,9 @@ static WXModuleFactory *_sharedInstance = nil;
     return [[self _sharedInstance] _moduleMethodMapsWithName:name];
 }
 
++ (NSMutableDictionary *)moduleSelectorMapsWithName:(NSString *)name
+{
+    return [[self _sharedInstance] _moduleSelctorMapsWithName:name];
+}
+
 @end

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.h 
b/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.h
index f2becd2..9c3634e 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.h
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.h
@@ -20,11 +20,17 @@
 #import <Foundation/Foundation.h>
 #import "WXSDKInstance.h"
 
-#define WXTNetworkHanding          @"loadjs"
-#define WXTExecJS                  @"execjs"
+#define WXTNetworkHanding          @"downloadBundleJS"
+#define WXTExecJS                  @"executeBundleJS"
 #define WXTJSCall                  @"jsCall"
+#define WXTDomCall                 @"domCall"
 #define WXTRender                  @"render"
-#define WXTRenderFinish            @"RenderFinish"
+#define WXTRenderFinish            @"renderFinish"
+
+#define WXTJSBridgeThread          @"JSThread"
+#define WXTDOMThread               @"DOMThread"
+#define WXTUIThread                @"UIThread"
+#define WXTMainThread              @"MainThread"
 
 #define WXTracingBegin             @"B"
 #define WXTracingEnd               @"E"
@@ -61,8 +67,9 @@ typedef enum : NSUInteger {
 @property (nonatomic) NSTimeInterval duration;
 @property (nonatomic, copy) NSString *fName; // functionName
 @property (nonatomic, copy) NSString *iid; // instance id
-@property (nonatomic, copy) NSString *parentId;// parent event id
+@property (nonatomic) long long parentId;// parent event id
 @property (nonatomic, copy) NSString *bundleUrl;
+@property (nonatomic, copy) NSString *threadName;
 -(NSDictionary *)dictionary;
 @end
 
@@ -112,6 +119,11 @@ typedef enum : NSUInteger {
 +(void)clearTracingData;
 
 /**
+ *  @discusstion  get current time
+ */
++(NSTimeInterval)getCurrentTime;
+
+/**
  *  @discusstion set bundle type
  *  @param jsBundleString the bundle source.
  *  @param iid the instance  id.

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.m 
b/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.m
index 732ec13..b4b19d5 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXTracingManager.m
@@ -31,7 +31,7 @@
 @implementation WXTracing
 
 -(NSDictionary *)dictionary {
-    return [NSDictionary 
dictionaryWithObjectsAndKeys:self.ref?:@"",@"ref",self.parentRef?:@"",@"parentRef",self.className?:@"",@"className",self.name?:@"",@"name",self.ph?:@"",@"ph",@(self.ts),@"ts",@(self.traceId),@"traceId",@(self.duration),@"duration",self.fName?:@"",@"fName",self.iid?:@"",@"iid",self.parentId?:@"",@"parentId",
 nil];
+    return [NSDictionary 
dictionaryWithObjectsAndKeys:self.ref?:@"",@"ref",self.parentRef?:@"",@"parentRef",self.className?:@"",@"className",self.name?:@"",@"name",self.ph?:@"",@"ph",@(self.ts),@"ts",@(self.traceId),@"traceId",@(self.duration),@"duration",self.fName?:@"",@"fName",self.iid?:@"",@"iid",@(self.parentId)?:0,@"parentId",self.threadName?:@"",@"tName",
 nil];
 }
 @end
 
@@ -147,15 +147,28 @@
     [WXTracingManager sharedInstance].tracingTasks = nil;
 }
 
++(NSTimeInterval)getCurrentTime
+{
+    if([self isTracing]){
+        return  [[NSDate date] timeIntervalSince1970]*1000;
+    }
+    return 0;
+}
+
 +(void)startTracingWithInstanceId:(NSString *)iid ref:(NSString*)ref 
className:(NSString *)className name:(NSString *)name phase:(NSString *)phase 
functionName:(NSString *)functionName options:(NSDictionary *)options
 {
     if([self isTracing]){
         WXTracing *tracing = [WXTracing new];
+        tracing.parentId = -1;
         if(ref.length>0){
             tracing.ref = ref;
+        }else {
+            tracing.ref = @"";
         }
         if(className.length>0){
             tracing.className = className;
+        }else {
+            tracing.className = @"";
         }
         if(name.length>0){
             tracing.name = name;
@@ -182,6 +195,9 @@
         if(options && options[@"bundleUrl"]){
             tracing.bundleUrl = options[@"bundleUrl"];
         }
+        if(options && options[@"threadName"]){
+            tracing.threadName = options[@"threadName"];
+        }
         [self startTracing:tracing];
     }
 }
@@ -210,7 +226,7 @@
     if(tracing.iid.length>0){
         newTracing.iid = tracing.iid;
     }
-    if(tracing.parentId.length>0){
+    if(tracing.parentId>0){
         newTracing.parentId = tracing.parentId;
     }
     if(tracing.traceId>0){
@@ -219,6 +235,9 @@
     if(tracing.ts>0){
         newTracing.ts = tracing.ts;
     }
+    if(tracing.threadName.length>0){
+        newTracing.threadName = tracing.threadName;
+    }
     return newTracing;
 }
 
@@ -237,12 +256,27 @@
     return  className;
 }
 
-+(void)updateTracings:(WXTracingTask *)task tracing:(WXTracing *)tracing
++(NSInteger )getParentId:(WXTracingTask *)task tracing:(WXTracing *)tracing
 {
-    if(![WXTJSCall isEqualToString:tracing.name]){
-        tracing.className = [self getclassName:tracing];
+    NSMutableArray *tracings = task.tracings;
+    if([tracing.threadName isEqualToString:WXTJSBridgeThread]) {
+        return -1;
     }
-    
+    if(tracings && [tracings count]>0){
+        for (NSInteger i = [tracings count] - 1; i >= 0; i--) {
+            WXTracing *t = tracings[i];
+            if([t.threadName isEqualToString:WXTJSBridgeThread]&& [t.ref 
isEqualToString:tracing.ref] && ([t.name isEqualToString:tracing.name] || 
[t.name isEqualToString:WXTJSCall])){
+                if([t.fName isEqualToString:tracing.fName]){
+                    return t.traceId;
+                }
+            }
+        }
+    }
+    return -1;
+}
+
++(void)updateTracings:(WXTracingTask *)task tracing:(WXTracing *)tracing
+{
     if([WXTNetworkHanding isEqualToString:task.tag]){
         if([WXTExecJS isEqualToString:tracing.name]){
             NSMutableArray *tracings = task.tracings;
@@ -262,24 +296,24 @@
         }
     }
     
-    if([WXTExecJS isEqualToString:task.tag]){
-        if([WXTJSCall isEqualToString:tracing.name]){
-            NSMutableArray *tracings = task.tracings;
-            [tracings enumerateObjectsWithOptions:NSEnumerationReverse 
usingBlock:^(WXTracing *bTracing, NSUInteger idx, BOOL *stop) {
-                if(([WXTExecJS isEqualToString:bTracing.name] || [bTracing.ref 
isEqualToString:tracing.ref])&&[WXTracingBegin isEqualToString:bTracing.ph]){
-                    WXTracing *newTracing = [self copyTracing:bTracing];
-                    newTracing.iid = tracing.iid;
-                    newTracing.ph = WXTracingEnd;
-                    newTracing.ts = tracing.ts ;
-                    newTracing.duration = newTracing.ts - bTracing.ts ;
-                    bTracing.duration = newTracing.duration;
-                    [task.tracings addObject:newTracing];
-                    *stop = YES;
-                }
-            }];
-            task.tag = WXTRender;
-        }
-    }
+//    if([WXTExecJS isEqualToString:task.tag]){
+//        if([WXTJSCall isEqualToString:tracing.name]){
+//            NSMutableArray *tracings = task.tracings;
+//            [tracings enumerateObjectsWithOptions:NSEnumerationReverse 
usingBlock:^(WXTracing *bTracing, NSUInteger idx, BOOL *stop) {
+//                if(([WXTExecJS isEqualToString:bTracing.name] || 
[bTracing.ref isEqualToString:tracing.ref])&&[WXTracingBegin 
isEqualToString:bTracing.ph]){
+//                    WXTracing *newTracing = [self copyTracing:bTracing];
+//                    newTracing.iid = tracing.iid;
+//                    newTracing.ph = WXTracingEnd;
+//                    newTracing.ts = tracing.ts ;
+//                    newTracing.duration = newTracing.ts - bTracing.ts ;
+//                    bTracing.duration = newTracing.duration;
+//                    [task.tracings addObject:newTracing];
+//                    *stop = YES;
+//                }
+//            }];
+//            task.tag = WXTRender;
+//        }
+//    }
     
     if([WXTracingBegin isEqualToString:tracing.ph]){
         if(tracing.ref.length>0){
@@ -292,8 +326,20 @@
                 if(com.supercomponent){
                     tracing.parentRef = com.supercomponent.ref;
                 }
+                tracing.name = com.type;
+                if(tracing.parentId == -1){
+                    tracing.parentId = [self getParentId:task tracing:tracing];
+                }
+                if(tracing.className.length == 0){
+                    tracing.className = [self getclassName:tracing];
+                }
             });
+        } else {
+            if(tracing.parentId == -1){
+                tracing.parentId = [self getParentId:task tracing:tracing];
+            }
         }
+    
     }
     if([WXTracingEnd isEqualToString:tracing.ph]){  // deal end
         NSMutableArray *tracings = task.tracings;
@@ -304,7 +350,7 @@
                 }
             }
             
-            if([bTracing.fName isEqualToString:tracing.fName] 
&&[WXTracingBegin isEqualToString:bTracing.ph]){
+            if([bTracing.fName isEqualToString:tracing.fName] 
&&[WXTracingBegin isEqualToString:bTracing.ph] ){
                 tracing.iid = bTracing.iid;
                 if(bTracing.ref.length > 0){
                     tracing.ref = bTracing.ref;
@@ -312,9 +358,12 @@
                 if(bTracing.parentRef.length > 0){
                     tracing.parentRef = bTracing.parentRef;
                 }
+                tracing.parentId = bTracing.parentId;
                 tracing.duration = tracing.ts - bTracing.ts ;
                 tracing.traceId = bTracing.traceId;
+                tracing.threadName = bTracing.threadName;
                 bTracing.duration = tracing.duration;
+                tracing.name = bTracing.name;
                 *stop = YES;
             }
         }];
@@ -327,6 +376,7 @@
     if(![self isTracing]){
         return nil;
     }
+    
     return [WXTracingManager sharedInstance].tracingTasks;
 }
 
@@ -342,7 +392,7 @@
     NSDictionary *componentConfigs = [WXComponentFactory componentConfigs];
     void (^componentBlock)(id, id, BOOL *) = ^(id mKey, id mObj, BOOL * mStop) 
{
         NSMutableDictionary *componentConfig = [mObj mutableCopy];
-        NSDictionary *cDict = [WXComponentFactory 
componentMethodMapsWithName:componentConfig[@"name"]];
+        NSDictionary *cDict = [WXComponentFactory 
componentSelectorMapsWithName:componentConfig[@"name"]];
         if(cDict && [cDict count]>0 && [cDict[@"methods"] count]>0){
             [componentConfig setObject:cDict[@"methods"] forKey:@"methods"];
         }
@@ -354,7 +404,7 @@
     }
     NSDictionary *moduleConfigs = [WXModuleFactory moduleConfigs];
     void (^moduleBlock)(id, id, BOOL *) = ^(id mKey, id mObj, BOOL * mStop) {
-        NSDictionary *mDict = [WXModuleFactory moduleMethodMapsWithName:mKey];
+        NSDictionary *mDict = [WXModuleFactory 
moduleSelectorMapsWithName:mKey];
         NSMutableDictionary *subDict = [NSMutableDictionary new];
         [subDict setObject:mKey forKey:@"name"];
         [subDict setObject:mObj forKey:@"class"];

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m 
b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
index bd5549b..d8da1a3 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
@@ -126,7 +126,6 @@
         [self _initCompositingAttribute:_attributes];
         [self _handleBorders:styles isUpdating:NO];
         
-        [WXTracingManager 
startTracingWithInstanceId:self.weexInstance.instanceId ref:ref className:nil 
name:type phase:WXTracingBegin functionName:WXTRender options:nil];
     }
     
     return self;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m 
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index c527ae1..9516b55 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -147,7 +147,7 @@ typedef enum : NSUInteger {
     
     WXResourceRequest *request = [WXResourceRequest requestWithURL:url 
resourceType:WXResourceTypeMainBundle referrer:@"" 
cachePolicy:NSURLRequestUseProtocolCachePolicy];
     [self _renderWithRequest:request options:options data:data];
-    [WXTracingManager startTracingWithInstanceId:self.instanceId ref:nil 
className:nil name:WXTNetworkHanding phase:WXTracingBegin 
functionName:@"renderWithURL" options:@{@"bundleUrl":url?[url 
absoluteString]:@""}];
+    [WXTracingManager startTracingWithInstanceId:self.instanceId ref:nil 
className:nil name:WXTNetworkHanding phase:WXTracingBegin 
functionName:@"renderWithURL" options:@{@"bundleUrl":url?[url 
absoluteString]:@"",@"threadName":WXTMainThread}];
 }
 
 - (void)renderView:(NSString *)source options:(NSDictionary *)options 
data:(id)data
@@ -202,9 +202,9 @@ typedef enum : NSUInteger {
     
     [self _handleConfigCenter];
     
+    [WXTracingManager startTracingWithInstanceId:self.instanceId ref:nil 
className:nil name:WXTExecJS phase:WXTracingBegin 
functionName:@"renderWithMainBundleString" 
options:@{@"threadName":WXTMainThread}];
     [[WXSDKManager bridgeMgr] createInstance:self.instanceId 
template:mainBundleString options:dictionary data:_jsData];
-    
-    [WXTracingManager startTracingWithInstanceId:self.instanceId ref:nil 
className:nil name:WXTExecJS phase:WXTracingBegin 
functionName:@"renderWithMainBundleString" 
options:@{@"bundleUrl":self.scriptURL?[self.scriptURL absoluteString]:@""}];
+    [WXTracingManager startTracingWithInstanceId:self.instanceId ref:nil 
className:nil name:WXTExecJS phase:WXTracingEnd 
functionName:@"renderWithMainBundleString" 
options:@{@"threadName":WXTMainThread}];
     
     WX_MONITOR_PERF_SET(WXPTBundleSize, [mainBundleString 
lengthOfBytesUsingEncoding:NSUTF8StringEncoding], self);
 }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4b80dac2/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m 
b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
index 40e9889..8bbdc06 100644
--- a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
+++ b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
@@ -138,7 +138,6 @@ do {\
 
 - (void)viewDidLoad
 {
-    [WXTracingManager startTracingWithInstanceId:self.weexInstance.instanceId 
ref:self.ref className:nil name:_type phase:WXTracingEnd functionName:WXTRender 
options:nil];
     WXAssertMainThread();
 }
 


Reply via email to