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

Commit

Permalink
[Fix] First remove invalid timers and the report. (#2549)
Browse files Browse the repository at this point in the history
  • Loading branch information
wqyfavor authored and jianhan-he committed Jun 14, 2019
1 parent 6a16112 commit 1201d50
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ - (void)createTimerWithCallback:(NSString *)callbackID time:(NSTimeInterval)mill
_timers[callbackID] = timer;

if ([_timers count] > 30) {
if (!_tooManyTimersReported) {
[WXExceptionUtils commitCriticalExceptionRT:self.weexInstance.instanceId errCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_TOO_MANY_TIMERS] function:@"" exception:@"Too many timers." extParams:nil];
_tooManyTimersReported = YES;
}

// remove invalid timers
NSMutableArray* invalidTimerIds = [[NSMutableArray alloc] init];
for (NSString *cbId in _timers) {
Expand All @@ -183,6 +178,14 @@ - (void)createTimerWithCallback:(NSString *)callbackID time:(NSTimeInterval)mill
}
}
[_timers removeObjectsForKeys:invalidTimerIds];

// If alive timer count still exceeds 30, we report once for this page.
if ([_timers count] > 30) {
if (!_tooManyTimersReported) {
[WXExceptionUtils commitCriticalExceptionRT:self.weexInstance.instanceId errCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_TOO_MANY_TIMERS] function:@"" exception:@"Too many timers." extParams:nil];
_tooManyTimersReported = YES;
}
}
}
}
}
Expand Down

0 comments on commit 1201d50

Please sign in to comment.