You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ji...@apache.org on 2019/04/23 06:48:55 UTC
[incubator-weex] branch master updated: [iOS] Monitor "Too many
timers" error. And remove invalidate timers automatically. (#2352)
This is an automated email from the ASF dual-hosted git repository.
jianhan 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 5805330 [iOS] Monitor "Too many timers" error. And remove invalidate timers automatically. (#2352)
5805330 is described below
commit 5805330931e2193972053f15e5786d68f86c4b8f
Author: wqyfavor <wq...@gmail.com>
AuthorDate: Tue Apr 23 14:48:50 2019 +0800
[iOS] Monitor "Too many timers" error. And remove invalidate timers automatically. (#2352)
---
ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h | 4 +++-
ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m | 4 +++-
ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m | 20 ++++++++++++++++++++
ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.h | 1 +
ios/sdk/WeexSDK/Sources/Utility/WXVersion.m | 4 ++--
5 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
index 52a9f20..99b1f60 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h
@@ -82,7 +82,9 @@ typedef NS_ENUM(int, WXSDKErrCode)
WX_KEY_EXCEPTION_ABILITY_DOWN_ = -9603,
WX_KEY_EXCEPTION_EMPTY_SCREEN_JS = -9700,
- WX_KEY_EXCEPTION_EMPTY_SCREEN_NATIVE = -9701
+ WX_KEY_EXCEPTION_EMPTY_SCREEN_NATIVE = -9701,
+
+ WX_KEY_EXCEPTION_TOO_MANY_TIMERS = -9800,
};
typedef NS_ENUM (NSInteger,WXSDKErrorType)
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
index 36aaa98..5199bf2 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKError.m
@@ -101,7 +101,9 @@
@(WX_ERR_JSFRAMEWORK_START):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
@(WX_KEY_EXCEPTION_ABILITY_DOWN_):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)},
@(WX_KEY_EXCEPTION_EMPTY_SCREEN_JS):@{ERROR_TYPE:@(WX_RENDER_ERROR),ERROR_GROUP:@(WX_JS)},
- @(WX_KEY_EXCEPTION_EMPTY_SCREEN_NATIVE):@{ERROR_TYPE:@(WX_RENDER_ERROR),ERROR_GROUP:@(WX_NATIVE)}
+ @(WX_KEY_EXCEPTION_EMPTY_SCREEN_NATIVE):@{ERROR_TYPE:@(WX_RENDER_ERROR),ERROR_GROUP:@(WX_NATIVE)},
+
+ @(WX_KEY_EXCEPTION_TOO_MANY_TIMERS):@{ERROR_TYPE:@(WX_NATIVE_ERROR),ERROR_GROUP:@(WX_NATIVE)}
};
});
return codeMap;
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m b/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
index cc399ac..d1dc4ef 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m
@@ -23,6 +23,8 @@
#import "WXAssert.h"
#import "WXMonitor.h"
#import "WXSDKInstance_performance.h"
+#import "WXSDKError.h"
+#import "WXExceptionUtils.h"
@interface WXTimerTarget : NSObject
@@ -75,6 +77,7 @@
@implementation WXTimerModule
{
+ BOOL _tooManyTimersReported;
NSMutableDictionary *_timers;
}
@@ -164,6 +167,23 @@ WX_EXPORT_METHOD(@selector(clearInterval:))
if (!_timers[callbackID]) {
_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) {
+ NSTimer *timer = _timers[cbId];
+ if (![timer isValid]) {
+ [invalidTimerIds addObject:cbId];
+ }
+ }
+ [_timers removeObjectsForKeys:invalidTimerIds];
+ }
}
}
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.h b/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.h
index c0bcf4b..6bd13e0 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.h
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXExceptionUtils.h
@@ -25,5 +25,6 @@
+ (void)commitCriticalExceptionRT:(NSString *)instanceId errCode:(NSString *)errCode function:(NSString *)function exception:(NSString *)exception extParams:(NSDictionary *)extParams;
+ (void)commitCriticalExceptionRT:(WXJSExceptionInfo*)jsExceptionInfo;
+
@end
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXVersion.m b/ios/sdk/WeexSDK/Sources/Utility/WXVersion.m
index 033df66..6739353 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXVersion.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXVersion.m
@@ -20,8 +20,8 @@
#import "WXVersion.h"
#import "WXDefine.h"
-static const char* WeexSDKBuildTime = "2019-04-16 13:26:54 UTC";
-static const unsigned long WeexSDKBuildTimestamp = 1555421214;
+static const char* WeexSDKBuildTime = "2019-04-23 06:34:41 UTC";
+static const unsigned long WeexSDKBuildTimestamp = 1556001281;
NSString* GetWeexSDKVersion(void)
{