Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Track native modules which use the main thread for initialization or …
Browse files Browse the repository at this point in the history
…gathering constants

Reviewed By: majak

Differential Revision: D3054146

fb-gh-sync-id: fd4f4c0dff3144d22357ea798d3131aee578d509
shipit-source-id: fd4f4c0dff3144d22357ea798d3131aee578d509
  • Loading branch information
alexeylang authored and Facebook Github Bot 9 committed Mar 16, 2016
1 parent c1762c7 commit 26d9417
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions React/Base/RCTBatchedBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ - (void)initModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup

// Set up modules that require main thread init or constants export
RCTPerformanceLoggerSet(RCTPLNativeModuleMainThread, 0);
NSUInteger modulesOnMainThreadCount = 0;
for (RCTModuleData *moduleData in _moduleDataByID) {
__weak RCTBatchedBridge *weakSelf = self;
if (moduleData.requiresMainThreadSetup) {
Expand All @@ -380,6 +381,7 @@ - (void)initModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
RCTPerformanceLoggerAppendEnd(RCTPLNativeModuleMainThread);
}
});
modulesOnMainThreadCount++;
} else if (moduleData.hasConstantsToExport) {
// Constants must be exported on the main thread, but module setup can
// be done on any queue
Expand All @@ -391,10 +393,12 @@ - (void)initModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
RCTPerformanceLoggerAppendEnd(RCTPLNativeModuleMainThread);
}
});
modulesOnMainThreadCount++;
}
}

RCTPerformanceLoggerEnd(RCTPLNativeModuleInit);
RCTPerformanceLoggerSet(RCTPLNativeModuleMainThreadUsesCount, modulesOnMainThreadCount);
}

- (void)setUpExecutor
Expand Down
1 change: 1 addition & 0 deletions React/Base/RCTPerformanceLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLNativeModuleMainThread,
RCTPLNativeModulePrepareConfig,
RCTPLNativeModuleInjectConfig,
RCTPLNativeModuleMainThreadUsesCount,
RCTPLJSCExecutorSetup,
RCTPLTTI,
RCTPLBundleSize,
Expand Down
2 changes: 2 additions & 0 deletions React/Base/RCTPerformanceLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ void RCTPerformanceLoggerAppendEnd(RCTPLTag tag)
@(RCTPLData[RCTPLNativeModulePrepareConfig][1]),
@(RCTPLData[RCTPLNativeModuleInjectConfig][0]),
@(RCTPLData[RCTPLNativeModuleInjectConfig][1]),
@(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][0]),
@(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][1]),
@(RCTPLData[RCTPLJSCExecutorSetup][0]),
@(RCTPLData[RCTPLJSCExecutorSetup][1]),
@(RCTPLData[RCTPLTTI][0]),
Expand Down

0 comments on commit 26d9417

Please sign in to comment.