removed unnecessary dispatches to main queue

Summary: There is no point in dispatching to main thread if there is nothing to do there.
This place gets called basically any time a repeating js timer fires, which doesn't imply UI changes (although usually that's why people setup timers).
Combined with previous diffs that makes us not generate empty blocks (nil instead), this could be minor perf win in some rare cases.

This also changes semantic of `reactBridgeDidFinishTransaction` call a bit. Previously it was done no matter if UI has changed or not.
I think it should be safe, since seems like callees really care only about views being laid out.

Depends on D2571166. (not strictly speaking)

public

Reviewed By: jspahrsummers, nicklockwood

Differential Revision: D2571188

fb-gh-sync-id: 02d52e4615475072c3c27226e67c431a667ec990
This commit is contained in:
Martin Kralik 2015-10-27 05:07:45 -07:00 committed by facebook-github-bot-5
parent 28f5af0c39
commit f916ec26a6
1 changed files with 20 additions and 20 deletions

View File

@ -898,31 +898,31 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
_pendingUIBlocks = [NSMutableArray new]; _pendingUIBlocks = [NSMutableArray new];
[_pendingUIBlocksLock unlock]; [_pendingUIBlocksLock unlock];
// Execute the previously queued UI blocks if (previousPendingUIBlocks.count) {
RCTProfileBeginFlowEvent(); // Execute the previously queued UI blocks
dispatch_async(dispatch_get_main_queue(), ^{ RCTProfileBeginFlowEvent();
RCTProfileEndFlowEvent(); dispatch_async(dispatch_get_main_queue(), ^{
RCTProfileBeginEvent(0, @"UIManager flushUIBlocks", nil); RCTProfileEndFlowEvent();
@try { RCTProfileBeginEvent(0, @"UIManager flushUIBlocks", nil);
for (dispatch_block_t block in previousPendingUIBlocks) { @try {
block(); for (dispatch_block_t block in previousPendingUIBlocks) {
} block();
/** }
* TODO(tadeu): Remove it once and for all /**
*/ * TODO(tadeu): Remove it once and for all
if (previousPendingUIBlocks.count) { */
for (id<RCTComponent> node in _bridgeTransactionListeners) { for (id<RCTComponent> node in _bridgeTransactionListeners) {
[node reactBridgeDidFinishTransaction]; [node reactBridgeDidFinishTransaction];
} }
} }
} @catch (NSException *exception) {
@catch (NSException *exception) { RCTLogError(@"Exception thrown while executing UI block: %@", exception);
RCTLogError(@"Exception thrown while executing UI block: %@", exception); }
} RCTProfileEndEvent(0, @"objc_call", @{
RCTProfileEndEvent(0, @"objc_call", @{ @"count": @(previousPendingUIBlocks.count),
@"count": @(previousPendingUIBlocks.count), });
}); });
}); }
} }
RCT_EXPORT_METHOD(measure:(nonnull NSNumber *)reactTag RCT_EXPORT_METHOD(measure:(nonnull NSNumber *)reactTag