Skip to content

Commit 91d2f80

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Remove bridge-mode branches from RCTDevSettings (#59260)
Summary: Pull Request resolved: #59260 Delete the always-false _isBridgeMode helper and fold its call sites to the bridgeless paths. Remove the no-op profiling bridge calls with their synchronize cascade, and simplify setExecutorClass to persist locally plus reload. Changelog: [Internal] Reviewed By: shwanton Differential Revision: D126574662 fbshipit-source-id: 5c883e086e11c1d4c7dd8a75aa53c259e9147a16
1 parent 200245e commit 91d2f80

1 file changed

Lines changed: 9 additions & 83 deletions

File tree

‎packages/react-native/React/CoreModules/RCTDevSettings.mm‎

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#import <React/RCTDevMenu.h>
1818
#import <React/RCTEventDispatcherProtocol.h>
1919
#import <React/RCTLog.h>
20-
#import <React/RCTProfile.h>
2120
#import <React/RCTReloadCommand.h>
2221
#import <React/RCTUtils.h>
2322
#import <atomic>
@@ -165,11 +164,6 @@ + (BOOL)requiresMainQueueSetup
165164
return NO;
166165
}
167166

168-
- (BOOL)_isBridgeMode
169-
{
170-
return [self.bridge isKindOfClass:[RCTBridge class]];
171-
}
172-
173167
- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource
174168
{
175169
if (self = [super init]) {
@@ -221,36 +215,9 @@ - (void)initialize
221215
#endif
222216

223217
#if RCT_ENABLE_INSPECTOR
224-
if ([self _isBridgeMode]) {
225-
// We need this dispatch to the main thread because the bridge is not yet
226-
// finished with its initialisation. By the time it relinquishes control of
227-
// the main thread, this operation can be performed.
228-
__weak __typeof(self) weakSelf = self;
229-
dispatch_async(dispatch_get_main_queue(), ^{
230-
__typeof(self) strongSelf = weakSelf;
231-
if (!strongSelf) {
232-
return;
233-
}
234-
id dispatchBlock = ^{
235-
__typeof(self) strongSelf2 = weakSelf;
236-
if (!strongSelf2) {
237-
return;
238-
}
239-
NSURL *url = strongSelf2.bundleManager.bundleURL;
240-
[RCTInspectorDevServerHelper connectWithBundleURL:url];
241-
};
242-
[strongSelf.bridge dispatchBlock:dispatchBlock queue:RCTJSThread];
243-
});
244-
} else {
245-
NSURL *url = self.bundleManager.bundleURL;
246-
[RCTInspectorDevServerHelper connectWithBundleURL:url];
247-
}
218+
NSURL *url = self.bundleManager.bundleURL;
219+
[RCTInspectorDevServerHelper connectWithBundleURL:url];
248220
#endif
249-
250-
__weak __typeof(self) weakSelf = self;
251-
dispatch_async(dispatch_get_main_queue(), ^{
252-
[weakSelf _synchronizeAllSettings];
253-
});
254221
}
255222

256223
- (dispatch_queue_t)methodQueue
@@ -295,11 +262,7 @@ - (void)setIsShakeGestureEnabled:(BOOL)isShakeGestureEnabled
295262
- (BOOL)isDeviceDebuggingAvailable
296263
{
297264
#if RCT_ENABLE_INSPECTOR
298-
if ([self _isBridgeMode]) {
299-
return self.bridge.isInspectable;
300-
} else {
301-
return self.isInspectable;
302-
}
265+
return self.isInspectable;
303266
#else
304267
return false;
305268
#endif // RCT_ENABLE_INSPECTOR
@@ -341,33 +304,13 @@ - (BOOL)isShakeToShowDevMenuEnabled
341304
- (void)setProfilingEnabled:(BOOL)enabled
342305
{
343306
[self _updateSettingWithValue:@(enabled) forKey:kRCTDevSettingProfilingEnabled];
344-
[self _profilingSettingDidChange];
345307
}
346308

347309
- (BOOL)isProfilingEnabled
348310
{
349311
return [[self settingForKey:kRCTDevSettingProfilingEnabled] boolValue];
350312
}
351313

352-
- (void)_profilingSettingDidChange
353-
{
354-
BOOL enabled = self.isProfilingEnabled;
355-
if (self.isHotLoadingAvailable && enabled != RCTProfileIsProfiling()) {
356-
if (enabled) {
357-
[self.bridge startProfiling];
358-
} else {
359-
__weak __typeof(self) weakSelf = self;
360-
[self.bridge stopProfiling:^(NSData *logData) {
361-
__typeof(self) strongSelf = weakSelf;
362-
if (!strongSelf) {
363-
return;
364-
}
365-
RCTProfileSendResult(strongSelf.bridge, @"systrace", logData);
366-
}];
367-
}
368-
}
369-
}
370-
371314
- (void)setHotLoadingEnabled:(BOOL)enabled
372315
{
373316
if (self.isHotLoadingEnabled != enabled) {
@@ -430,17 +373,12 @@ - (BOOL)isPerfMonitorShown
430373

431374
- (void)setExecutorClass:(Class)executorClass
432375
{
433-
_executorClass = executorClass;
434-
if (self.bridge.executorClass != executorClass) {
435-
// TODO (6929129): we can remove this special case test once we have better
436-
// support for custom executors in the dev menu. But right now this is
437-
// needed to prevent overriding a custom executor with the default if a
438-
// custom executor has been set directly on the bridge
439-
if (executorClass == Nil) {
440-
return;
441-
}
442-
443-
self.bridge.executorClass = executorClass;
376+
if (executorClass == Nil) {
377+
_executorClass = Nil;
378+
return;
379+
}
380+
if (_executorClass != executorClass) {
381+
_executorClass = executorClass;
444382
RCTTriggerReloadCommandListeners(@"Custom executor class reset");
445383
}
446384
}
@@ -505,15 +443,6 @@ - (void)openDebugger
505443

506444
#pragma mark - Internal
507445

508-
/**
509-
* Query the data source for all possible settings and make sure we're doing the right
510-
* thing for the state of each setting.
511-
*/
512-
- (void)_synchronizeAllSettings
513-
{
514-
[self _profilingSettingDidChange];
515-
}
516-
517446
- (void)jsLoaded:(NSNotification *)notification
518447
{
519448
// In bridge mode, the bridge that sent the notif must be the same as the one stored in this module.
@@ -530,9 +459,6 @@ - (void)jsLoaded:(NSNotification *)notification
530459
if (!strongSelf) {
531460
return;
532461
}
533-
// update state again after the bridge has finished loading
534-
[strongSelf _synchronizeAllSettings];
535-
536462
// Inspector can only be shown after JS has loaded
537463
if ([strongSelf isElementInspectorShown]) {
538464
#pragma clang diagnostic push

0 commit comments

Comments
 (0)