From a4e89d71a3214d35f029188fe236f49189050bc1 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Sun, 17 May 2015 18:32:00 -0700 Subject: [PATCH] [ReactNative] Fix RCTBatchedBridge main thread invalidation Summary: D2052669 introduced a block for objects that had to be invalidated on the main thread, but after the JS thread objects, but the block was being dispatched on the JS thread. @public Test Plan: I added `RCTAssertMainThread()` to the `mainThreadInvalidate` block, it was crashing on reload, but now it should work as expected. --- React/Base/RCTBridge.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 42973a3b6..5e1aa7f27 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -1182,6 +1182,7 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(NSString *)module method:(NSStrin } void (^mainThreadInvalidate)(void) = ^{ + RCTAssertMainThread(); [_mainDisplayLink invalidate]; _mainDisplayLink = nil; @@ -1221,7 +1222,7 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(NSString *)module method:(NSStrin /** * Main Thread deallocations */ - mainThreadInvalidate(); + dispatch_async(dispatch_get_main_queue(), mainThreadInvalidate); }]; }