删除 React Natural 中的“远程调试器位于后台选项卡中”警告

我已经开始了一个新的反应本机项目,我不断得到以下警告:

远程调试器位于后台选项卡中,这可能导致应用程序执行缓慢。通过前景化选项卡(或在单独的窗口中打开它)来修复这个问题。

有点烦人,所以我想知道怎样才能摆脱它?我在 Chrome 中运行调试器,我把它移动到一个单独的窗口,但它没有帮助。

49381 次浏览

You can use React Native Debugger available at https://github.com/jhen0409/react-native-debugger It is a standalone app for debugging React Native apps during development.

I had the same issue pop up yesterday. Googling it led to this Stack Overflow post. In one of the response (by adriansprod), he suggested:

Chrome debugger in it's own window fixes. But annoying problem

It is likely that your React Native debugger is not in its own Chrome browser window but in a Chrome browser tab. Pulling it out as its own window, as adriansprod suggest, fixed this for me.

The (very annoying) error message is handled by debuggerWorker.js, which sadly doesn't include any configuration options to turn off the message. So for the time being there are no ways you can configure your application to disable the message.

The related code is outlined below (original licence applies):

var visibilityState;
var showVisibilityWarning = (function() {
var hasWarned = false;
return function() {
// Wait until `YellowBox` gets initialized before displaying the warning.
if (hasWarned || console.warn.toString().includes('[native code]')) {
return;
}
hasWarned = true;
console.warn(
'Remote debugger is in a background tab which may cause apps to ' +
'perform slowly. Fix this by foregrounding the tab (or opening it in ' +
'a separate window).'
);
};
})();

As you see, no configuration options are used, the whole thing is scoped off locally (see the above repo link for further details).

this solution is work for me

open/move http://localhost:8081/debugger-ui (default path for remote debugging) on the separate window

maybe that could help :)

I also have faced with same issue about one week ago and finally i have found solution that works excelent for me

It called reactotron, you can find it here - https://github.com/reactotron/reactotron and you can use it to:
* view your application state
* show API requests & responses
* perform quick performance benchmarks
* subscribe to parts of your application state
* display messages similar to console.log
* track global errors with source-mapped stack traces including saga stack traces!
* dispatch actions like a government-run mind control experiment
* hot swap your app's state
* track your sagas

I hope my post was helpful and you never will faced with this tedious warning .

Good luck

This issue was resolved when I closed all open Chrome windows and started the Remove Debugging again. I had previously had open Chrome windows, so it 'seems' that having them open kills performance.

If you have the Maintain Priority checkbox in the debugger window, try enabling it before you jump to any of the solutions below.

To get rid of the warning in your whole project add the following to your outermost Javascript file (most of the time that's index.js for React Native)

for react-native v0.63+:

Use LogBox: https://reactnative.dev/docs/debugging#logbox

LogBox.ignoreLogs(['Remote debugger']);

for react-native v0.57 - v0.62:

import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Remote debugger']);

Reference this from the official React Native docs:

https://facebook.github.io/react-native/docs/debugging.html

react-native v0.56 or below:

Add the following early on in your code:

console.ignoredYellowBox = ['Remote debugger'];

Easy, simple and specific to that error. Works for me. Can substitute for any text you want.

It is because of number of tabs are opened in the browser with React Native Remote Debugger UI tab. I also faced the same issue.

To overcome this warning message you can use any one method from the following:

  1. Move http://localhost:*****/debugger-ui on the separate window.
  2. Restart Remote JS Debugging.

As mentioned by @jakeforaker in one of the comment. The warning went away by simply opening the remote debugger in a separate window instead of a tab in your existing window of your browser (you have to reload your simulator though).

As the warning is saying keeping the remote debugger in the same window as other tabs

may cause apps to perform slowly

So i think simply suppressing warning as mentioned by @kjonsson:- console.ignoredYellowBox = ['Remote debugger']; doesnt seem to be best solution.

I think the accepted answer is no longer accurate (at least for React Native v0.57+).

The correct code is now:

import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Remote debugger']);

Reference this from the official React Native docs:

https://facebook.github.io/react-native/docs/debugging.html

I use this in index.js

if (__DEV__) {
console.ignoredYellowBox = [
'Remote debugger',
'Warning: isMounted… is deprecated',
'Module RCTImageLoader'
];
}

Since this commit in March 2017, you can enable the Maintain Priority checkbox. When enabled, it silently plays a base64-encoded .wav file to prevent the debugger's browser tab from entering low-power mode, which can affect websocket performance. This will effectively prevent the warning you describe.

I am on Macbook. I fixed this issue by bringing the Debugger window on main desktop, rather than on having it on separate desktop which it thinks is in "Background".

enter image description here

I had minimised the "http://localhost:8081/debugger-ui/" window. Just opening it up (un minimising), and reloading the app removed the warning.

there might be chances that Another debugger is already connected to packager. so close your terminal and debugger google chrome.

if you are using visual studio's package manger then don't start package manager by Mac/other os terminal command.

so close all terminal and stop on going package manger and google chrome debugger. start the process again.

For me warning went away by checking Maintain Priority Checkbox!

Maintain Priority Checkbox should be checked

Similar to Akshay Vijay Jain, mine went away by ticking this box! enter image description here