-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Make DevTools configurable #17617
Make DevTools configurable #17617
Conversation
This setting will be used to disable react-devtools connection. By default it is enabled.
Add JS global variable __RCTDevToolsEnabled, and set it before main script execution. Check this variable in InitializeCore.js and setup DevTools only if enabled.
Was added in 878b7e4 (fishhook nwlog_legacy_v to avoid log spam on websocket reconnect) It is not needed anymore because we can disable DevTools (the only thing that try to infinity reconnects from device or simulator)
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
@facebook-github-bot large-pr Attention: @shergin, @mhorowitz Generated by 🚫 dangerJS |
This PR is actually not big! It simply removes |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@emilsjolander Now I have some code to continue discussion at #10027 (comment) |
@vovkasm I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
Actually we at work support our own fork for RN and can rebase and/or improve this concrete change at any time (within 1-2 days). But I want to be sure that this work not be lost... So I will do anything only if requested from human, not a bot ;-) |
DevTools are a pretty useful feature though and it's reasonable to think that most people will have them enabled always. if we fix the logspew, what benefit does this provide? |
If logspew fixed, only benefit of disabling DevTools is that one can debug application network depended behaviors (battery, sleep, etc...) in dev mode. |
I don't think we'll want to support this change. It's rather complex and the majority of people won't really benefit from it. I'd much rather work on reducing the log spew than adding all this complexity to React Native. |
Motivation
The main motivator for this change is #10027 ("__nw_connection_get_connected_socket_block_invoke Connection has no connected handler" error on iOS 10)
This issue about spam in log output makes application very hard to debug. Error logs generated from inside Apple frameworks when websocket connection can't be established and do not do any harm themselves, but they are repeated every 2 seconds by reconnects to React DevTools and this leads to many meaningless lines in console. This makes quick analysis of logs impossible without running DevTools.
Commit 878b7e4 tries to fix this by hacking system logging functions and filtering some messages. It works sometimes, but has drawbacks:
more here "__nw_connection_get_connected_socket_block_invoke Connection has no connected handler" in logs #10027 (comment)
All this can be workarounded. I can simply run React DevTools utility and these logs disappear because now websocket connection is successful, but:
So as in #10027 (comment)
I implemented an option to disable DevTools connection from dev menu. Now developer can press
Cmd+D
and selectDisable DevTools
in menu to stop application's infinite attempts to reconnect to DevTools.There are other variants to deal with this:
InitializeCore.js
, developers who need it can insert code like below in their application themselves:globals
with magic flags butInitializeCore.js
is called too early in application start, I simply can't (or don't see how) pass config to JS with other mechanisms.Test Plan
react-devtools
are not runningRNTester/RNTester.xcodeproj
Cmd+D
)Disable DevTools
This setting persists like other dev menu settings and can be enabled/disabled. By default DevTools are enabled to not break current behavior.
Release Notes
[IOS] [ENHANCEMENT] [developer menu] - Automatic connection to React DevTools can be enabled/disabled from In-App Developer Menu