Skip to content

Commit c1d8139

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Drop RCTBridge reads from five new-arch-only modules (#59256)
Summary: Pull Request resolved: #59256 RCTEventDispatcher routes via _dispatchToJSThread; RCTImageLoader and RCTNetworking require their registry-backed providers; RCTTestModule uses the injected viewRegistry_DEPRECATED; RCTViewManager drops a no-op registry write. Legacy RCTBridge is a stub, so these reads only reached RCTBridgeProxy shims. Changelog: [Internal] Reviewed By: javache Differential Revision: D126558187 fbshipit-source-id: 5a17e359289d606163149eae72e8bb077ed46a35
1 parent db5c52d commit c1d8139

5 files changed

Lines changed: 12 additions & 43 deletions

File tree

‎packages/react-native/Libraries/Image/RCTImageLoader.mm‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ @implementation RCTImageLoader {
8585
__weak id<RCTImageRedirectProtocol> _redirectDelegate;
8686
}
8787

88-
@synthesize bridge = _bridge;
8988
@synthesize moduleRegistry = _moduleRegistry;
9089
@synthesize maxConcurrentLoadingTasks = _maxConcurrentLoadingTasks;
9190
@synthesize maxConcurrentDecodingTasks = _maxConcurrentDecodingTasks;
@@ -134,13 +133,8 @@ - (void)setUp
134133

135134
_URLRequestQueue = dispatch_queue_create("com.facebook.react.ImageLoaderURLRequestQueue", DISPATCH_QUEUE_SERIAL);
136135

137-
// Get loaders, sorted in reverse priority order (highest priority first)
138-
if (_loadersProvider != nil) {
139-
_loaders = _loadersProvider(self.moduleRegistry);
140-
} else {
141-
RCTAssert(_bridge, @"Trying to find RCTImageURLLoaders and bridge not set.");
142-
_loaders = [_bridge modulesConformingToProtocol:@protocol(RCTImageURLLoader)];
143-
}
136+
RCTAssert(_loadersProvider != nil, @"Trying to find RCTImageURLLoaders and loaders provider not set.");
137+
_loaders = _loadersProvider(self.moduleRegistry);
144138
_loaders =
145139
[_loaders sortedArrayUsingComparator:^NSComparisonResult(id<RCTImageURLLoader> a, id<RCTImageURLLoader> b) {
146140
float priorityA = [a respondsToSelector:@selector(loaderPriority)] ? [a loaderPriority] : 0;
@@ -154,13 +148,8 @@ - (void)setUp
154148
}
155149
}];
156150

157-
// Get decoders, sorted in reverse priority order (highest priority first)
158-
if (_decodersProvider != nil) {
159-
_decoders = _decodersProvider(self.moduleRegistry);
160-
} else {
161-
RCTAssert(_bridge, @"Trying to find RCTImageDataDecoders and bridge not set.");
162-
_decoders = [_bridge modulesConformingToProtocol:@protocol(RCTImageDataDecoder)];
163-
}
151+
RCTAssert(_decodersProvider != nil, @"Trying to find RCTImageDataDecoders and decoders provider not set.");
152+
_decoders = _decodersProvider(self.moduleRegistry);
164153
_decoders = [_decoders
165154
sortedArrayUsingComparator:^NSComparisonResult(id<RCTImageDataDecoder> a, id<RCTImageDataDecoder> b) {
166155
float priorityA = [a respondsToSelector:@selector(decoderPriority)] ? [a decoderPriority] : 0;

‎packages/react-native/Libraries/Network/RCTNetworking.mm‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,8 @@ - (void)invalidate
271271
return _handlers;
272272
}
273273

274-
NSArray<id<RCTURLRequestHandler>> *newHandlers = _handlersProvider
275-
? _handlersProvider(self.moduleRegistry)
276-
: [self.bridge modulesConformingToProtocol:@protocol(RCTURLRequestHandler)];
274+
RCTAssert(_handlersProvider != nil, @"Trying to find RCTURLRequestHandlers and handlers provider not set.");
275+
NSArray<id<RCTURLRequestHandler>> *newHandlers = _handlersProvider(self.moduleRegistry);
277276

278277
// Get handlers, sorted in reverse priority order (highest priority first)
279278
newHandlers = [newHandlers

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ @implementation RCTEventDispatcher {
4040
NSRecursiveLock *_observersLock;
4141
}
4242

43-
@synthesize bridge = _bridge;
4443
@synthesize dispatchToJSThread = _dispatchToJSThread;
4544
@synthesize callableJSModules = _callableJSModules;
4645

@@ -175,13 +174,7 @@ - (void)sendEvent:(id<RCTEvent>)event
175174
[_eventQueueLock unlock];
176175

177176
if (scheduleEventsDispatch) {
178-
if (_bridge != nullptr) {
179-
[_bridge
180-
dispatchBlock:^{
181-
[self flushEventsQueue];
182-
}
183-
queue:RCTJSThread];
184-
} else if (_dispatchToJSThread != nullptr) {
177+
if (_dispatchToJSThread != nullptr) {
185178
_dispatchToJSThread(^{
186179
[self flushEventsQueue];
187180
});

‎packages/react-native/React/Views/RCTViewManager.m‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ - (void)updateAccessibilityTraitsForRole:(RCTView *)view withDefaultView:(RCTVie
322322
RCT_CUSTOM_VIEW_PROPERTY(nativeID, NSString *, RCTView)
323323
{
324324
view.nativeID = json ? [RCTConvert NSString:json] : defaultView.nativeID;
325-
[_bridge.uiManager setNativeID:view.nativeID forView:view];
326325
}
327326

328327
RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, RCTView)

‎packages/rn-tester/RCTTest/RCTTestModule.mm‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,16 @@ @implementation RCTTestModule {
9090
NSMutableDictionary<NSString *, NSNumber *> *_snapshotCounter;
9191
}
9292

93-
@synthesize bridge = _bridge;
9493
@synthesize moduleRegistry = _moduleRegistry;
94+
@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
9595

9696
RCT_EXPORT_MODULE()
9797

98-
- (dispatch_queue_t)methodQueue
99-
{
100-
return _bridge.uiManager.methodQueue;
101-
}
102-
103-
- (void)setMethodQueue:(dispatch_queue_t)methodQueue
104-
{
105-
// noop
106-
}
107-
10898
- (void)verifySnapshot:(RCTResponseSenderBlock)callback
10999
{
110100
RCTAssert(_controller != nil, @"No snapshot controller configured.");
111101

112-
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
102+
[_viewRegistry_DEPRECATED addUIBlock:^(__unused RCTViewRegistry *viewRegistry) {
113103
NSString *testName = NSStringFromSelector(self->_testSelector);
114104
if (!self->_snapshotCounter) {
115105
self->_snapshotCounter = [NSMutableDictionary new];
@@ -163,10 +153,9 @@ - (void)markTestCompleted
163153

164154
- (void)markTestPassed:(BOOL)success
165155
{
166-
[_bridge.uiManager
167-
addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
168-
self->_status = success ? RCTTestStatusPassed : RCTTestStatusFailed;
169-
}];
156+
[_viewRegistry_DEPRECATED addUIBlock:^(__unused RCTViewRegistry *viewRegistry) {
157+
self->_status = success ? RCTTestStatusPassed : RCTTestStatusFailed;
158+
}];
170159
}
171160

172161
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:

0 commit comments

Comments
 (0)