use correct delegate queue in RCTRSWebSocket
Summary: This commit makes the websocket's delegate dispatch queue use `RCTWebSocketModule`'s method queue. This fixes a bug where didReceiveMessage was called on the wrong queue, which is especially harmful if the websocket has a contentHandler expects to be running on the RCTWebSocketModule's method queue. This also fixes the race condition where `_contentHandlers` and `_sockets` can be mutated from the main dispatch queue (the default in `RCTRSWebSocket`) and `RCTWebSocketModule`'s method queue. Websockets still work, and hopefully crash less now. - [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates. Closes https://github.com/facebook/react-native/pull/18530 Differential Revision: D7394298 Pulled By: hramos fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
This commit is contained in:
parent
1acef45977
commit
228f5c83f9
|
@ -82,6 +82,7 @@ RCT_EXPORT_METHOD(connect:(NSURL *)URL protocols:(NSArray *)protocols options:(N
|
|||
}];
|
||||
|
||||
RCTSRWebSocket *webSocket = [[RCTSRWebSocket alloc] initWithURLRequest:request protocols:protocols];
|
||||
[webSocket setDelegateDispatchQueue:_methodQueue];
|
||||
webSocket.delegate = self;
|
||||
webSocket.reactTag = socketID;
|
||||
if (!_sockets) {
|
||||
|
|
Loading…
Reference in New Issue