Skip to content

Commit c7d28bc

Browse files
luluwu2032facebook-github-bot
authored andcommitted
Remove developer tool guard for android
Summary: Debugging with not having Metro console.log() working in Venice is inconvenient. After PeteTheHeat's fixes in diff series D26624224 the ground issues should be gone, so I tried removing the guard for Android and it worked. The only issue I found is that when connected to Hermes Debugger in Flipper it keeps refreshing (reloading?), I posted here https://fb.workplace.com/groups/2308952995990093/permalink/2899448643607189/, with this found, I think it's a good start to iterate on since there are no crashes and this would help us a lot on Venice debugging. Changelog: [Android][Changed] - Remove developer tool guard for android Reviewed By: PeteTheHeat Differential Revision: D26779418 fbshipit-source-id: 96bb18771e01a25f84f845833a4f71e70433ef2b
1 parent 542c7cc commit c7d28bc

File tree

1 file changed

+53
-56
lines changed

1 file changed

+53
-56
lines changed

Libraries/Core/setUpDeveloperTools.js

+53-56
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,63 @@ declare var console: typeof console & {_isPolyfilled: boolean, ...};
1717
* You can use this module directly, or just require InitializeCore.
1818
*/
1919
if (__DEV__) {
20-
// TODO (T45803484) Enable devtools for bridgeless RN Android.
21-
if (!global.RN$Bridgeless || Platform.OS === 'ios') {
22-
if (!global.__RCTProfileIsProfiling) {
23-
require('./setUpReactDevTools');
20+
if (!global.__RCTProfileIsProfiling) {
21+
require('./setUpReactDevTools');
2422

25-
// Set up inspector
26-
const JSInspector = require('../JSInspector/JSInspector');
27-
JSInspector.registerAgent(require('../JSInspector/NetworkAgent'));
28-
}
23+
// Set up inspector
24+
const JSInspector = require('../JSInspector/JSInspector');
25+
JSInspector.registerAgent(require('../JSInspector/NetworkAgent'));
26+
}
2927

30-
// Note we can't check if console is "native" because it would appear "native" in JSC and Hermes.
31-
// We also can't check any properties that don't exist in the Chrome worker environment.
32-
// So we check a navigator property that's set to a particular value ("Netscape") in all real browsers.
33-
const isLikelyARealBrowser =
34-
global.navigator != null &&
35-
/* _
36-
* | |
37-
* _ __ ___| |_ ___ ___ __ _ _ __ ___
38-
* | '_ \ / _ \ __/ __|/ __/ _` | '_ \ / _ \
39-
* | | | | __/ |_\__ \ (_| (_| | |_) | __/
40-
* |_| |_|\___|\__|___/\___\__,_| .__/ \___|
41-
* | |
42-
* |_|
43-
*/
44-
global.navigator.appName === 'Netscape'; // Any real browser
28+
// Note we can't check if console is "native" because it would appear "native" in JSC and Hermes.
29+
// We also can't check any properties that don't exist in the Chrome worker environment.
30+
// So we check a navigator property that's set to a particular value ("Netscape") in all real browsers.
31+
const isLikelyARealBrowser =
32+
global.navigator != null &&
33+
/* _
34+
* | |
35+
* _ __ ___| |_ ___ ___ __ _ _ __ ___
36+
* | '_ \ / _ \ __/ __|/ __/ _` | '_ \ / _ \
37+
* | | | | __/ |_\__ \ (_| (_| | |_) | __/
38+
* |_| |_|\___|\__|___/\___\__,_| .__/ \___|
39+
* | |
40+
* |_|
41+
*/
42+
global.navigator.appName === 'Netscape'; // Any real browser
4543

46-
if (!Platform.isTesting) {
47-
const HMRClient = require('../Utilities/HMRClient');
44+
if (!Platform.isTesting) {
45+
const HMRClient = require('../Utilities/HMRClient');
4846

49-
if (console._isPolyfilled) {
50-
// We assume full control over the console and send JavaScript logs to Metro.
51-
[
52-
'trace',
53-
'info',
54-
'warn',
55-
'error',
56-
'log',
57-
'group',
58-
'groupCollapsed',
59-
'groupEnd',
60-
'debug',
61-
].forEach(level => {
62-
const originalFunction = console[level];
63-
console[level] = function(...args) {
64-
HMRClient.log(level, args);
65-
originalFunction.apply(console, args);
66-
};
67-
});
68-
} else {
69-
// We assume the environment has a real rich console (like Chrome), and don't hijack it to log to Metro.
70-
// It's likely the developer is using rich console to debug anyway, and hijacking it would
71-
// lose the filenames in console.log calls: https://github.com/facebook/react-native/issues/26788.
72-
HMRClient.log('log', [
73-
`JavaScript logs will appear in your ${
74-
isLikelyARealBrowser ? 'browser' : 'environment'
75-
} console`,
76-
]);
77-
}
47+
if (console._isPolyfilled) {
48+
// We assume full control over the console and send JavaScript logs to Metro.
49+
[
50+
'trace',
51+
'info',
52+
'warn',
53+
'error',
54+
'log',
55+
'group',
56+
'groupCollapsed',
57+
'groupEnd',
58+
'debug',
59+
].forEach(level => {
60+
const originalFunction = console[level];
61+
console[level] = function(...args) {
62+
HMRClient.log(level, args);
63+
originalFunction.apply(console, args);
64+
};
65+
});
66+
} else {
67+
// We assume the environment has a real rich console (like Chrome), and don't hijack it to log to Metro.
68+
// It's likely the developer is using rich console to debug anyway, and hijacking it would
69+
// lose the filenames in console.log calls: https://github.com/facebook/react-native/issues/26788.
70+
HMRClient.log('log', [
71+
`JavaScript logs will appear in your ${
72+
isLikelyARealBrowser ? 'browser' : 'environment'
73+
} console`,
74+
]);
7875
}
79-
80-
require('./setUpReactRefresh');
8176
}
77+
78+
require('./setUpReactRefresh');
8279
}

0 commit comments

Comments
 (0)