Skip to content

Plugin RFC #305

@RobPruzan

Description

@RobPruzan

Plugin RFC: A plugin system for React Scan

Motivation

Long Term Goals

The original motivation for creating React Scan was to help people improve performance on their website. Not specifically to make a tool for visualizing re-renders.

Over the last few months, we have attempted to make easy to use tools on top of React Scan that furthers this goal- "what changed" state/props/context viewer, component tree, slowdown notifications + profiler.

These solutions are all scoped to React. But, React related problems is an arbitrary boundary for a devtool trying to generally help people fix performance issues.

We increasingly want to introduce more features that generally show you problems and how to fix them. The slowdown notifications feature is mostly framework agnostic, other than then the render time visualization- we provide a couple useful insights that are not specific to React inside notifications.

But, a large risk in implementing more non-React features is increasing scope too far of React Scan, and creating a large number of features that are all not quite good enough for a large set of projects.

This also risks making the project itself too hard to maintain under current resources.

Feature re-use

We have noticed large interest in other frameworks/libraries/projects re-using specific features of React Scan in their own toolchain, see one.js integration and radon ide integration

This requires significant effort by third parties since our internal features are deeply coupled.

For core maintainers, unrelated features being coupled make it difficult to add more features. Every new feature add's n^~2 new interactions between features, making it very hard to maintain and keep reliable.

Solution

The solution to this is to build a plugin system for React Scan, where each individual feature is implemented as a plugin, which hooks into the React Scan backend.

Re-render outlines, component selector, and notifications slowdown will be implemented against common public plugin API.

One example of a useful plugin somebody can build on top of this system is one that pushes custom spans associated with a slowdown. This will let arbitrary performance data be rendered on our ranked bar chart in the notification slowdown view.

A plugin like this could push non-React data to our visualizers- for example, a script made for Vue, that tracks Vue component render times and pushes that data to React Scan Notifications. When a slowdown happens, you will see a visualization on Vue components, not React.

There are also existing attempts to implement React Scan features for other frameworks, which can be implemented as React Scan plugins. For example, see a svelete version of react-scan

Internally, we have experimented with building tools that help you find general performance problems (e.g. a slow image detector), but couldn't find a place for it inside the current toolbar. With a plugin system, they can be released outside of the context of React Scan as plugins.

Plugins would be able to access our canvas drawing API's, React Scan Internal's, and have ways to visualize content inside of our toolbar.

For people making performance related devtools, building a plugin ontop of React Scan will allow the person to only think about writing the solution that impacts the user. React Scan handles toolbar logic, accessibility, UI Patterns, and common API's you will need to create your own visualizations/custom UI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions