From cd4574498d27e1b71b7f77f554533997f8552481 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Wed, 9 Dec 2015 09:53:00 -0800 Subject: [PATCH] Use actual CADisplayLink timestamp for VSYNC Summary: public Use the actual timestamp provided through `CADisplayLink` instead of the time the handler is called. Reviewed By: jspahrsummers Differential Revision: D2739121 fb-gh-sync-id: 1da28190bb25351dc3dd94efaff21d49279a570f --- React/Base/RCTBatchedBridge.m | 2 +- React/Profiler/RCTProfile.h | 1 + React/Profiler/RCTProfile.m | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 696de22ad5..b3b290d72b 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -943,7 +943,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR [self updateJSDisplayLinkState]; - RCTProfileImmediateEvent(0, @"JS Thread Tick", 'g'); + RCTProfileImmediateEvent(0, @"JS Thread Tick", displayLink.timestamp, 'g'); RCT_PROFILE_END_EVENT(0, @"objc_call", nil); } diff --git a/React/Profiler/RCTProfile.h b/React/Profiler/RCTProfile.h index 2e6e921d3d..a013a70703 100644 --- a/React/Profiler/RCTProfile.h +++ b/React/Profiler/RCTProfile.h @@ -124,6 +124,7 @@ RCT_EXTERN void RCTProfileEndAsyncEvent(uint64_t tag, */ RCT_EXTERN void RCTProfileImmediateEvent(uint64_t tag, NSString *name, + NSTimeInterval time, char scope); /** diff --git a/React/Profiler/RCTProfile.m b/React/Profiler/RCTProfile.m index f311a35045..a47931e429 100644 --- a/React/Profiler/RCTProfile.m +++ b/React/Profiler/RCTProfile.m @@ -275,9 +275,9 @@ void RCTProfileUnhookModules(RCTBridge *bridge) @implementation RCTProfile -+ (void)vsync:(__unused CADisplayLink *)displayLink ++ (void)vsync:(CADisplayLink *)displayLink { - RCTProfileImmediateEvent(0, @"VSYNC", 'g'); + RCTProfileImmediateEvent(0, @"VSYNC", displayLink.timestamp, 'g'); } @end @@ -513,6 +513,7 @@ void RCTProfileEndAsyncEvent( void RCTProfileImmediateEvent( uint64_t tag, NSString *name, + NSTimeInterval time, char scope ) { CHECK(); @@ -522,7 +523,6 @@ void RCTProfileImmediateEvent( return; } - NSTimeInterval time = CACurrentMediaTime(); NSString *threadName = RCTCurrentThreadName(); dispatch_async(RCTProfileGetQueue(), ^{