Skip to content

Commit

Permalink
Merge branch 'merge_all_code' of gitlab.alibaba-inc.com:weex/weex int…
Browse files Browse the repository at this point in the history
…o merge_all_code

* 'merge_all_code' of gitlab.alibaba-inc.com:weex/weex:
  [WEEX-598][iOS] slider component can not request gesture stoppropagation (apache#1478)
  [WEEX-597][Android] fix can't get instance before render template for apm (apache#1477)
  [WEEX-596][iOS]fix report empty when too fast between render and destroy (apache#1476)
  [WEEX-595][Android] fix report empty when too fast between render(template) and destroy (apache#1475)
  • Loading branch information
东煜 committed Aug 28, 2018
2 parents a00c6fa + 2efe8f3 commit 12ef527
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void onStage(String name) {
* @param time unixTime ,plz use WXUtils.getFixUnixTime
*/
public void onStageWithTime(String name,long time){
WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
WXSDKInstance instance = WXSDKManager.getInstance().getAllInstanceMap().get(mInstanceId);
if (null != instance){
instance.getExceptionRecorder().recordStage(name, time);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,26 @@ public void checkEmptyScreenAndReport() {
return;
}
//2s limit of instance stayTime (case in\quit very fast case)
final long DIFF_LIMIT = 2000;
long useTime = 2001;
final long DIFF_LIMIT_FROM_RENDER_URL = 2000;
final long DIFF_LIMIT_FROM_RENDER_TEMPLATE = 1000;

long curTime = WXUtils.getFixUnixTime();
Long startRequestTime = mStageMap.get(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START);
long useTime;
String useTimeForm;
boolean shouldReportByUseTime;
if (null != startRequestTime) {
useTime = WXUtils.getFixUnixTime() - startRequestTime;
useTime = curTime - startRequestTime;
shouldReportByUseTime = useTime >= DIFF_LIMIT_FROM_RENDER_URL;
useTimeForm = WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START;
}else {
Long startRenderTemplateTime = mStageMap.get(WXInstanceApm.KEY_PAGE_STAGES_RENDER_ORGIGIN);
useTime = null != startRenderTemplateTime?curTime - startRenderTemplateTime:curTime;
shouldReportByUseTime = useTime >= DIFF_LIMIT_FROM_RENDER_TEMPLATE;
useTimeForm = WXInstanceApm.KEY_PAGE_STAGES_RENDER_ORGIGIN;
}
if (useTime < DIFF_LIMIT) {

if (!shouldReportByUseTime){
return;
}

Expand All @@ -164,6 +177,7 @@ public void checkEmptyScreenAndReport() {
flagMap.put("wxHasDegrade",String.valueOf(hasDegrade.get()));
flagMap.put("wxHasReportScreenEmpty",String.valueOf(mHasReportScreenEmpty));
flagMap.put("wxUseTime", String.valueOf(useTime));
flagMap.put("wxUseTimeForm", useTimeForm);

WXExceptionUtils.commitCriticalExceptionRT(
instanceId,
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@
- (void)setIndicatorView:(WXIndicatorView *)indicatorView;

@end
@interface WXRecycleSliderScrollView: UIScrollView
@end

28 changes: 24 additions & 4 deletions ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import "WXSDKManager.h"
#import "WXUtility.h"
#import "WXComponent+Layout.h"
#import "WXComponent+Events.h"

typedef NS_ENUM(NSInteger, Direction) {
DirectionNone = 1 << 0,
Expand All @@ -40,15 +41,16 @@ - (void)recycleSliderView:(WXRecycleSliderView *)recycleSliderView didScroll:(UI
- (void)recycleSliderView:(WXRecycleSliderView *)recycleSliderView didScrollToItemAtIndex:(NSInteger)index;
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
- (BOOL)requestGestureShouldStopPropagation:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;

@end


@interface WXRecycleSliderView : UIView <UIScrollViewDelegate>

@property (nonatomic, strong) WXIndicatorView *indicator;
@property (nonatomic, weak) id<WXRecycleSliderViewDelegate> delegate;

@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) WXRecycleSliderScrollView *scrollView;
@property (nonatomic, strong) NSMutableArray *itemViews;
@property (nonatomic, assign) Direction direction;
@property (nonatomic, assign) NSInteger currentIndex;
Expand All @@ -70,7 +72,7 @@ - (id)initWithFrame:(CGRect)frame
if (self) {
_currentIndex = 0;
_itemViews = [[NSMutableArray alloc] init];
_scrollView = [[UIScrollView alloc] init];
_scrollView = [[WXRecycleSliderScrollView alloc] init];
_scrollView.backgroundColor = [UIColor clearColor];
_scrollView.delegate = self;
_scrollView.showsHorizontalScrollIndicator = NO;
Expand Down Expand Up @@ -256,7 +258,6 @@ - (void)nextPage {

- (void)lastPage
{

NSInteger lastIndex = [self currentIndex]-1;
if (_itemViews.count > 1) {
if (_infinite) {
Expand Down Expand Up @@ -589,6 +590,11 @@ - (void)removeEvent:(NSString *)eventName
}
}

- (BOOL)requestGestureShouldStopPropagation:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return [self gestureShouldStopPropagation:gestureRecognizer shouldReceiveTouch:touch];
}

#pragma mark WXIndicatorComponentDelegate Methods

-(void)setIndicatorView:(WXIndicatorView *)indicatorView
Expand Down Expand Up @@ -679,3 +685,17 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
}

@end

@implementation WXRecycleSliderScrollView
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
WXRecycleSliderView *view = (WXRecycleSliderView *)self.delegate;
if ([(id <WXRecycleSliderViewDelegate>) view.wx_component respondsToSelector:@selector(requestGestureShouldStopPropagation:shouldReceiveTouch:)]) {
return [(id <WXRecycleSliderViewDelegate>) view.wx_component requestGestureShouldStopPropagation:gestureRecognizer shouldReceiveTouch:touch];
}
else{
return YES;
}
}
@end

2 changes: 1 addition & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ - (void)viewDidLoad
{
[super viewDidLoad];
[self setContentSize:_contentSize];
WXScrollerComponentView* scrollView = (WXScrollerComponentView *)self.view;
WXScrollerComponentView *scrollView = (WXScrollerComponentView *)self.view;
scrollView.delegate = self;
scrollView.exclusiveTouch = YES;
scrollView.autoresizesSubviews = NO;
Expand Down
67 changes: 48 additions & 19 deletions ios/sdk/WeexSDK/Sources/Performance/WXInstanceApm.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,27 +343,56 @@ - (void) _checkScreenEmptyAndReport
if(self.hasAddView || !self.isStartRender || self.isDegrade){
return;
}
WXSDKErrCode code = WX_KEY_EXCEPTION_EMPTY_SCREEN_NATIVE;


NSNumberFormatter *formater = [[NSNumberFormatter alloc] init];
formater.numberStyle = NSNumberFormatterDecimalStyle;

for (WXJSExceptionInfo* exception in self.errorList) {
NSNumber *codeNumber = [formater numberFromString:exception.errorCode];
if (nil == codeNumber) {
continue;
__weak WXApmForInstance* weakSelf = self;
WXPerformBlockOnComponentThread(^{
__strong WXApmForInstance* strongSelf = weakSelf;
if (nil == strongSelf) {
return;
}
WXSDKErrorGroup group = [WXSDKErrCodeUtil getErrorGroupByCode:codeNumber.intValue];
if(group == WX_JS){
code = WX_KEY_EXCEPTION_EMPTY_SCREEN_JS;
break;

NSInteger LIMIT_TIME_FROM_RENDER_URL = 2000;
NSInteger LIMIT_TIME_FROM_RENDER_TEMPLATE = 1000;

long curTime = [WXUtility getUnixFixTimeMillis];
BOOL sholudReportByTime;
long useTime;
NSString* useTimeFrom;

NSNumber* startTime = [strongSelf.stageDic objectForKey:KEY_PAGE_STAGES_DOWN_BUNDLE_START];
if (nil != startTime) {
useTime = curTime - startTime.longValue;
useTimeFrom = KEY_PAGE_STAGES_DOWN_BUNDLE_START;
sholudReportByTime = useTime > LIMIT_TIME_FROM_RENDER_URL;
}else{
startTime = [strongSelf.stageDic objectForKey:KEY_PAGE_STAGES_RENDER_ORGIGIN];
useTime = nil != startTime ? curTime -startTime.longValue : curTime;
useTimeFrom = KEY_PAGE_STAGES_RENDER_ORGIGIN;
sholudReportByTime = useTime > LIMIT_TIME_FROM_RENDER_TEMPLATE;
}
}
NSString *codeStr = [NSString stringWithFormat:@"%d",code];
[WXExceptionUtils commitCriticalExceptionRT:self.instanceId errCode:codeStr function:@"_checkScreenEmptyAndReport"
exception:[self _convertTopExceptionListToStr] extParams:nil];


if (!sholudReportByTime) {
return;
}

WXSDKErrCode code = WX_KEY_EXCEPTION_EMPTY_SCREEN_NATIVE;
for (WXJSExceptionInfo* exception in strongSelf.errorList) {
WXSDKErrorGroup group = [WXSDKErrCodeUtil getErrorGroupByCode:exception.errorCode.intValue];
if(group == WX_JS){
code = WX_KEY_EXCEPTION_EMPTY_SCREEN_JS;
break;
}
}
NSString *codeStr = [NSString stringWithFormat:@"%d",code];
NSDictionary* extInfo = @{
@"wxBeginRender":@(strongSelf.isStartRender),
@"wxHasAddView":@(strongSelf.hasAddView),
@"wxHasDegrade":@(strongSelf.isDegrade),
@"wxUseTime":@(useTime),
@"wxUseTimeFrom":useTimeFrom
};
[WXExceptionUtils commitCriticalExceptionRT:strongSelf.instanceId errCode:codeStr function:@"_checkScreenEmptyAndReport"
exception:[strongSelf _convertTopExceptionListToStr] extParams:extInfo];
});
}

- (NSString *)_convertTopExceptionListToStr
Expand Down

0 comments on commit 12ef527

Please sign in to comment.