cxfeng1 closed pull request #1750: [WEEX-660][iOS]add component 
ignoreInteraction flag (bad case addEle…
URL: https://github.com/apache/incubator-weex/pull/1750
 
 
   

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/Manager/WXComponentManager.mm 
b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
index e9b1733e7f..434ef36dad 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
@@ -40,6 +40,7 @@
 #import "WXRootView.h"
 #import "WXComponent+Layout.h"
 #import "WXCoreBridge.h"
+#import "WXComponent_performance.h"
 
 static NSThread *WXComponentThread;
 
@@ -279,6 +280,12 @@ - (void)addComponent:(NSString*)ref
     } else {
         index = (index == -1 ? supercomponent->_subcomponents.count : index);
     }
+    if (supercomponent.ignoreInteraction) {
+        component.ignoreInteraction = YES;
+    }
+    if ([[component.attributes objectForKey:@"ignoreInteraction"] 
isEqualToString:@"1"]) {
+        component.ignoreInteraction = YES;
+    }
     
 #ifdef DEBUG
     WXLogDebug(@"flexLayout -> _recursivelyAddComponent : 
super:(%@,%@):[%f,%f] ,child:(%@,%@):[%f,%f],childClass:%@",
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h 
b/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
index 17153ee160..bbc18cf4e1 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
@@ -21,6 +21,7 @@
 
 @interface WXComponent()
 
-@property (nonatomic,assign) bool hasAdd;
+@property (nonatomic,assign) BOOL hasAdd;
+@property (nonatomic,assign) BOOL ignoreInteraction;
 
 @end
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m 
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
index 49da81345e..a8002b9fab 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
@@ -70,6 +70,9 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent 
withModifyTime:(double)
     if (nil == targetComponent) {
         return;
     }
+    if (targetComponent.ignoreInteraction) {
+        return;
+    }
     double diff = modifyTime - self.renderTimeOrigin;
     if (diff > 8000) {
         return;
@@ -85,11 +88,8 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent 
withModifyTime:(double)
     
     CGRect absoluteFrame = [targetComponent.view.superview 
convertRect:targetComponent.view.frame 
toView:targetComponent.weexInstance.rootView];
     CGRect rootFrame = targetComponent.weexInstance.rootView.frame;
-    CGPoint leftTop = absoluteFrame.origin;
-    CGPoint rightBottom = 
CGPointMake(absoluteFrame.origin.x+absoluteFrame.size.width, 
absoluteFrame.origin.y+absoluteFrame.size.height);
-
     
-    if (!self.hasRecordFsRenderTimeByPosition && rightBottom.y > 
rootFrame.size.height +1 && ![self _isViewGroup:targetComponent] ) {
+    if (!self.hasRecordFsRenderTimeByPosition && 
absoluteFrame.origin.y+absoluteFrame.size.height > rootFrame.size.height +1 && 
![self _isViewGroup:targetComponent] ) {
         self.newFsRenderTime = diff;
         self.hasRecordFsRenderTimeByPosition = true;
         [targetComponent.weexInstance.apmInstance 
onStage:KEY_PAGE_STAGES_NEW_FSRENDER];
@@ -107,18 +107,17 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent 
withModifyTime:(double)
         return;
     }
     
-    bool inScreen = CGRectContainsPoint(rootFrame, leftTop) || 
CGRectContainsPoint(rootFrame, rightBottom);
+    bool inScreen = CGRectIntersectsRect(rootFrame, absoluteFrame);
     if (!inScreen) {
         return;
     }
     
 #ifdef DEBUG
-    WXLogDebug(@"onElementChange _-> size, count :%f,inScreen:%d,  
lefttop:%@,rightBottom:%@, rootFrame:%@",
+    WXLogDebug(@"onElementChange _-> size, count :%f,inScreen:%d, 
type:%@,attr:%@",
           self.interactionAddCountRecord,
           inScreen,
-          NSStringFromCGPoint(leftTop),
-          NSStringFromCGPoint(rightBottom),
-          NSStringFromCGRect(targetComponent.weexInstance.rootView.frame)
+          targetComponent.type,
+          targetComponent.attributes
           );
 #endif
     if 
(!targetComponent.weexInstance.apmInstance.hasRecordFirstInterationView) {
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m 
b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
index 1abe38f83d..d7fafd7532 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
@@ -55,7 +55,7 @@ + (void)performancePoint:(WXPerformanceTag)tag 
didEndWithInstance:(WXSDKInstance
     NSMutableDictionary *performanceDict = [self 
performanceDictForInstance:instance];
     NSMutableDictionary *dict = performanceDict[@(tag)];
     if (!dict) {
-        WXLogError(@"Performance point:%ld, in instance:%@, did not have a 
start", (unsigned long)tag, instance.instanceId);
+        WXLogDebug(@"Performance point:%ld, in instance:%@, did not have a 
start", (unsigned long)tag, instance.instanceId);
         return;
     }
     
@@ -202,7 +202,7 @@ + (void)commitPerformanceWithDict:(NSMutableDictionary 
*)commitDict instance:(WX
         
         if (!start || !end) {
             if (state == MonitorCommit) {
-                WXLogWarning(@"Performance point:%d, in instance:%@, did not 
have a start or end", tag, instance);
+                WXLogDebug(@"Performance point:%d, in instance:%@, did not 
have a start or end", tag, instance);
             }
             continue;
         }
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h 
b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
index 455cbf6e93..e5fd690947 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
@@ -125,6 +125,7 @@ extern NSString* const VALUE_ERROR_CODE_DEFAULT;
 - (void) updateDiffStats:(NSString *)name withDiffValue:(double)diff;
 - (void) updateMaxStats:(NSString *)name curMaxValue:(double)maxValue;
 - (void) updateExtInfoFromResponseHeader:(NSDictionary*) extInfo;
+- (void) forceSetInteractionTime:(long) unixTime;
 
 
 #pragma mark - called by IWXHttpAdapter implementer
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m 
b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
index 5adeb011ee..0bd74e3dca 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
@@ -114,6 +114,7 @@ @interface WXApmForInstance ()
     BOOL _hasRecordInteractionTime;
     BOOL _hasRecordDownLoadStart;
     BOOL _hasRecordDownLoadEnd;
+    BOOL _forceRecordInteractionTime;
 }
 
 @property (nonatomic,strong) id<WXApmProtocol> apmProtocolInstance;
@@ -178,6 +179,9 @@ - (void) onStageWithTime:(NSString*)name time:(long)unixTime
     
     if ([KEY_PAGE_STAGES_INTERACTION isEqualToString:name]) {
         _hasRecordInteractionTime = YES;
+        if (_forceRecordInteractionTime) {
+            return;
+        }
     }
     [self.apmProtocolInstance onStage:name withValue:unixTime];
     __weak typeof(self) weakSelf = self;
@@ -487,5 +491,11 @@ - (NSString*) templateInfo
     return info;
 }
 
+- (void) forceSetInteractionTime:(long) unixTime
+{
+    [self onStageWithTime:KEY_PAGE_STAGES_INTERACTION time:unixTime];
+    _forceRecordInteractionTime=YES;
+}
+
 @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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to