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
This commit is contained in:
Tadeu Zagallo 2015-11-23 09:48:43 -08:00 committed by facebook-github-bot-3
parent 3afa8b6c5f
commit 659cc005ad

View File

@ -46,6 +46,7 @@ static NSDictionary *RCTProfileInfo;
static NSMutableDictionary *RCTProfileOngoingEvents; static NSMutableDictionary *RCTProfileOngoingEvents;
static NSTimeInterval RCTProfileStartTime; static NSTimeInterval RCTProfileStartTime;
static NSUInteger RCTProfileEventID = 0; static NSUInteger RCTProfileEventID = 0;
static CADisplayLink *RCTProfileDisplayLink;
#pragma mark - Macros #pragma mark - Macros
@ -266,6 +267,19 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
dispatch_group_leave(RCTProfileGetUnhookGroup()); 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 #pragma mark - Public Functions
@ -312,6 +326,11 @@ void RCTProfileInit(RCTBridge *bridge)
RCTProfileHookModules(bridge); RCTProfileHookModules(bridge);
RCTProfileDisplayLink = [CADisplayLink displayLinkWithTarget:[RCTProfile class]
selector:@selector(vsync:)];
[RCTProfileDisplayLink addToRunLoop:[NSRunLoop mainRunLoop]
forMode:NSRunLoopCommonModes];
[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidStartProfiling [[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidStartProfiling
object:nil]; object:nil];
} }
@ -329,6 +348,9 @@ void RCTProfileEnd(RCTBridge *bridge, void (^callback)(NSString *))
[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidEndProfiling [[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidEndProfiling
object:nil]; object:nil];
[RCTProfileDisplayLink invalidate];
RCTProfileDisplayLink = nil;
RCTProfileUnhookModules(bridge); RCTProfileUnhookModules(bridge);
if (callbacks != NULL) { if (callbacks != NULL) {