Skip to content

Add react devtools profiler support #1117

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Conversation

kmagiera
Copy link
Member

@kmagiera kmagiera commented Apr 24, 2025

This PR adds a new tool – React Profiler

React Profiler integration allows controlling (starting/stopping) of the profile via React Devtools and also to open the profiles in a standalone editor panel.

rprofiler.mp4

Below is an overview of the changes made in this PR:

  • We use devtools-hedless package to access react devtools' profiler store to control the profiling
  • When profiling is finished, we use the export method exposed via devtools-headless package to dump the profile into a file and save under '.reactprofile' extension
  • We're implementing a new editor provider that can open '.reactprofile' files. The editor uses the devtools-inline package to present the UI and uses the profile import method from devtools-headless package to process the profile data.
  • We're adding buttons to the tools menu to initiate the profiling and use the CPU profiling style indicator when the profiler is running.
  • We're updating vite configuration – for some reason after adding a new input, vite in release mode started splitting CSS into more chunks. Before it was just main chunk and theme chunk. Instead of adding more dependencies I decided it will be easier to force it to not do chunking at all and use single style.css for all the webviews.
  • We are adding additional options to the webview CSP because devtools use JS's eval and also boot up a worker thread using blob URL.

How Has This Been Tested:

  1. Open IDE panel and wait for app to load
  2. Click "Start React Profiler"
  3. Observe a profiler indicator appear (similar as with the CPU profiling)
  4. Do something with the app
  5. Click stop
  6. The profiler will stop (indicator is gone) and a profile will be automatically opened in a new editor tab
  7. Run everything in release mode (DEV=false in weviewContentGenerator) – check other panels like network to make sure vite changes didn't mess something up

Copy link

vercel bot commented Apr 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2025 10:45am

Copy link
Collaborator

@filip131311 filip131311 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that the react profiler has an option to be displayed in light mode, if it is possible to set it in the hedless package we use, I think it would look much better for users that use light mode in their vscode

image

@kmagiera
Copy link
Member Author

forgot about that, just made an update to account for the theme

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

Successfully merging this pull request may close these issues.

2 participants