Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS][WebSocket] use correct delegate queue in RCTRSWebSocket #18530

Closed
wants to merge 2 commits into from

Conversation

jhgg
Copy link
Contributor

@jhgg jhgg commented Mar 23, 2018

Motivation

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.

Test Plan

Websockets still work, and hopefully crash less now.

Release Notes

  • [iOS][BUGFIX][WebSocket] fix crashes caused by a race condition in websocket delegates.

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.
@react-native-bot react-native-bot added Missing Test Plan This PR appears to be missing a test plan. Missing Changelog This PR appears to be missing a changelog, or they are incorrectly formatted. labels Mar 23, 2018
@jhgg jhgg changed the title websocket / use correct delegate queue in RCTRSWebSocket [iOS][WebSocket] use correct delegate queue in RCTRSWebSocket Mar 23, 2018
@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Mar 23, 2018
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 23, 2018
@pull-bot
Copy link

pull-bot commented Mar 23, 2018

Warnings
⚠️

📋 Release Notes - This PR may have incorrectly formatted Release Notes.

Generated by 🚫 dangerJS

Copy link
Contributor

@ide ide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just one small change

@@ -82,6 +82,7 @@ - (void)invalidate
}];

RCTSRWebSocket *webSocket = [[RCTSRWebSocket alloc] initWithURLRequest:request protocols:protocols];
[webSocket setDelegateDispatchQueue: _methodQueue];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove space, please follow implied style

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ sorry bout that.

@jhgg
Copy link
Contributor Author

jhgg commented Mar 24, 2018

Android CI failed but it seems to be unrelated to this PR 🤔

@ide
Copy link
Contributor

ide commented Mar 25, 2018

@facebook-github-bot shipit

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Mar 25, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ide is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

hamaron pushed a commit to hamaron/react-native that referenced this pull request Apr 9, 2018
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 facebook#18530

Differential Revision: D7394298

Pulled By: hramos

fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
campsafari pushed a commit to exozet/react-native that referenced this pull request Apr 11, 2018
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 facebook#18530

Differential Revision: D7394298

Pulled By: hramos

fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
LukeDurrant pushed a commit to LukeDurrant/react-native that referenced this pull request Apr 11, 2018
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 facebook#18530

Differential Revision: D7394298

Pulled By: hramos

fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
LukeDurrant pushed a commit to LukeDurrant/react-native that referenced this pull request Apr 11, 2018
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 facebook#18530

Differential Revision: D7394298

Pulled By: hramos

fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
bunnyc1986 pushed a commit to bunnyc1986/react-native that referenced this pull request May 11, 2018
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 facebook#18530

Differential Revision: D7394298

Pulled By: hramos

fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
macdoum1 pushed a commit to macdoum1/react-native that referenced this pull request Jun 28, 2018
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 facebook#18530

Differential Revision: D7394298

Pulled By: hramos

fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
aleclarson pushed a commit to aleclarson/react-native-macos that referenced this pull request Jun 16, 2019
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 facebook/react-native#18530

Differential Revision: D7394298

Pulled By: hramos

fbshipit-source-id: 230466ccb47ea532ced15cd7603256a19077b32b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved. Missing Changelog This PR appears to be missing a changelog, or they are incorrectly formatted. Missing Test Plan This PR appears to be missing a test plan. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants