diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m index dd53ee8ec..a52400ffc 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m @@ -22,13 +22,12 @@ #import "RCTRootView.h" #define RUN_RUNLOOP_WHILE(CONDITION) \ -_Pragma("clang diagnostic push") \ -_Pragma("clang diagnostic ignored \"-Wshadow\"") \ -NSDate *timeout = [[NSDate date] dateByAddingTimeInterval:5]; \ -while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \ - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeout]; \ -} \ -_Pragma("clang diagnostic pop") +{ \ + NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \ + while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \ + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \ + } \ +} @interface RCTJavaScriptContext : NSObject @@ -212,8 +211,6 @@ RCT_EXPORT_METHOD(test:(__unused NSString *)a XCTAssertFalse(rootContentView.userInteractionEnabled, @"RCTContentView should have been invalidated"); } -// This test is flaky, and needs to be fixed before re-enabling. See t9456702. -#if 0 - (void)testUnderlyingBridgeIsDeallocated { RCTBridge *bridge; @@ -229,7 +226,15 @@ RCT_EXPORT_METHOD(test:(__unused NSString *)a XCTAssertNotNil(bridge, @"RCTBridge should not have been deallocated"); XCTAssertNil(batchedBridge, @"RCTBatchedBridge should have been deallocated"); + + // Wait to complete the test until the new batchedbridge is also deallocated + @autoreleasepool { + batchedBridge = bridge.batchedBridge; + bridge = nil; + } + + RUN_RUNLOOP_WHILE(batchedBridge != nil); + XCTAssertNil(batchedBridge); } -#endif @end diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTBridgeTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTBridgeTests.m index d428fb441..31fc8f74e 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTBridgeTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTBridgeTests.m @@ -21,15 +21,13 @@ #import "RCTJavaScriptExecutor.h" #import "RCTUtils.h" - #define RUN_RUNLOOP_WHILE(CONDITION) \ -_Pragma("clang diagnostic push") \ -_Pragma("clang diagnostic ignored \"-Wshadow\"") \ -NSDate *timeout = [[NSDate date] dateByAddingTimeInterval:0.1]; \ -while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \ -[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeout]; \ -} \ -_Pragma("clang diagnostic pop") +{ \ + NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \ + while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \ + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \ + } \ +} @interface TestExecutor : NSObject diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m index 55b53e48d..9d5814c56 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m @@ -17,13 +17,12 @@ #import "RCTNetworking.h" #define RUN_RUNLOOP_WHILE(CONDITION) \ -_Pragma("clang diagnostic push") \ -_Pragma("clang diagnostic ignored \"-Wshadow\"") \ -NSDate *timeout = [[NSDate date] dateByAddingTimeInterval:5]; \ -while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \ - [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeout]; \ -} \ -_Pragma("clang diagnostic pop") +{ \ + NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \ + while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \ + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \ + } \ +} extern BOOL RCTIsGzippedData(NSData *data); diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 3031c1a54..185d6379e 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -175,9 +175,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); dispatch_group_notify(initModulesAndLoadSource, dispatch_get_main_queue(), ^{ RCTBatchedBridge *strongSelf = weakSelf; if (sourceCode && strongSelf.loading) { - dispatch_async(bridgeQueue, ^{ - [weakSelf executeSourceCode:sourceCode]; - }); + [strongSelf executeSourceCode:sourceCode]; } }); } @@ -570,6 +568,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR } RCTAssertMainThread(); + RCTAssert(_javaScriptExecutor != nil, @"Can't complete invalidation without a JS executor"); _loading = NO; _valid = NO; @@ -605,11 +604,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR if (RCTProfileIsProfiling()) { RCTProfileUnhookModules(self); } + _moduleDataByName = nil; _moduleDataByID = nil; _moduleClassesByID = nil; _modulesByName_DEPRECATED = nil; _frameUpdateObservers = nil; + _pendingCalls = nil; }]; });