-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Scheduling Profiler: Move preprocessing to web worker and add loading indicator #19759
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit cd1f3c4:
|
b3e8313
to
283bc76
Compare
Looks like the error handling is now broken with fast refresh. I haven't managed to find the cause yet, but here are some guesses:
Any idea, @bvaughn? I can look into this further tomorrow too. |
Likely won't have time to look into this today. |
👍 No problem! I'll continue poking tomorrow. |
Looks like this was not a good fit for error boundaries. See: facebook/create-react-app#6530 (comment)
283bc76
to
cd1f3c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, it's fixed! Looks like it just wasn't a good use case for error boundaries.
This is ready for review, @bvaughn :)
packages/react-devtools-scheduling-profiler/src/import-worker/import.worker.js
Show resolved
Hide resolved
const [profilerData, setProfilerData] = useState<ReactProfilerData | null>( | ||
null, | ||
); | ||
type DataResource = Resource<void, File, ReactProfilerData | Error>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not sure if storing data + import errors in a resource is the cleanest approach. I'm doing this to handle these expected/intentional errors without throwing them and using error boundaries. Any idea how I can improve this?
Something else occurs to me that I don't know the answer for: Will this change make merging the new profiler into DevTools harder? I think extensions support workers but I've never done it before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to hold off on merging this until you've had a chance to respond to the previous two messages, but overall this looks good to me 👍
Ouch! I've just tried using the 57MB facebook.com profile that you sent us, and it seems like there's a difference between the project from the fellowship and what we currently have on On https://react-scheduling-profiler.vercel.app/ (currently still deployed from the MLH Fellowship repo), I'm getting ~5 seconds On a prod build of the On a prod build of this branch, I'm getting the same ~11 seconds |
Oh, interesting. I was just testing against react-scheduling-profiler.vercel.app rather than switching between master and rebuilding. Would be good for us to follow up and figure out what deopted us, but I guess that shouldn't hold up this merge then. |
Yeah, I'll look into this further next week.
I don't know either 😆 I did think about this, and I figured that since there's very little code needed to use web workers it shouldn't be a big issue when integrating this into DevTools. In the worst case, we can probably just remove the web worker entirely. |
Sounds good. Let's merge this then for now, to keep the train rolling. We'll dig in more later. |
… indicator (facebook#19759) * Move preprocessData into a web worker * Add UI feedback for loading/import error states * Terminate worker when done handling profile * Add display density CSS variables
Builds on #19707 to further improve the UI/UX by:
preprocessData
call into a new web worker. This previously caused the UI to freeze for a significant amount of time (the facebook.com we have freezes my browser for >10 seconds).ProcessingData
component is copied from the React DevTools Profiler.cc @bvaughn, @kartikcho
Implementation notes
Resource
implementation inreact-devtools-shared
without forking it.UI notes
It's possible to load a second profile while the first one is still loading. I think this is fine from both UI and technical perspectives: users may want to select another profile if they selected the wrong profile/the profile is taking too long to load, and our implementation only displays the latest selected profile.
This is what it looks like:
Here's what's happening in the gif: