Bug: Excessive cpu usage of the page when react-devtools is active
See original GitHub issueWhen option “Highlight updates when components render” is activated the whole page repaints in rapid succession after the components state has been changed. It causes 100% CPU usage by the browser and unpleasant DX due low fps.
React version: 16.12.0 DevTools version 4.4.0-f749045a5
The sequance of actions is important:
- Open react application
- Open react-devtools
- Check option “Highlight updates when components render” in react-devtools settings
- Change the internal state of a component
- In activity monitor there will be 100% cpu usage of the page, or check option “Paint flashing” in rendering pane of chrome devtools
The code example (to trigger the issue: 1) check the option “Highlight updates when components render” and 2) click on the button:
import React, {useState} from 'react';
function App() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
click #{count}
</button>
);
}
export default App;
The current behavior
Excessive cpu usage of the page
The expected behavior
Normal cpu usage of the page
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Debugging performance problems in React - LogRocket Blog
Learn how to debug performance problems in React with this post ... is taking too long to process (usually related to CPU consumption)....
Read more >React - High CPU usage on website idle even when no events ...
Noticed quite high CPU usage, doing some investigation seems like its constantly using on 50% cpu on the chrome task manager.
Read more >Analyze runtime performance - Chrome Developers
Whenever you profile a page, use CPU Throttling to simulate how your page performs on mobile devices. In DevTools, click the Performance tab....
Read more >How to track down CPU issues in Node.js | Dynatrace news
Let's find out what causes very high Node.js CPU usage! ... here's a story by Netflix on how they used flame charts to...
Read more >High CPU usage because of service worker (sw.js)
To test weather the recent update has been causing the issue, you could (1) remove all extensions, (2) unregister all service workers through ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Browsers including Internet Explorer, Chrome, Safari, and Firefox store the delay as a 32-bit signed integer internally. This causes an integer overflow when using delays larger than 2,147,483,647 ms (about 24.8 days), resulting in the timeout being executed immediately.
sourceOh, I see. I’ll try to refactor it a little bit but without engaging to refactor other functions. Maybe just reversed conditions will be more readable in this situation.
@mkrl Interesting, I cloned your repository it worked fine for me too, it might be a chrome bug on ubuntu, can you also check it with firefox devtools (it is basically the same code base just built for firefox), if it exists there too it means that it is probably related to react-devtools.