Skip to content
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

[DevTools Bug]: Component tree size too small, components can't be selected #21986

Closed
subnomo opened this issue Jul 29, 2021 · 33 comments · Fixed by #22083
Closed

[DevTools Bug]: Component tree size too small, components can't be selected #21986

subnomo opened this issue Jul 29, 2021 · 33 comments · Fixed by #22083
Assignees
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@subnomo
Copy link

subnomo commented Jul 29, 2021

Website or app

https://reactjs.org/

Repro steps

  1. Visit reactjs.org
  2. Open devtools
  3. Open "Components" tab

At first the component tree won't appear. Once I'm at the "Components" tab, I then have to also refresh the page to make the tree render. And when it does render, it still doesn't work properly.

As a note, this issue started happening after I had to forcibly restart my computer. Since then I have tried reinstalling the extension, restarting Chrome, restarting my pc, all of which haven't worked. I'd like to avoid reinstalling Chrome completely but that's the only thing I haven't yet tried. Using Windows 10, btw.

Here is what the broken component tree looks like. It's very narrow and the components cannot be selected:
tree

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)

No response

Error component stack (automated)

No response

GitHub query string (automated)

No response

@subnomo subnomo added Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Jul 29, 2021
@lilbumblebear
Copy link

Same issue, Chrome v 92.0.4515.107

@gabriel-peracio
Copy link

Same here:
image

The Profiler tab seems unaffected

Workarounds that don't help:

  • Reloading the page
  • Docking the devtools on the side/bottom
  • Undocking the devtools (a.k.a. open in a window)
  • Resizing the window
  • Fiddling with the Expand component tree by default setting
  • Resizing the right pane of the component tab

@gabriel-peracio
Copy link

gabriel-peracio commented Jul 29, 2021

Looks like a CSS issue. I managed to work around it by fiddling with the styles as shown in this video:

hOIhH63WKa.mp4

Besides the css tweaks to make the tree not so squished, the mouse selection issue has to be worked around separately

The nodes are initially selectable with the mouse, but mouse selection breaks permanently if you attempt to use the element picker (I'm guessing it adds pointer-events: none and doesn't remove it?)

Using other methods of selecting nodes (i.e. searching, keyboard, using the owners/rendered by buttons, etc) still work

For anyone curious on how to do what I did in the video:

  1. open the devtools in undocked mode
  2. press ctrl+shift+I - this will open an "inspector inspector"
  3. tweak the properties as shown in the video

@kkragoth
Copy link

kkragoth commented Jul 29, 2021

Doesn't seem to occur on mac os for me on extension (both from chrome extension store and running from main branch). Could this be os specific?
Version
4.14.0 (7/16/2021)

Screenshot 2021-07-30 at 00 05 56

@dmitry-turing
Copy link

reproduces for me on:

MacOS X 10.14
Chrome Version 92.0.4515.107 (Official Build) (x86_64) (latest)
DevTools 4.14.0 (7/16/2021)

@gabriel-peracio
Copy link

gabriel-peracio commented Jul 30, 2021

Mine is:

Windows 10 21H1 (OS Build 19043.1110)
Chrome Version 92.0.4515.107 (Official Build) (64-bit)
DevTools version 4.14.0-d0ec283819

