Skip to content

Commit cd45744

Browse files
tadeuzagallofacebook-github-bot-9
authored andcommitted
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
1 parent 86bb656 commit cd45744

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

React/Base/RCTBatchedBridge.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ - (void)_jsThreadUpdate:(CADisplayLink *)displayLink
943943
[self updateJSDisplayLinkState];
944944

945945

946-
RCTProfileImmediateEvent(0, @"JS Thread Tick", 'g');
946+
RCTProfileImmediateEvent(0, @"JS Thread Tick", displayLink.timestamp, 'g');
947947

948948
RCT_PROFILE_END_EVENT(0, @"objc_call", nil);
949949
}

React/Profiler/RCTProfile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ RCT_EXTERN void RCTProfileEndAsyncEvent(uint64_t tag,
124124
*/
125125
RCT_EXTERN void RCTProfileImmediateEvent(uint64_t tag,
126126
NSString *name,
127+
NSTimeInterval time,
127128
char scope);
128129

129130
/**

React/Profiler/RCTProfile.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ @interface RCTProfile : NSObject
275275

276276
@implementation RCTProfile
277277

278-
+ (void)vsync:(__unused CADisplayLink *)displayLink
278+
+ (void)vsync:(CADisplayLink *)displayLink
279279
{
280-
RCTProfileImmediateEvent(0, @"VSYNC", 'g');
280+
RCTProfileImmediateEvent(0, @"VSYNC", displayLink.timestamp, 'g');
281281
}
282282

283283
@end
@@ -513,6 +513,7 @@ void RCTProfileEndAsyncEvent(
513513
void RCTProfileImmediateEvent(
514514
uint64_t tag,
515515
NSString *name,
516+
NSTimeInterval time,
516517
char scope
517518
) {
518519
CHECK();
@@ -522,7 +523,6 @@ void RCTProfileImmediateEvent(
522523
return;
523524
}
524525

525-
NSTimeInterval time = CACurrentMediaTime();
526526
NSString *threadName = RCTCurrentThreadName();
527527

528528
dispatch_async(RCTProfileGetQueue(), ^{

0 commit comments

Comments
 (0)