mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
[ReactNative] Fix timers for debugger executors
Summary: @public `-[RCTJavaScriptExecutor executeBlockOnJavaScriptQueue:]` would always `dispatch_async` for the WebView and WebSocket executors, what caused for any frame aligned dispatch. Test Plan: Test the `Timers, TimerMixin` example on UIExplorer, `requestAnimationFrame` was taking ~33.3ms when debugging, now takes ~16.6ms as expected.
This commit is contained in:
@@ -185,6 +185,15 @@ RCT_EXPORT_MODULE()
|
||||
}
|
||||
|
||||
- (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block
|
||||
{
|
||||
if ([NSThread isMainThread]) {
|
||||
block();
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), block);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), block);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user