-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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]: React DevTools Profiler freezes after recording multiple events #31977
Comments
@MariniGraphicDesigner try to clear your local cache. |
I'm encountering this issue as well. Recording even for a few seconds in profiler, then stopping, paints the flame graph successfully, but then all future clicks to the UI do not do anything. Closing dev tools then reopening, the react dev tools are no longer available in the tab bar. |
I started using react just today and encountered this while going over the devtools. I am attaching a video of the behaviour. It seems to freeze whenever i have previous profiling data present and I try to press start profiling. 20250112-1028-59.9864090.mp4If you clear the profiling data before pressing start profiling button or press the reload and start profiling it works |
I also have the exact same problem. After the Profiler tab freezes, even closing and reopening causes the React DevTools to disappear. I can also confirm that the video by @GaneshS288 shows the same behavior that happens to me and that I tried to describe in my post. |
I believe I have pinpointed the exact reason why this is happening. Profiling works fine the first time, but subsequently, the Dev Tools enter an infinite loop of state updates. It begins with a call to the However, when you pause execution using a debugger in the |
…#32066) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary This pull request resolves an issue where consecutive profiling sessions would cause Dev Tools to freeze due to an infinite loop of state updates. The problem occurs when the startProfiling function triggers a call to [`selectCommitIndex(0)` in SnapshotSelector](https://github.com/facebook/react/blob/b3a95caf61bc716fb618997e6e9f3a0c8c9c8374/packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js#L77-L85) as previous profiling data is available, which causes a re-render. Then, [ProfilerContextProvider calls `selectCommitIndex(null)`](https://github.com/facebook/react/blob/b3a95caf61bc716fb618997e6e9f3a0c8c9c8374/packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js#L231-L241) to clear the view while profiling is in progress, leading to another re-render and creating an infinite loop. This behavior was prevented by clearing the existing profiling data before starting a new session. Closes #31977 Closes #31679 ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> I ran the Dev Tools locally following [the contributing guideline](https://github.com/facebook/react/blob/b3a95caf61bc716fb618997e6e9f3a0c8c9c8374/packages/react-devtools/CONTRIBUTING.md). I observed the freeze at the start of the second profiling session. Then, I modified the code to clear the store when starting a new session and ran the Dev Tools again. This time, no freeze was observed. Before: https://github.com/user-attachments/assets/9d790f84-f6d0-4951-8202-e599cf8d225b After: https://github.com/user-attachments/assets/af097019-0b8f-49dd-8afc-0f6cd72af787
Website or app
localhost
Repro steps
I'm experiencing an issue with React DevTools while debugging a project locally. Here are the steps to reproduce the issue:
I hope these details help in identifying and resolving the issue. Let me know if you need further information or clarification.
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
The text was updated successfully, but these errors were encountered: