diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 74eef66ed..4bfbe9926 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -739,6 +739,8 @@ struct RCTInstanceCallback : public InstanceCallback { { // This will get called from whatever thread was actually executing JS. dispatch_block_t completion = ^{ + // Log start up metrics early before processing any other js calls + [self logStartupFinish]; // Flush pending calls immediately so we preserve ordering [self _flushPendingCalls]; @@ -1013,16 +1015,19 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR } } -- (void)_flushPendingCalls +- (void)logStartupFinish { // Log metrics about native requires during the bridge startup. - uint64_t nativeRequiresCount = [self->_performanceLogger valueForTag:RCTPLRAMNativeRequiresCount]; + uint64_t nativeRequiresCount = [_performanceLogger valueForTag:RCTPLRAMNativeRequiresCount]; [_performanceLogger setValue:nativeRequiresCount forTag:RCTPLRAMStartupNativeRequiresCount]; - uint64_t nativeRequires = [self->_performanceLogger valueForTag:RCTPLRAMNativeRequires]; + uint64_t nativeRequires = [_performanceLogger valueForTag:RCTPLRAMNativeRequires]; [_performanceLogger setValue:nativeRequires forTag:RCTPLRAMStartupNativeRequires]; [_performanceLogger markStopForTag:RCTPLBridgeStartup]; +} +- (void)_flushPendingCalls +{ RCT_PROFILE_BEGIN_EVENT(0, @"Processing pendingCalls", @{ @"count": [@(_pendingCalls.count) stringValue] }); // Phase B: _flushPendingCalls happens. Each block in _pendingCalls is // executed, adding work to the queue, and _pendingCount is decremented.