Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
*[iOS][WEEX-660]add component ignoreInteraction flag (bad case addEle…
Browse files Browse the repository at this point in the history
…ment onScreen with loop) (#1750)

use method CGRectIntersectsRect
  • Loading branch information
lucky-chen authored and cxfeng1 committed Nov 13, 2018
1 parent 0dc92f3 commit a1f6823
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
7 changes: 7 additions & 0 deletions ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#import "WXRootView.h"
#import "WXComponent+Layout.h"
#import "WXCoreBridge.h"
#import "WXComponent_performance.h"

static NSThread *WXComponentThread;

Expand Down Expand Up @@ -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:%@",
Expand Down
3 changes: 2 additions & 1 deletion ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

@interface WXComponent()

@property (nonatomic,assign) bool hasAdd;
@property (nonatomic,assign) BOOL hasAdd;
@property (nonatomic,assign) BOOL ignoreInteraction;

@end
17 changes: 8 additions & 9 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ @interface WXApmForInstance ()
BOOL _hasRecordInteractionTime;
BOOL _hasRecordDownLoadStart;
BOOL _hasRecordDownLoadEnd;
BOOL _forceRecordInteractionTime;
}

@property (nonatomic,strong) id<WXApmProtocol> apmProtocolInstance;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -487,5 +491,11 @@ - (NSString*) templateInfo
return info;
}

- (void) forceSetInteractionTime:(long) unixTime
{
[self onStageWithTime:KEY_PAGE_STAGES_INTERACTION time:unixTime];
_forceRecordInteractionTime=YES;
}

@end

0 comments on commit a1f6823

Please sign in to comment.