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 scroll-to error or warning feature broken #22143

Closed
bvaughn opened this issue Aug 19, 2021 · 5 comments · Fixed by #22144
Closed

DevTools scroll-to error or warning feature broken #22143

bvaughn opened this issue Aug 19, 2021 · 5 comments · Fixed by #22144

Comments

@bvaughn
Copy link
Contributor

bvaughn commented Aug 19, 2021

Not sure when this happened, but the feature got broken:

scroll-to-broken.mp4

Using the up/down arrows to navigate the list works fine, but jumping to the next/previous component with a warning or error doesn't quite work correctly. (The scroll offset is wrong so the component is often not visible.)

@iunfixit
Copy link

I cannot reproduce this unless I'm doing something wrong, tested with errors here

ErrorJump

The part where it is selected outside of the view is because of the recording, it never goes behind the console

@bvaughn
Copy link
Contributor Author

bvaughn commented Aug 20, 2021

I wonder if this is related to a Chrome experimental flag? I can repro in both Chrome stable and canary.

@eps1lon
Copy link
Collaborator

eps1lon commented Aug 20, 2021

I can reproduce on Version 92.0.4515.159 (Official Build) (64-bit) (with and without our good friend "Throttle non-visible cross-origin iframes" enabled).

Though it does scroll. It just is a bit offset. It also seems to work on upward movement if the current node is already in the frame.

Notice how the scrollbar actually moves:

devtools-scroll-to-warning.mp4

@eps1lon
Copy link
Collaborator

eps1lon commented Aug 20, 2021

When we call store.getElementsWithErrorsAndWarnings() we get a cached list of elements with their indices and ids. The problem is that we only update this list when errors or warning change. But the indices of these elements can change with other operations as well so we need to invalidate the cache more often (or at least update the indices).

If I just naively invalidate the cache on every operation, the issue is no longer reproducible:

diff --git a/packages/react-devtools-shared/src/devtools/store.js b/packages/react-devtools-shared/src/devtools/store.js
index 16bc56ae64..af2ed945c4 100644
--- a/packages/react-devtools-shared/src/devtools/store.js
+++ b/packages/react-devtools-shared/src/devtools/store.js
@@ -1124,7 +1124,7 @@ export default class Store extends EventEmitter<{|
 
     this._revision++;
 
-    if (haveErrorsOrWarningsChanged) {
+    if (true) {
       let errorCount = 0;
       let warningCount = 0;
 

I may have an idea how to update the cache more "smartly".

@iunfixit
Copy link

iunfixit commented Aug 20, 2021

I wonder if this is related to a Chrome experimental flag? I can repro in both Chrome stable and canary.

I only tested with the default instead of enabled, because when it is enabled it freezes everything, I am using Brave 1.28.105 Chromium: 92.0.4515.131, DevTools version 4.16.0-1d2528097. Same behavior on Chromium(without Brave) 92.0.4515.159.
I also notice sometimes the tool doesn't work, unless I change the code and it hot reloads

ErrorJumpNotShowing

The code is just modified from the latest CRA
import logo from './logo.svg';
import './App.css';
import React from 'react'

const Err = () => [`a`, `b`, `d`].map(i => <p key={1}>something</p>);
const TenDivs = () => <><div/><div/></>
const Div = () => <div><Err/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><TenDivs/><Err/><Err/></div>;

function App() {
  return (
    <div className="App">
      <header className="App-header"> <Div/>
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p> 
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a> <Div/> <Div/> <Div/> <Div/>
          <Div/>
          <Div/>
          <Div/>
          <Div/>
          <Div/>
          <Div/>
          <Div/>
          <Div/>
          <Div/>
          <Div/>
        <Err/>
      </header> 
    </div>
  );
}

export default App;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants