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

Move instrumentation from isomorphic to renderers/shared #6797

Closed
gaearon opened this issue May 18, 2016 · 12 comments
Closed

Move instrumentation from isomorphic to renderers/shared #6797

gaearon opened this issue May 18, 2016 · 12 comments
Assignees

Comments

@gaearon
Copy link
Collaborator

gaearon commented May 18, 2016

Per @sebmarkbage, we want isomorphic folder to only contain the code necessary to author React components. It should not have dependencies on ReactInstrumentation, ReactDebugTool, and devtools/* friends, which themselves should be moved to renderers/shared/.

The only caller we to ReactInstrumentation we have right now in that folder is onSetState() inside ReactComponent. We need to move it somewhere inside the renderer (e.g. in the update queue implementation).

Labeling it as a good first bug because this mostly involves moving files. The goal is that files in isomorphic folder don’t contain anything that references ReactInstrumentation.

This is up for grabs but I’ll do it myself if no one takes it.

@iamdustan
Copy link
Contributor

Should ReactPerf also move out to renderers/shared/?

iamdustan added a commit to iamdustan/react that referenced this issue May 19, 2016
@sebmarkbage
Copy link
Collaborator

Yea.

@gaearon Do you have a plan for how the new perf tool API will be used since it is tied to a particular renderer? It is the only of the add-ons that does that.

@gaearon
Copy link
Collaborator Author

gaearon commented May 19, 2016

I don't quite understand what you're asking. From user's point of view it is used the same way as before, through react-addons-perf. If you create a third party renderer you'll need to emit some events to tell it what's going on, but I don't see this as being "tied" to RN or DOM renderers.

gaearon added a commit that referenced this issue May 19, 2016
Move instrumentation to renderers/shared. Closes #6797
@sebmarkbage
Copy link
Collaborator

@gaearon react-addons-perf currently requires react/lib/ReactDefaultPerf. After #6795 there won't be such a file because it will live in react-dom/lib/ReactDefaultPerf. However, that only works for DOM. For React Native, we'd have to require react-native/lib/ReactDefaultPerf.

@gaearon
Copy link
Collaborator Author

gaearon commented May 19, 2016

I still don’t quite understand what you want to do in #6795. Why is react-addons-perf affected by this but other addons are not?

@sebmarkbage
Copy link
Collaborator

Currently both react-dom and react-native uses the same instance of all the shared modules. It uses runtime dependency injection to determine which environment actually gets used. The idea is to copy all the modules to each one of them, except the isomorphic ones. That way multiple renderers can coexist on npm, but more importantly they can be versioned independently.

This means that there will be two copies of the ReactPerf modules on npm. One in each renderer.

The alternative would be that we keep ReactPerf and the debug tool in isomorphic and have renderers register themselves there somehow.

The other addons are not affected because they only depend on things in the isomorphic folder which will remain shared.

@gaearon
Copy link
Collaborator Author

gaearon commented May 19, 2016

Do I understand correctly that you are concerned that changes to ReactDebugTool (e.g. adding new events) will force us to release isomorphic react more often, and will force us to keep react-dom and react-native versioned more closely together than we would have preferred otherwise?

@iamdustan
Copy link
Contributor

Is the intent also to get away from the current dependency injection? Would this allow multiple independent renderers to coexist in a runtime environment as well? (Possible upcoming scenario: ReactDOM and ReactART, with ReactDOM using the current reconciler and ART using the incremental reconciler)

@sebmarkbage
Copy link
Collaborator

@iamdustan Yes, that is an imminent upcoming scenario.

@sebmarkbage
Copy link
Collaborator

@gaearon I'm more concerned about the events not making sense across renderers, but I guess we already tried to make that very generic so maybe that's unfounded.

I'm concerned about having too much in the isomorphic package. It is supposed to be small.

I'm also concerned about having stateful modules in the isomorphic package. It would be nice to let react be a direct dependency instead of peerDependency. But there are also practical issues such as that it is difficult that beginX and endX calls aren't nested inside each other when there are two different renderers doing different work on the same stateful module.

I think ReactInstrumentation and ReactDebugTool should at least be on a per renderer level.

ReactPerf itself is more like one tool of many that could connect to any number of renderers that have a ReactDebugTool hook. It could live in the react-addons-perf package.

Then we'd need some way to connect them up. For UI based tools such as the Chrome React DevTools, we've used a global variable to coordinate. That way it doesn't matter how npm nests the packages and it doesn't matter which module loads first. The perf tool or the renderer.

Not sure how we'd solve this with a programmatic API though.

One solution would be to expose the ReactInstrumentation module on the renderer and then you have to register it to get a paired up perf tool.

var ReactDOMPerf = require('react-addons-perf')(require('react-dom'));

If we're comfortable with react remaining a peerDependency, we could have every renderer register their instrumentation. react-dom would call:

require('react').registerRendererInstrumentation(require('ReactInstrumentation'));

Then the perf tool can be a summary of all renderers ever registered.

@sebmarkbage
Copy link
Collaborator

I'm offering problems more than solutions. Eager to hear your proposals.

Btw, a design goal was to allow third parties doing something like ReactInstrumentation.debugTool = totallyCustomTool; which would have full access to custom profiling etc.

@gaearon
Copy link
Collaborator Author

gaearon commented May 20, 2016

Thanks, I understand it better now. I created #6812 to track this and will share my thoughts next week.

zpao pushed a commit to zpao/react that referenced this issue Jun 8, 2016
…ared

Move instrumentation to renderers/shared. Closes facebook#6797
(cherry picked from commit d125682)
zpao pushed a commit that referenced this issue Jun 14, 2016
Move instrumentation to renderers/shared. Closes #6797
(cherry picked from commit d125682)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants