Skip to content

Commit a1b67f9

Browse files
motiz88facebook-github-bot
authored andcommitted
Handle all incoming Inspector messages on main thread (#41503)
Summary: Pull Request resolved: #41503 Changelog: [Internal] Updates RCTInspectorPackagerConnection to dispatch all messages on the main thread (which is SocketRocket's default behaviour). This is in support of a new CDP implementation in React Native that will strictly assume it's called on the main thread (thus avoiding the need for explicit locking in many places). Reviewed By: javache Differential Revision: D51346659 fbshipit-source-id: c529b0aea97f7732cea58a4dc66993c5c8259958
1 parent 781b637 commit a1b67f9

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

packages/react-native/React/Inspector/RCTInspectorPackagerConnection.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ @interface RCTInspectorPackagerConnection () <SRWebSocketDelegate> {
2828
NSURL *_url;
2929
NSMutableDictionary<NSString *, RCTInspectorLocalConnection *> *_inspectorConnections;
3030
SRWebSocket *_webSocket;
31-
dispatch_queue_t _jsQueue;
3231
BOOL _closed;
3332
BOOL _suppressConnectionErrors;
3433
RCTBundleStatusProvider _bundleStatusProvider;
@@ -57,7 +56,6 @@ - (instancetype)initWithURL:(NSURL *)url
5756
if (self = [super init]) {
5857
_url = url;
5958
_inspectorConnections = [NSMutableDictionary new];
60-
_jsQueue = dispatch_queue_create("com.facebook.react.WebSocketExecutor", DISPATCH_QUEUE_SERIAL);
6159
}
6260
return self;
6361
}
@@ -247,7 +245,6 @@ - (void)connect
247245
// timeouts, but our previous class, RCTSRWebSocket didn't have the same
248246
// implemented options. Might be worth reinvestigating for SRWebSocket?
249247
_webSocket = [[SRWebSocket alloc] initWithURL:_url];
250-
[_webSocket setDelegateDispatchQueue:_jsQueue];
251248
_webSocket.delegate = self;
252249
[_webSocket open];
253250
}
@@ -282,7 +279,7 @@ - (void)closeQuietly
282279
- (void)sendToPackager:(NSDictionary *)messageObject
283280
{
284281
__weak RCTInspectorPackagerConnection *weakSelf = self;
285-
dispatch_async(_jsQueue, ^{
282+
dispatch_async(dispatch_get_main_queue(), ^{
286283
RCTInspectorPackagerConnection *strongSelf = weakSelf;
287284
if (strongSelf && !strongSelf->_closed) {
288285
NSError *error;

0 commit comments

Comments
 (0)