If any developer is unable to reproduce, let me know and I can get you whatever you need (a snapshot of the dom, the css ruleset, a memory dump, clientRects of specific nodes, heck even a css fiddle if that's what you need, anything that might help you)

Also I know you guys know this but just in case: what I did in the video is by no means a suggestion of what should be done in order to fix the problem. Randomly changing CSS around without understanding what it does is a good way to introduce more bugs

@samuelcolburn
Copy link

reproduces for me on:

Windows 10 Pro (10.0.19043 Build 19043)
Edge Version 92.0.902.62 (Official Build) (64-bit) (latest)
DevTools 4.14.0 (7/16/2021)

@KasiMaru
Copy link

KasiMaru commented Aug 4, 2021

I also have this problem:

MacOS 11.4
Chrome version: Version 92.0.4515.131 (Official Build) (x86_64)
DevTools version: 4.14.0 (7/16/2021)

Sometimes component tree doesn't show at all, have to reload a page. Even after reloading tree is too narrow and clicks are not coming through.

Tried every sane approach to fix (reinstall, reload etc) — nothing helps.

@Borvik
Copy link

Borvik commented Aug 6, 2021

Occurs for me as well:

Ubuntu 20.04.2 LTS
Chrome: 92.0.4515.107 - also occurs on: 92.0.4515.131
DevTools: 4.14.0

While Chrome is affected for me - FireFox continues to work.

@jstejada
Copy link
Contributor

Another report in #22065

@bvaughn
Copy link
Contributor

bvaughn commented Aug 11, 2021

I suspect the bug may be caused by this component (which we use in DevTools to auto-expand the Components tree to fill the width and height of the viewport):
https://github.com/bvaughn/react-virtualized-auto-sizer

@mbonaci
Copy link

mbonaci commented Aug 11, 2021

Me too.
OSX 10.15.7
Chrome 92.0.4515.131 (the latest)
ReactDevTools: 4.14.0

Interestingly, the issue is not present in Chromium: 91.0.4472.114 (Brave 1.26.67).

@bvaughn
Copy link
Contributor

bvaughn commented Aug 11, 2021

Tanks @mbonaci.

As another data point:

OS X 11.4 (20F71)
Chrome 92.0.4515.131
DevTools (built from HEAD of main)

FWIW I've never seen or been able to reproduce this bug myself (and I use DevTools daily).

Maybe others can share their configurations and we can spot a pattern.

@gabriel-peracio
Copy link

@ bvaughn

I've never seen this personally.

So you can't reproduce?

Maybe others can share their configurations and we can spot a pattern.

What would be helpful for you to track this down?

@simplecommerce
Copy link

I have the same issues and also using chrome with latest version 92.0.4515.131 and dev tools version 4.14.0 on windows 10.
Weird thing, is my co-worker with the same versions, it works fine on his end on the same app/site.
So no idea what is causing it to not work on my computer.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 11, 2021

@simplecommerce Could be helpful if you and your coworker could try to further narrow down what the difference is between the two of your setups.

@simplecommerce
Copy link

@bvaughn I checked with him quickly and we have pretty much the same extensions.
I also did a test in Edge and in Edge it works fine, it only seems to affect my chrome.
I also tried to disable all extensions and even did a complete reset of the chrome settings to default values and cleared all cache.
The problem still persists.
I even thought of disabling hardware acceleration and checked if my settings differed from edge, but no go.

@issacgerges
Copy link

issacgerges commented Aug 11, 2021

I have a suspicion at whats going on here. I know react-virtualized shims ResizeObserver has resize detection using scroll event handlers, when it does this, it schedules a requestAnimationFrame to be notified after the layout updates. In this case, if I debug this script, I can see that scheduling any raf in main.html of the devtool will never fire. I suspect a finch trial is being used by the Chromium team to attempt to throttle rAFs in hidden iframes. This experiment looks the most suspicious, these will show as "Default" for everyone unfortunately.

image

@gabriel-peracio
Copy link

gabriel-peracio commented Aug 11, 2021

@issacgerges Awesome work, this pretty much confirms it.

Changing that flag from Default to Disabled solves the issue on my end. Changing it to Enabled makes it happen again

@simplecommerce
Copy link

Couldn't find the throttle setting mentioned by @issacgerges and where to change it.
But I uninstalled chrome completely and reinstalled it (fresh copy, wiping out all settings) and it fixed it for me.

@issacgerges
Copy link

issacgerges commented Aug 11, 2021

Could be worth opening a Chromium ticket, but from similar experience this is likely by design. Maybe they could exclude devtools extensions here?

I think the fact that this is deep in the ResizeObserver polyfill resize detection might make it painful to fix in the short term. Maybe it's best to create a branch off of react-virtualized-auto-sizer thats used for the plugin that removes the raf from the scheduler array

Alternatively it feels like that polyfill detection deserves a naive check around document.visiblityState and preferring setTimeout over requestAnimationFrame when hidden.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 11, 2021

Fantastic find, @issacgerges!

Seems like react-virtualized-auto-sizer could detect this case (no rAF firing by a certain time) and maybe fallback to using a timer or other debounce technique.

@issacgerges
Copy link

issacgerges commented Aug 12, 2021

I saw you just picked this up @bvaughn, if you have issues in development I have seen Chromium make timers minute aligned when doing background throttling. It's possible it may do the same in this case. If that's the case I know setImmediate polyfills have a trick with a self postMessage that could be used.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 12, 2021

Thanks for the pointer, @issacgerges. Happen to have a code pointer?

@issacgerges
Copy link

Sure! Here's the setImmediate strategy I was thinking of
https://github.com/YuzuJS/setImmediate/blob/f1ccbfdf09cb93aadf77c4aa749ea554503b9234/setImmediate.js#L99-L122

and here is a reference to the timer alignment I've seen mentioned (not 100% sure it will apply here)
https://www.chromestatus.com/feature/4718288976216064

@bvaughn
Copy link
Contributor

bvaughn commented Aug 12, 2021

Super helpful. Thanks!

@bvaughn
Copy link
Contributor

bvaughn commented Aug 12, 2021

I'm overlooking some important detail here.

Enabling/disabling the "Throttle non-visible cross-origin iframes" flag does indeed trigger/fix the bug, but even when this is disabled– animation frames still get called based on my testing, unlike what @issacgerges reported above:

In this case, if I debug this script, I can see that scheduling any raf in main.html of the devtool will never fire.

(So my idea to detect this case and fallback to a timeout doesn't work.)

That being said, just replacing requestAnimationFrame with setTimeout (and not trying to detect support) fixes the broken behavior.

@issacgerges
Copy link

@bvaughn ah interesting. Just to validate are you registering those requestAnimationFrame callbacks from the context of main.html or panel.html. I believe they will only fail to fire from main.html (which is the hidden iframe)

@bvaughn
Copy link
Contributor

bvaughn commented Aug 12, 2021

@issacgerges I added logging to the feature detection code I wrote (which runs in the same context as the detectElementResize script).

bvaughn pushed a commit to bvaughn/react-virtualized-auto-sizer that referenced this issue Aug 13, 2021
Chrome's new "Throttle non-visible cross-origin iframes" flag causes problems for code running inside of hidden iframes. In this case, animation frames get scheduled without any error but never get called. This causes problems for the React DevTools browser extension specifically.

This commit adds a workaround by scheduling a backup timeout along with animation frames. In the normal case, these timeout will be cancelled by the animation frame (which will run first).

For more info, see facebook/react#21986
@bvaughn
Copy link
Contributor

bvaughn commented Aug 13, 2021

Fixed it by adding a fallback timeout when rAF is used ☹️ Doesn't feel great but...

bvaughn/react-virtualized-auto-sizer#39

@bvaughn
Copy link
Contributor

bvaughn commented Aug 13, 2021

Thanks a ton for the info @issacgerges and @gabriel-peracio

@bvaughn
Copy link
Contributor

bvaughn commented Aug 13, 2021

This fix has landed. We'll probably release it next week because we're also waiting on another bugfix to unblock the Firefox release.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 20, 2021

smart94423 added a commit to smart94423/react-virtualized-auto-sizer that referenced this issue Jan 30, 2024
Chrome's new "Throttle non-visible cross-origin iframes" flag causes problems for code running inside of hidden iframes. In this case, animation frames get scheduled without any error but never get called. This causes problems for the React DevTools browser extension specifically.

This commit adds a workaround by scheduling a backup timeout along with animation frames. In the normal case, these timeout will be cancelled by the animation frame (which will run first).

For more info, see facebook/react#21986
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.