Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React app slows to a crawl with chrome developer tools open. Works fine in incognito

When developing my react app the app becomes unusably slow with the devtools open in chrome. Works fast and fine with them closed or in incognito mode. I have tried disabling all extensions and had the same problem. This seems to have started happening recently when I updated chrome (now on Version 80.0.3987.132).

I am not really sure where to start debugging this issue but it has become very frustrating to develop on my app.

Any advice or help debugging would be appreciated.

like image 269
tgreen Avatar asked Mar 07 '20 00:03

tgreen


2 Answers

TL;DR: Go to the Sources tab and delete all breakpoints for the site.

I had a similar problem. My site was very slow to load, but only in specific circumstances:

  1. Dev-tools were open.
  2. Tab was in a normal window. (not incognito mode)
  3. Profiling was not enabled.

If (and only if) all three of those conditions were met, the site would load unbearably slowly (15+ seconds; normally ~3s), plus have performance issues for certain operations on the site (like changing which subpanel was open). It was very strange.

Like you, I tried disabling all of my extensions, yet the problem persisted.

Attempt 1: I tried clearing all of the site's cookies and local-storage, using the info/lock dropdown at the left of the address-bar. Suprisingly, that seems to have fixed it! (edit: this was not the root problem; see below for that)

So the problem must be that my site was storing too much data in local storage or something, such that dev-tools was choking on it (but only in specific cases, for some reason). This also matches with the issue resolving in incognito mode: incognito mode uses a "clear slate" for site cookies/local-storage.

Anyway, it's an odd one, but the cookies/local-storage clearing seems to have worked for my case. (If the issue comes up again, and the solution above doesn't fix it, I'll try to remember to mention it.)

Update: Oddly, having the profiler on still speeds things up even after the fix (ie. those three conditions being met still slows down page loading and actions, just much less than before the fix). So apparently the fix merely "reduces the intensity" of the problem rather than fully fixing it; like, by resetting local-storage, it lessens the size of that data, which somehow is a variable affecting the core problem (not yet identified).

Attempt 2: I believe I have found the root problem and solution: I removed all breakpoints for the site, and the slowdown was solved completely. So the problem seems to be that I had lots of unneeded breakpoints set at various places in my website code (some enabled, some disabled). Some of these must have been placed in/near "hotspots" that were getting called frequently. By having the dev-tools open, the Javascript engine must have had to start performing some processing related to the breakpoints, slowing things down.

My guess is that the problem would also be fixed by disabling the "JavaScript source maps" settings (as that's the only thing I can think would cause so much slowdown), but I haven't confirmed this.

like image 162
Venryx Avatar answered Oct 20 '22 00:10

Venryx


This has most probably something to do with this commit, titled "Stop sending profile data when recording is off".

They already know there is an issue with the Developer Tools slowing down and they tried to prevent it by preventing profiling data to be sent via the bridge to the frontend, when not recording.

As reported, it seems the issue is not happening anymore, on the latest version. However, the cause is still unknown.

Try uninstalling the Developer Tools extension, clearing browser cache and then installing it again.

like image 45
Daniele Molinari Avatar answered Oct 20 '22 01:10

Daniele Molinari