Improve fbsystrace support
Reviewed By: mhorowitz Differential Revision: D4756318 fbshipit-source-id: 7811f680a7ad044b5ae028ee9b2fed5f46ce2a63
This commit is contained in:
parent
12de9729bd
commit
5af30382d5
|
@ -301,15 +301,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
}
|
||||
|
||||
RCTAssert(implClass != nil, @"No bridge implementation is available, giving up.");
|
||||
|
||||
#ifdef WITH_FBSYSTRACE
|
||||
if (implClass == cxxBridgeClass) {
|
||||
[RCTFBSystrace registerCallbacks];
|
||||
} else {
|
||||
[RCTFBSystrace unregisterCallbacks];
|
||||
}
|
||||
#endif
|
||||
|
||||
return implClass;
|
||||
}
|
||||
|
||||
|
|
|
@ -1139,6 +1139,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
RCTAssertMainQueue();
|
||||
|
||||
[self executeBlockOnJavaScriptThread:^{
|
||||
#if WITH_FBSYSTRACE
|
||||
[RCTFBSystrace registerCallbacks];
|
||||
#endif
|
||||
RCTProfileInit(self);
|
||||
}];
|
||||
}
|
||||
|
@ -1151,6 +1154,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
RCTProfileEnd(self, ^(NSString *log) {
|
||||
NSData *logData = [log dataUsingEncoding:NSUTF8StringEncoding];
|
||||
callback(logData);
|
||||
#if WITH_FBSYSTRACE
|
||||
[RCTFBSystrace unregisterCallbacks];
|
||||
#endif
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ typedef struct {
|
|||
} systrace_arg_t;
|
||||
|
||||
typedef struct {
|
||||
void (*start)(uint64_t enabledTags, char *buffer, size_t bufferSize);
|
||||
char *(*start)(void);
|
||||
void (*stop)(void);
|
||||
|
||||
void (*begin_section)(uint64_t tag, const char *name, size_t numArgs, systrace_arg_t *args);
|
||||
|
|
|
@ -455,9 +455,7 @@ void RCTProfileInit(RCTBridge *bridge)
|
|||
OSAtomicOr32Barrier(1, &RCTProfileProfiling);
|
||||
|
||||
if (callbacks != NULL) {
|
||||
size_t buffer_size = 1 << 22;
|
||||
systrace_buffer = calloc(1, buffer_size);
|
||||
callbacks->start(~((uint64_t)0), systrace_buffer, buffer_size);
|
||||
systrace_buffer = callbacks->start();
|
||||
} else {
|
||||
NSTimeInterval time = CACurrentMediaTime();
|
||||
dispatch_async(RCTProfileGetQueue(), ^{
|
||||
|
@ -514,9 +512,10 @@ void RCTProfileEnd(RCTBridge *bridge, void (^callback)(NSString *))
|
|||
RCTProfileUnhookModules(bridge);
|
||||
|
||||
if (callbacks != NULL) {
|
||||
if (systrace_buffer) {
|
||||
callbacks->stop();
|
||||
|
||||
callback(@(systrace_buffer));
|
||||
}
|
||||
} else {
|
||||
dispatch_async(RCTProfileGetQueue(), ^{
|
||||
NSString *log = RCTJSONStringify(RCTProfileInfo, NULL);
|
||||
|
|
Loading…
Reference in New Issue