Add option to start sampling profiler on app launch

Reviewed By: mhorowitz

Differential Revision: D4415989

fbshipit-source-id: 30704c2b618656cb7cc0ccdf87dec315b30b62f3
This commit is contained in:
Pieter De Baets
2017-01-25 14:28:02 -08:00
committed by Facebook Github Bot
parent 5bb19a5bf5
commit a407ff94ee
5 changed files with 23 additions and 4 deletions

View File

@@ -212,6 +212,9 @@ RCT_EXPORT_MODULE()
self->_executorOverride = [self->_defaults objectForKey:@"executor-override"];
});
// Same values are read during the bridge starup path
_startSamplingProfilerOnLaunch = [_settings[@"startSamplingProfilerOnLaunch"] boolValue];
// Delay setup until after Bridge init
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf updateSettings:self->_settings];
@@ -537,6 +540,8 @@ RCT_EXPORT_MODULE()
}
// Add toggles for JSC's sampling profiler, if the profiler is enabled
// Note: bridge.jsContext is not implemented in the old bridge, so this code is
// duplicated in RCTJSCExecutor
if (JSC_JSSamplingProfilerEnabled(self->_bridge.jsContext.JSGlobalContextRef)) {
JSContext *context = self->_bridge.jsContext;
// Allow to toggle the sampling profiler through RN's dev menu
@@ -625,6 +630,12 @@ RCT_EXPORT_METHOD(debugRemotely:(BOOL)enableDebug)
[self updateSetting:@"shakeToShow" value:@(_shakeToShow)];
}
- (void)setStartSamplingProfilerOnLaunch:(BOOL)startSamplingProfilerOnLaunch
{
_startSamplingProfilerOnLaunch = startSamplingProfilerOnLaunch;
[self updateSetting:@"startSamplingProfilerOnLaunch" value:@(_startSamplingProfilerOnLaunch)];
}
RCT_EXPORT_METHOD(setProfilingEnabled:(BOOL)enabled)
{
_profilingEnabled = enabled;