You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2018/11/13 15:44:51 UTC
[incubator-weex] branch master updated: *[iOS][WEEX-660]add
component ignoreInteraction flag (bad case addElement onScreen with loop)
(#1750)
This is an automated email from the ASF dual-hosted git repository.
cxfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new a1f6823 *[iOS][WEEX-660]add component ignoreInteraction flag (bad case addElement onScreen with loop) (#1750)
a1f6823 is described below
commit a1f682395e132231056ecb960cd38ebf7f143b96
Author: chen <lu...@users.noreply.github.com>
AuthorDate: Tue Nov 13 23:44:46 2018 +0800
*[iOS][WEEX-660]add component ignoreInteraction flag (bad case addElement onScreen with loop) (#1750)
use method CGRectIntersectsRect
---
ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm | 7 +++++++
ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h | 3 ++-
.../WeexSDK/Sources/Model/WXSDKInstance_performance.m | 17 ++++++++---------
ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m | 4 ++--
ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h | 1 +
ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m | 10 ++++++++++
6 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
index e9b1733..434ef36 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 @@ static NSThread *WXComponentThread;
} 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 17153ee..bbc18cf 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 49da813..a8002b9 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
@@ -70,6 +70,9 @@
if (nil == targetComponent) {
return;
}
+ if (targetComponent.ignoreInteraction) {
+ return;
+ }
double diff = modifyTime - self.renderTimeOrigin;
if (diff > 8000) {
return;
@@ -85,11 +88,8 @@
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 @@
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 1abe38f..d7fafd7 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
@@ -55,7 +55,7 @@ static WXThreadSafeMutableDictionary *globalPerformanceDict;
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 @@ static WXThreadSafeMutableDictionary *globalPerformanceDict;
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 455cbf6..e5fd690 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 5adeb01..0bd74e3 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
@@ -114,6 +114,7 @@ NSString* const VALUE_ERROR_CODE_DEFAULT = @"0";
BOOL _hasRecordInteractionTime;
BOOL _hasRecordDownLoadStart;
BOOL _hasRecordDownLoadEnd;
+ BOOL _forceRecordInteractionTime;
}
@property (nonatomic,strong) id<WXApmProtocol> apmProtocolInstance;
@@ -178,6 +179,9 @@ NSString* const VALUE_ERROR_CODE_DEFAULT = @"0";
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* const VALUE_ERROR_CODE_DEFAULT = @"0";
return info;
}
+- (void) forceSetInteractionTime:(long) unixTime
+{
+ [self onStageWithTime:KEY_PAGE_STAGES_INTERACTION time:unixTime];
+ _forceRecordInteractionTime=YES;
+}
+
@end