diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 0430f2b0a..89861deda 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -871,12 +871,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR for (RCTModuleData *moduleData in _frameUpdateObservers) { id observer = (id)moduleData.instance; if (!observer.paused) { - RCT_IF_DEV(NSString *name = [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp];) RCTProfileBeginFlowEvent(); [self dispatchBlock:^{ RCTProfileEndFlowEvent(); - RCT_PROFILE_BEGIN_EVENT(0, name, nil); + RCT_PROFILE_BEGIN_EVENT(0, [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp], nil); [observer didUpdateFrame:frameUpdate]; RCT_PROFILE_END_EVENT(0, @"objc_call,fps", nil); } queue:moduleData.methodQueue]; diff --git a/React/Profiler/RCTProfile.h b/React/Profiler/RCTProfile.h index 5829a8eb4..2e6e921d3 100644 --- a/React/Profiler/RCTProfile.h +++ b/React/Profiler/RCTProfile.h @@ -66,13 +66,16 @@ RCT_EXTERN void _RCTProfileBeginEvent(NSThread *calleeThread, uint64_t tag, NSString *name, NSDictionary *args); -#define RCT_PROFILE_BEGIN_EVENT(...) { \ - NSThread *calleeThread = [NSThread currentThread]; \ - NSTimeInterval time = CACurrentMediaTime(); \ - dispatch_async(RCTProfileGetQueue(), ^{ \ - _RCTProfileBeginEvent(calleeThread, time, __VA_ARGS__); \ - }); \ -} +#define RCT_PROFILE_BEGIN_EVENT(...) \ + do { \ + if (RCTProfileIsProfiling()) { \ + NSThread *calleeThread = [NSThread currentThread]; \ + NSTimeInterval time = CACurrentMediaTime(); \ + dispatch_async(RCTProfileGetQueue(), ^{ \ + _RCTProfileBeginEvent(calleeThread, time, __VA_ARGS__); \ + }); \ + } \ + } while(0) /** * The ID returned by BeginEvent should then be passed into EndEvent, with the @@ -86,14 +89,17 @@ RCT_EXTERN void _RCTProfileEndEvent(NSThread *calleeThread, NSString *category, NSDictionary *args); -#define RCT_PROFILE_END_EVENT(...) { \ - NSThread *calleeThread = [NSThread currentThread]; \ - NSString *threadName = RCTCurrentThreadName(); \ - NSTimeInterval time = CACurrentMediaTime(); \ - dispatch_async(RCTProfileGetQueue(), ^{ \ - _RCTProfileEndEvent(calleeThread, threadName, time, __VA_ARGS__); \ - }); \ -} +#define RCT_PROFILE_END_EVENT(...) \ + do { \ + if (RCTProfileIsProfiling()) { \ + NSThread *calleeThread = [NSThread currentThread]; \ + NSString *threadName = RCTCurrentThreadName(); \ + NSTimeInterval time = CACurrentMediaTime(); \ + dispatch_async(RCTProfileGetQueue(), ^{ \ + _RCTProfileEndEvent(calleeThread, threadName, time, __VA_ARGS__); \ + }); \ + } \ + } while(0) /** * Collects the initial event information for the event and returns a reference ID