Merge pull request #3086 from sunshl/Jiakui/bugfix_191217_crashfix
[iOS] fix uncaught exception when nan value passed from front end
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
index 6fa35be..0a86a77 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
@@ -70,6 +70,7 @@
#define WXAssertComponentExist(component) WXAssert(component, @"component not exists")
#define MAX_DROP_FRAME_FOR_BATCH 200
+#define SYNC_UI_EXCEPTION_LOG_INTERVAL 1000
@interface WXComponentManager () <WXDisplayLinkClient>
@end
@@ -1146,7 +1147,15 @@
if (blocks.count) {
dispatch_async(dispatch_get_main_queue(), ^{
for(dispatch_block_t block in blocks) {
- block();
+ @try {
+ block();
+ } @catch (NSException *exception) {
+ static NSInteger sCatchCount = 0;
+ if (++sCatchCount % SYNC_UI_EXCEPTION_LOG_INTERVAL == 1) {
+ // log for the first time and control interval
+ WXLogError(@"SyncUI Exception:%@", exception);
+ }
+ }
}
});
}