Skip to content

Commit 659cc00

Browse files
tadeuzagallofacebook-github-bot-3
authored andcommitted
Restore VSYNC markers on RCTProfile
Summary: public The VSYNC markers got lost at some point when refactoring RCTBatchedBridge, restore it, but keep it in RCTProfile. Reviewed By: jspahrsummers Differential Revision: D2685805 fb-gh-sync-id: 1acad330de7baf004a83b41f90ba4b6532605de6
1 parent 3afa8b6 commit 659cc00

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

React/Profiler/RCTProfile.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
static NSMutableDictionary *RCTProfileOngoingEvents;
4747
static NSTimeInterval RCTProfileStartTime;
4848
static NSUInteger RCTProfileEventID = 0;
49+
static CADisplayLink *RCTProfileDisplayLink;
4950

5051
#pragma mark - Macros
5152

@@ -266,6 +267,19 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
266267
dispatch_group_leave(RCTProfileGetUnhookGroup());
267268
}
268269

270+
#pragma mark - Private ObjC class only used for the vSYNC CADisplayLink target
271+
272+
@interface RCTProfile : NSObject
273+
@end
274+
275+
@implementation RCTProfile
276+
277+
+ (void)vsync:(__unused CADisplayLink *)displayLink
278+
{
279+
RCTProfileImmediateEvent(0, @"VSYNC", 'g');
280+
}
281+
282+
@end
269283

270284
#pragma mark - Public Functions
271285

@@ -312,6 +326,11 @@ void RCTProfileInit(RCTBridge *bridge)
312326

313327
RCTProfileHookModules(bridge);
314328

329+
RCTProfileDisplayLink = [CADisplayLink displayLinkWithTarget:[RCTProfile class]
330+
selector:@selector(vsync:)];
331+
[RCTProfileDisplayLink addToRunLoop:[NSRunLoop mainRunLoop]
332+
forMode:NSRunLoopCommonModes];
333+
315334
[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidStartProfiling
316335
object:nil];
317336
}
@@ -329,6 +348,9 @@ void RCTProfileEnd(RCTBridge *bridge, void (^callback)(NSString *))
329348
[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidEndProfiling
330349
object:nil];
331350

351+
[RCTProfileDisplayLink invalidate];
352+
RCTProfileDisplayLink = nil;
353+
332354
RCTProfileUnhookModules(bridge);
333355

334356
if (callbacks != NULL) {

0 commit comments

Comments
 (0)