Commit Graph
187 Commits
Author SHA1 Message Date
Brian VaughnandGitHub 5894f18aa3 [FB-only] Show which hooks (indices) changed when profiling (#20998) 2021-03-17 12:28:21 -04:00
Brian VaughnandGitHub 0a5bf1a801 DevTools Profiler: Add commit and post-commit durations to UI (#20984) 2021-03-17 12:27:37 -04:00
4636cf1bdd Ensure sync-xhr is allowed before reload and profile (#20879)
Co-authored-by: Brian Vaughn <[email protected]>
2021-03-11 10:31:57 -05:00
Brian VaughnandGitHub d6004f38b7 Remove DevTools dependency on Scheduler runWithPriority (#20967) 2021-03-10 08:52:19 -05:00
Brian VaughnandGitHub 57b0df9d81 Swap log with cbrt for commit bar height (#20952) 2021-03-08 14:02:09 -05:00
9ac2eb25ed DevTools flushes updated passive warning/error info after delay (#20931)
* DevTools flushes updated passive warning/error info after delay
Previously this information was not flushed until the next commit, but this provides a worse user experience if the next commit is really delayed. Instead, the backend now flushes only the warning/error counts after a delay. As a safety, if there are already any pending operations in the queue, we bail.

Co-authored-by: eps1lon <[email protected]>
2021-03-08 11:33:14 -05:00
Brian VaughnandGitHub 1a0d48a91f Improve DevTools Profiler commit-selector UX (#20943)
* Improve DevTools Profiler commit-selector UX

1. Use natural log of durations (rather than linear) when calculating bar height. This reduces the impact of one (or few) outlier times on more common smaller durations. (Continue to use linear for bar color though.)
2. Decrease the minimum bar height to make the differences in height more noticeable.
3. Add a background hover highlight to increase contrast.
4. Add hover tooltip with commit duration and timestamp.
2021-03-08 11:09:55 -05:00
Brian VaughnandGitHub 1375341bdc DevTools: Restore inspect-element bridge optimizations (#20789)
* Restore inspect-element bridge optimizations

When the new Suspense cache was integrated (so that startTransition could be used) I removed a couple of optimizations between the backend and frontend that reduced bridge traffic when e.g. dehydrated paths were inspected for elements that had not rendered since previously inspected. This commit re-adds those optimizations as well as an additional test with a bug fix that I noticed while reading the backend code.

There are two remaining TODO items as of this commit:
- Make inspected element edits and deletes also use transition API
- Don't over-eagerly refresh the cache in our ping-for-updates handler

I will addres both in subsequent commits.

* Poll for update only refreshes cache when there's an update

* Added inline comment
2021-02-22 14:04:20 -05:00
Matt WoodandGitHub f6bad6edcc Fix typo in comment for react-devtools-shared (#20459) 2021-02-10 23:35:24 -05:00
Dan AbramovandGitHub 84054f55ca Remove the Fundamental internals (#20745) 2021-02-05 20:36:55 +00:00
Brian VaughnandGitHub b057b3d4ea DevTools: Patch console methods even when only show-inline-warnings/errors enabled (#20688) 2021-02-02 10:19:53 -05:00
Sebastian SilbermannandGitHub 63e7d4debb fix: don't run effects if a render phase update results in unchanged deps (#20676)
The memoized state of effect hooks is only invalidated when deps change. Deps are compared between the previous effect and the current effect. This can be problematic if one commit consists of an update that has changed deps followed by an update that has equal deps. That commit will lead to memoizedState containing the changed deps even though we committed with unchanged deps.

The n+1 update will therefore run an effect because we compare the updated deps with the deps with which we never actually committed.

To prevent this we now invalidate memoizedState on every updateEffectImpl call so that memoizedStat.deps always points to the latest deps.
2021-01-29 10:51:11 -05:00
Brian VaughnandGitHub 5559348caa DevTools: Make it easier to write tests for inspected elements (#20655)
And also add a few tests for  which also cover a recent bugfix that just landed
2021-01-25 14:58:19 -05:00
Berton ZhuandGitHub 82b6930f61 Devtool: $r should contain hooks property when it is forwardRef or memo component (#20626) 2021-01-25 10:35:02 -05:00
29afa88383 [devtools] Fix can't expand prop value in some scenario (#20534)
Co-authored-by: Brian Vaughn <[email protected]>
2021-01-19 10:26:52 -05:00
Brian VaughnandGitHub c00f873bac Update DevTools to use getCacheForType API (#20548)
DevTools was built with a fork of an early idea for how Suspense cache might work. This idea is incompatible with newer APIs like `useTransition` which unfortunately prevented me from making certain UX improvements. This PR swaps out the primary usage of this cache (there are a few) in favor of the newer `unstable_getCacheForType` and `unstable_useCacheRefresh` APIs. We can go back and update the others in follow up PRs.

### Messaging changes

I've refactored the way the frontend loads component props/state/etc to hopefully make it better match the Suspense+cache model. Doing this gave up some of the small optimizations I'd added but hopefully the actual performance impact of that is minor and the overall ergonomic improvements of working with the cache API make this worth it.

The backend no longer remembers inspected paths. Instead, the frontend sends them every time and the backend sends a response with those paths. I've also added a new "force" parameter that the frontend can use to tell the backend to send a response even if the component hasn't rendered since the last time it asked. (This is used to get data for newly inspected paths.)

_Initial inspection..._
```
front |                                                      | back
      | -- "inspect" (id:1, paths:[], force:true) ---------> |
      | <------------------------ "inspected" (full-data) -- |
```
_1 second passes with no updates..._
```
      | -- "inspect" (id:1, paths:[], force:false) --------> |
      | <------------------------ "inspected" (no-change) -- |
```
_User clicks to expand a path, aka hydrate..._
```
      | -- "inspect" (id:1, paths:['foo'], force:true) ----> |
      | <------------------------ "inspected" (full-data) -- |
```
_1 second passes during which there is an update..._
```
      | -- "inspect" (id:1, paths:['foo'], force:false) ---> |
      | <----------------- "inspectedElement" (full-data) -- |
```

### Clear errors/warnings transition
Previously this meant there would be a delay after clicking the "clear" button. The UX after this change is much improved.

### Hydrating paths transition
I also added a transition to hydration (expanding "dehyrated" paths).

### Better error boundaries
I also added a lower-level error boundary in case the new suspense operation ever failed. It provides a better "retry" mechanism (select a new element) so DevTools doesn't become entirely useful. Here I'm intentionally causing an error every time I select an element.

### Improved snapshot tests
I also migrated several of the existing snapshot tests to use inline snapshots and added a new serializer for dehydrated props. Inline snapshots are easier to verify and maintain and the new serializer means dehydrated props will be formatted in a way that makes sense rather than being empty (in external snapshots) or super verbose (default inline snapshot format).
2021-01-19 09:51:32 -05:00
Brian VaughnandGitHub 0e9cf4d68c Add rudimentary support for Cache to DevTools (#20458) 2021-01-04 09:32:03 -05:00
Brian VaughnandGitHub 6b93e4cf16 React Native fixes for new inline errors feature (#20502) 2020-12-22 13:58:47 -05:00
91e2ddbda9 Expose DEV-mode warnings in devtools UI (#20463)
Co-authored-by: Brian Vaughn <[email protected]>
2020-12-22 11:09:29 -05:00
Sebastian SilbermannandGitHub 3e9b343c0b devtools: Display shortcuts for prev/next search result (#20470) 2020-12-20 21:48:36 -05:00
Oliver LassenandGitHub d421c74633 [devtools] Increase the clickable area of the prop value (#20428) 2020-12-14 16:23:26 -05:00
Brian VaughnandGitHub e7663c18b0 Add more DevTools tests for React.Lazy (#20380) 2020-12-06 09:10:15 -05:00
Brian VaughnandGitHub bec1ab8cf5 Fixed invalid DevTools work tags (#20362)
* Fixed invalid DevTools work tags

Work tags changed recently (PR #13902) but we didn't bump React versions. This meant that DevTools has valid work tags only for master (and FB www sync) but invalid work tags for the latest open source releases. To fix this, I incremneted React's version in Git (without an actual release) and added a new fork to the work tags detection branch.

This commit also adds tags for the experimental Scope and Fundamental APIs to DevTools so component names will at least display correctly. Technically these new APIs were first introduced to experimental builds ~16.9 but I didn't add a new branch to the work tags fork because I don't they're used commonly. I've just added them to the 17+ branches.

* Removed FundamentalComponent from DevTools tag defs
2020-12-01 10:33:32 -05:00
Sebastian MarkbågeandGitHub c4723c3a8f Remove Blocks (#20138)
* Remove Blocks

* Remove Flight Server Runtime

There's no need for this now that the JSResource is part of the bundler
protocol. Might need something for Webpack plugin specifically later.

* Devtools
2020-10-30 23:03:45 -07:00
Brian VaughnandGitHub abe673ce02 DevTools fix props editing for host components (#20055) 2020-10-19 15:21:41 -04:00
oltrepandGitHub d4bced18a1 Bump to latest eslint-config-fbjs (#20029)
* bump package to latest

* update files to respect lint

* disable object-type-delimiter rule to work with prettier

* disable rule to let flow check pass
2020-10-16 16:06:08 +01:00
IDrissAitHafidandGitHub 0458757b6a fixed unfound node error when Suspense is filtered (#20019)
* fixed unfound node error when Suspense is filtered

* added a test for filtered Suspense node
2020-10-15 14:45:23 -04:00
Brian VaughnandGitHub 03065f533b DevTools always overrides the dispatcher when shallow rendering (#20011)
This is done so that any effects scheduled by the shallow render are thrown away.

Unlike the code this was forked from (in ReactComponentStackFrame) DevTools should override the dispatcher even when DevTools is compiled in production mode, because the app itself may be in development mode and log errors/warnings.
2020-10-14 13:19:47 -04:00
ee0b42b19b handled a missing suspense fiber when suspense is filtered on the profiler (#19987)
Co-authored-by: Brian Vaughn <[email protected]>
2020-10-13 13:38:58 -04:00
Brian VaughnandGitHub 45099227df Fix bad null check in DevTools highlight code (#20010) 2020-10-13 13:08:12 -04:00
c766f6c82d [DevTools] Add DevTools forked Feature flags (#18994)
Also resolve an uncaught error in extension build (#18843).

Co-authored-by: Brian Vaughn <[email protected]>
Co-authored-by: Brian Vaughn <[email protected]>
2020-10-12 13:07:10 -04:00
Brian VaughnandGitHub ac3a932add Revert "DevTools: Improve browser extension iframe support (#19854)" (#19959)
This reverts commit dbc0833791.
2020-10-05 09:44:08 -04:00
dbc0833791 DevTools: Improve browser extension iframe support (#19854)
Co-authored-by: Joel DSouza <[email protected]>
Co-authored-by: Damien Maillard <[email protected]>
Co-authored-by: Brian Vaughn <[email protected]>
2020-09-23 16:56:13 -04:00
7cb091e206 Don't consumer iterators while inspecting (#19831)
Co-authored-by: Brian Vaughn <[email protected]>
2020-09-22 14:23:20 -04:00
Brian VaughnandGitHub 692f18378d Improve DevTools editing interface (#19774)
* Improve DevTools editing interface

This commit adds the ability to rename or delete keys in the props/state/hooks/context editor and adds tests to cover this functionality. DevTools will degrade gracefully for older versions of React that do not inject the new reconciler rename* or delete* methods.

Specifically, this commit includes the following changes:
* Adds unit tests (for modern and legacy renderers) to cover overriding props, renaming keys, and deleting keys.
* Refactor backend override methods to reduce redundant Bridge/Agent listeners and methods.
* Inject new (DEV-only) methods from reconciler into DevTools to rename and delete paths.
* Refactor 'inspected element' UI components to improve readability.
* Improve auto-size input to better mimic Chrome's Style editor panel. (See this Code Sandbox for a proof of concept.)

It also contains the following code cleanup:
* Additional unit tests have been added for modifying values as well as renaming or deleting paths.
* Four new DEV-only methods have been added to the reconciler to be injected into the DevTools hook: overrideHookStateDeletePath, overrideHookStateRenamePath, overridePropsDeletePath, and overridePropsRenamePath. (DevTools will degrade gracefully for older renderers without these methods.)
* I also took this as an opportunity to refactor some of the existing code in a few places:
  * Rather than the backend implementing separate methods for editing props, state, hooks, and context– there are now three methods: deletePath, renamePath, and overrideValueAtPath that accept a type argument to differentiate between props, state, context, or hooks.
  * The various UI components for the DevTools frontend have been refactored to remove some unnecessary repetition.

This commit also adds temporary support for override* commands with mismatched backend/frontend versions:
* Add message forwarding for older backend methods (overrideContext, overrideHookState, overrideProps, and overrideState) to the new overrideValueAtPath method. This was done in both the frontend Bridge (for newer frontends passing messages to older embedded backends) and in the backend Agent (for older frontends passing messages to newer backends). We do this because React Native embeds the React DevTools backend, but cannot control which version of the frontend users use.
* Additional unit tests have been added as well to cover the older frontend to newer backend case. Our DevTools test infra does not make it easy to write tests for the other way around.
2020-09-18 11:07:18 -04:00
Brian VaughnandGitHub 9b5275b9a3 Revert "DevTools: Improve browser extension iframe support (#19827)" (#19852)
This reverts commit 216081fb1c.
2020-09-17 14:57:44 -04:00
216081fb1c DevTools: Improve browser extension iframe support (#19827)
Co-authored-by: Joel DSouza <[email protected]>
Co-authored-by: Damien Maillard <[email protected]>
Co-authored-by: Brian Vaughn <[email protected]>
2020-09-14 10:04:46 -04:00
0d40530d94 React DevTools: Show symbols used as keys in state (#19786)
Co-authored-by: Brian Vaughn <[email protected]>
2020-09-14 09:55:19 -04:00
Andrew ClarkandGitHub 636cc7f810 Decouple public, internal act implementation (#19745)
In the next major release, we intend to drop support for using the `act`
testing helper in production. (It already fires a warning.) The
rationale is that, in order for `act` to work, you must either mock the
testing environment or add extra logic at runtime. Mocking the testing
environment isn't ideal because it requires extra set up for the user.
Extra logic at runtime is fine only in development mode — we don't want
to slow down the production builds.

Since most people only run their tests in development mode, dropping
support for production should be fine; if there's demand, we can add it
back later using a special testing build that is identical to the
production build except for the additional testing logic.

One blocker for removing production support is that we currently use
`act` to test React itself. We must test React in both development and
production modes.

So, the solution is to fork `act` into separate public and
internal implementations:

- *public implementation of `act`* – exposed to users, only works in
  development mode, uses special runtime logic, does not support partial
  rendering
- *internal implementation of `act`* – private, works in both
  development and productionm modes, only used by the React Core test
  suite, uses no special runtime logic, supports partial rendering (i.e.
  `toFlushAndYieldThrough`)

The internal implementation should mostly match the public
implementation's behavior, but since it's a private API, it doesn't have
to match exactly. It works by mocking the test environment: it uses a
mock build of Scheduler to flush rendering tasks, and Jest's mock timers
to flush Suspense placeholders.

---

In this first commit, I've added the internal forks of `act` and
migrated our tests to use them. The public `act` implementation is
unaffected for now; I will leave refactoring/clean-up for a later step.
2020-09-08 08:11:45 -07:00
Andrew ClarkandGitHub 073399d062 Rename effect fields (#19755)
- `effectTag` -> `flags`
- `subtreeTag` -> `subtreeFlags`
2020-09-04 14:34:07 -07:00
E-Liang TanandGitHub 18f5522989 Scheduling Profiler: Move preprocessing to web worker and add loading indicator (#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
2020-09-04 10:57:32 -04:00
e388fe3fd8 Scheduling Profiler: Redesign with DevTools styling (#19707)
Co-authored-by: Brian Vaughn <[email protected]>
2020-09-03 12:08:40 -04:00
0bcc429808 Add checkbox toggle for boolean values (#19714)
* added a checkbox which appears to the right of a value when value is boolean
* checkbox with toggle capability created for boolean props

Co-authored-by: Brian Vaughn <[email protected]>
2020-09-03 08:57:12 -04:00
Brian VaughnandGitHub 6f3a4a0408 Add ⎇ + arrow key navigation to DevTools (#19741)
⎇ + left/right navigates between owners (similar to owners tree) and ⎇ + up/down navigations between siblings.
2020-09-01 20:03:44 -04:00
Ben PernickandGitHub b1abeba70d Add SuspenseList to devTools (#19684)
* ensure getDisplayName is only called on functions

* add SuspenseList to Dev tools element names

* Add SuspenseList and pass tests

* Import SuspenseList directly

* run prettier

* Refactor tests to use real components

* run linter
2020-08-26 18:04:43 +01:00
6h057andGitHub 20d39cbfc1 Fix DevTools crash when inspecting document.all (#19619)
* Add html_all_collection type to correct typeof document.all

* process HTMLAllCollection like HTMLElement + fix flow issue

* fix lint

* move flow fix comment

* Make it work with iframes too

* optimize how we get html_all_collection type

* use once Object.prototype.toString.call
2020-08-21 14:31:16 +01:00
Sam MarksandGitHub 9a83027101 fix: property list values should show whitespace (#19640) 2020-08-19 08:50:46 -04:00
2bf141b574 refactor fb.me redirect link to reactjs.org/link (#19598)
* refactor fb.me url to reactjs.org/link

* Update ESLintRuleExhaustiveDeps-test.js

* Update ReactDOMServerIntegrationUntrustedURL-test.internal.js

* Update createReactClassIntegration-test.js

* Update ReactDOMServerIntegrationUntrustedURL-test.internal.js

Co-authored-by: Dan Abramov <[email protected]>
2020-08-17 13:25:50 +01:00
Pascal Fong KyeandGitHub 8fa4975389 DevTools bug fix: Proxied methods should be safely dehydrated for display 2020-08-12 12:15:53 -04:00
4b1315011f Support inner component _debugOwner in memo (#19556)
* Support inner component _debugOwner in memo

* test with devtool context

* remove memo test

* Merged master; tweaked test and snapshot

* Pass owner to createFiber fn when creating a memo component.

Co-authored-by: Theodore Han <[email protected]>
2020-08-10 10:49:10 -04:00