From 3184ab03877ffbfcd23cff1b468e418a9b564d63 Mon Sep 17 00:00:00 2001 From: Artem Yarulin Date: Sun, 3 May 2015 10:42:53 +0300 Subject: [PATCH 1/2] Fixed crash when moduleId or methodId cannot be found and when project is built using release build --- React/Base/RCTBridge.m | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 5c6bcf7cb35a5b..f75f5aa1df3713 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -1044,12 +1044,14 @@ - (void)invalidate */ - (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args { - NSNumber *moduleID = RCTLocalModuleIDs[moduleDotMethod]; - RCTAssert(moduleID != nil, @"Module '%@' not registered.", + NSNumber *notFound = @-1; + + NSNumber *moduleID = RCTLocalModuleIDs[moduleDotMethod] ?: notFound; + RCTAssert(moduleID == notFound, @"Module '%@' not registered.", [[moduleDotMethod componentsSeparatedByString:@"."] firstObject]); - NSNumber *methodID = RCTLocalMethodIDs[moduleDotMethod]; - RCTAssert(methodID != nil, @"Method '%@' not registered.", moduleDotMethod); + NSNumber *methodID = RCTLocalMethodIDs[moduleDotMethod] ?: notFound; + RCTAssert(methodID == notFound, @"Method '%@' not registered.", moduleDotMethod); if (!_loading) { [self _invokeAndProcessModule:@"BatchedBridge" @@ -1063,13 +1065,15 @@ - (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args */ - (void)_immediatelyCallTimer:(NSNumber *)timer { + NSNumber *notFound = @-1; NSString *moduleDotMethod = @"RCTJSTimers.callTimers"; - NSNumber *moduleID = RCTLocalModuleIDs[moduleDotMethod]; - RCTAssert(moduleID != nil, @"Module '%@' not registered.", + + NSNumber *moduleID = RCTLocalModuleIDs[moduleDotMethod] ?: notFound; + RCTAssert(moduleID == notFound, @"Module '%@' not registered.", [[moduleDotMethod componentsSeparatedByString:@"."] firstObject]); - NSNumber *methodID = RCTLocalMethodIDs[moduleDotMethod]; - RCTAssert(methodID != nil, @"Method '%@' not registered.", moduleDotMethod); + NSNumber *methodID = RCTLocalMethodIDs[moduleDotMethod] ?: notFound; + RCTAssert(methodID == notFound, @"Method '%@' not registered.", moduleDotMethod); if (!_loading) { #if BATCHED_BRIDGE From b4253e022611be6eece220fd0340e7b24b91061b Mon Sep 17 00:00:00 2001 From: Artem Yarulin Date: Sun, 3 May 2015 10:57:51 +0300 Subject: [PATCH 2/2] Fixed not found check for module and methodId --- React/Base/RCTBridge.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index f75f5aa1df3713..296ff41f42bcc6 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -1047,11 +1047,11 @@ - (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args NSNumber *notFound = @-1; NSNumber *moduleID = RCTLocalModuleIDs[moduleDotMethod] ?: notFound; - RCTAssert(moduleID == notFound, @"Module '%@' not registered.", + RCTAssert(moduleID != notFound, @"Module '%@' not registered.", [[moduleDotMethod componentsSeparatedByString:@"."] firstObject]); NSNumber *methodID = RCTLocalMethodIDs[moduleDotMethod] ?: notFound; - RCTAssert(methodID == notFound, @"Method '%@' not registered.", moduleDotMethod); + RCTAssert(methodID != notFound, @"Method '%@' not registered.", moduleDotMethod); if (!_loading) { [self _invokeAndProcessModule:@"BatchedBridge" @@ -1069,11 +1069,11 @@ - (void)_immediatelyCallTimer:(NSNumber *)timer NSString *moduleDotMethod = @"RCTJSTimers.callTimers"; NSNumber *moduleID = RCTLocalModuleIDs[moduleDotMethod] ?: notFound; - RCTAssert(moduleID == notFound, @"Module '%@' not registered.", + RCTAssert(moduleID != notFound, @"Module '%@' not registered.", [[moduleDotMethod componentsSeparatedByString:@"."] firstObject]); NSNumber *methodID = RCTLocalMethodIDs[moduleDotMethod] ?: notFound; - RCTAssert(methodID == notFound, @"Method '%@' not registered.", moduleDotMethod); + RCTAssert(methodID != notFound, @"Method '%@' not registered.", moduleDotMethod); if (!_loading) { #if BATCHED_BRIDGE