Skip to content

Commit

Permalink
Restore VSYNC markers on RCTProfile
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tadeuzagallo authored and facebook-github-bot-3 committed Nov 23, 2015
1 parent 3afa8b6 commit 659cc00
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions React/Profiler/RCTProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
static NSMutableDictionary *RCTProfileOngoingEvents;
static NSTimeInterval RCTProfileStartTime;
static NSUInteger RCTProfileEventID = 0;
static CADisplayLink *RCTProfileDisplayLink;

#pragma mark - Macros

Expand Down Expand Up @@ -266,6 +267,19 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
dispatch_group_leave(RCTProfileGetUnhookGroup());
}

#pragma mark - Private ObjC class only used for the vSYNC CADisplayLink target

@interface RCTProfile : NSObject
@end

@implementation RCTProfile

+ (void)vsync:(__unused CADisplayLink *)displayLink
{
RCTProfileImmediateEvent(0, @"VSYNC", 'g');
}

@end

#pragma mark - Public Functions

Expand Down Expand Up @@ -312,6 +326,11 @@ void RCTProfileInit(RCTBridge *bridge)

RCTProfileHookModules(bridge);

RCTProfileDisplayLink = [CADisplayLink displayLinkWithTarget:[RCTProfile class]
selector:@selector(vsync:)];
[RCTProfileDisplayLink addToRunLoop:[NSRunLoop mainRunLoop]
forMode:NSRunLoopCommonModes];

[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidStartProfiling
object:nil];
}
Expand All @@ -329,6 +348,9 @@ void RCTProfileEnd(RCTBridge *bridge, void (^callback)(NSString *))
[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidEndProfiling
object:nil];

[RCTProfileDisplayLink invalidate];
RCTProfileDisplayLink = nil;

RCTProfileUnhookModules(bridge);

if (callbacks != NULL) {
Expand Down

0 comments on commit 659cc00

Please sign in to comment.