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

Add Fiber Debugger #8033

Merged
merged 3 commits into from
Oct 25, 2016
Merged

Add Fiber Debugger #8033

merged 3 commits into from
Oct 25, 2016

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Oct 21, 2016

Fiber Debugger

This is a debugger handy for visualizing how Fiber works internally.

It is only meant to be used by React contributors, and not by React users.

It is likely that it might get broken at some point. If it's broken, ping Dan.

Running

First, npm run build in React root repo folder.

Then npm install and npm start in this folder.

Open http://localhost:3000 in Chrome.

Features

  • Edit code that uses ReactNoop renderer
  • Visualize how relationships between fibers change over time
  • Current tree is displayed in green

fiber debugger

This lets us consume it from the debugger.
@@ -61,219 +62,231 @@ function flattenChildren(children : HostChildren<Instance | TextInstance>) {
return flatArray;
}

var NoopRenderer = ReactFiberReconciler({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are just indentation changes + pass options.debugTool through to the reconciler.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

This comment is meant to be an alternative, and preferred, solution instead of the other comments.

The most important thing to me is that we can easily strip this out today because I don't want to have to skip through and worry about this when we micro-optimize.

It is also important that we don't expose this to the public renderer API so that others don't start building devtools with it, or that we start building public devtools that rely on the fiber structure.

It seems to me that the use of this tool means that you're inside the React debugging environment and therefore you have access to your own build.

So you can just create a global devtool module that can get a dynamic injection from anywhere. Just like ReactInstrumentation/ReactDebugTool does.

Then you hide that behind a __DEV__ or __REACT_DEV__ flag that we can filter out so it doesn't get packaged.

That way you don't have to expose a custom constructor for each renderer to invoke this. You don't have to pass it around anyway. You can just require it globally and the tool can just attach to the instrumentation.

scheduleDeferredCallback(callback : (deadline : Deadline) => void) : void
scheduleDeferredCallback(callback : (deadline : Deadline) => void) : void,

debugTool : DebugTool | null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think the debug tool should be part of the host environment since we can use this with any host environment.

Adding things to this API should come with a very high bar since it makes it difficult to implement new renderers and it create a permanent type that we have to support.

It would be better if you passed this as a separate argument, separate from HostConfig.

E.g. just pass it as debugTool parallel to config in the places you need it.

} else {
// Otherwise, complete the current work.
return completeUnitOfWork(workInProgress);
if (debugTool) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should wrap all of these in __DEV__ before we have the infrastructure in place to statically DCE them.

@gaearon
Copy link
Collaborator Author

gaearon commented Oct 24, 2016

@sebmarkbage Addressed.

@sebmarkbage
Copy link
Collaborator

ok!

@gaearon gaearon merged commit 225325e into facebook:master Oct 25, 2016
@keyz keyz mentioned this pull request Oct 25, 2016
@gaearon gaearon deleted the fiber-debugger branch November 21, 2016 18:01
acusti pushed a commit to brandcast/react that referenced this pull request Mar 15, 2017
* Build react-noop as a package

This lets us consume it from the debugger.

* Add instrumentation to Fiber

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

Successfully merging this pull request may close these issues.

3 participants