react-native-macos/React
Emily Janzer e7f6210d5d Don't attempt to connect to React devtools every 2s
Summary:
When testing out the NetworkOverlay, I noticed that we were creating a lot of WebSocket connections for localhost:8097. Rick found that this is because we're trying to connect to React devtools every 2 seconds: https://github.com/facebook/react/blob/master/packages/react-devtools-core/src/backend.js#L67 and it appears we create a new WebSocket every time.

Dan suggested that we use opening the dev menu as a trigger for attempting to connect to React devtools. This diff uses RCTNativeAppEventEmitter to emit an event from native when the dev menu/dialog is shown, and listening to that event in JS to attempt to connect to devtools.

I'm also making the change of passing in a websocket instead of just passing in the host + port; this way it will only attempt to connect once on each call to `connectToDevTools` (otherwise, we would attempt to reconnect every 2 seconds as soon as the dev menu is opened, and then the next time the menu is opened we'd so start that *again*, and so on - I could have it keep track of whether it's already connecting and avoid doing it again, but this is easier and should be sufficient, I think).

We should probably also update the suggested troubleshooting tips on the devtools page to reflect this change, so that people don't get confused.

Changelog: [General] [Fixed] Fix issue where we attempt to connect to React devtools every 2 seconds

Reviewed By: mmmulani

Differential Revision: D17919808

fbshipit-source-id: 4658d995c274574d22f2f54ea06d7f29ef2f54dc
2019-10-23 10:30:43 -07:00
..
Base Render collapsed frames in RedBox 2019-10-22 11:05:36 -07:00
CoreModules Move RCTImage NativeModules back to RCTImage 2019-10-21 17:15:32 -07:00
CxxBridge Replace folly::make_unique with std::make_unique (#26730) 2019-10-22 12:21:41 -07:00
CxxModule Replace folly::make_unique with std::make_unique (#26730) 2019-10-22 12:21:41 -07:00
CxxUtils Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
DevSupport Don't attempt to connect to React devtools every 2s 2019-10-23 10:30:43 -07:00
Fabric Tidy up license headers [3/n] 2019-10-16 10:06:34 -07:00
Inspector Tidy up license headers [3/n] 2019-10-16 10:06:34 -07:00
Modules Render collapsed frames in RedBox 2019-10-22 11:05:36 -07:00
Profiler Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
UIUtils Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
Views Tidy up license headers [3/n] 2019-10-16 10:06:34 -07:00
React-RCTFabric.podspec Move non-license comments out of license header 2019-10-15 20:12:12 -07:00
third-party.xcconfig Upgrade folly to v2018.10.22.00 for iOS (#21976) 2018-10-29 12:13:11 -07:00