Commit Graph
283 Commits
Author SHA1 Message Date
Brian VaughnandGitHub 673d3256bd Added performance timings to DevTools named hooks parsing (#22173) 2021-08-25 15:39:15 -04:00
Brian VaughnandGitHub a932f1511b DevTools: Replaced WeakMap with LRU for inspected element cache (#22160)
We use an LRU for this rather than a WeakMap because of how the "no-change" optimization works.

When the frontend polls the backend for an update on the element that's currently inspected, the backend will send a "no-change" message if the element hasn't updated (rendered) since the last time it was asked. In thid case, the frontend cache should reuse the previous (cached) value. Using a WeakMap keyed on Element generally works well for this, since Elements are mutable and stable in the Store. This doens't work properly though when component filters are changed, because this will cause the Store to dump all roots and re-initialize the tree (recreating the Element objects).

So instead we key on Element ID (which is stable in this case) and use an LRU for eviction.
2021-08-23 19:22:31 -04:00
Holger BenlandGitHub 482d848170 [DevTools] Add options for disabling some features (#22136) 2021-08-20 12:55:50 -04:00
Brian VaughnandGitHub e1d53e4d33 DevTools: Reset cached indices in Store after elements reordered (#22147) 2021-08-20 12:53:28 -04:00
Sebastian SilbermannandGitHub 84f2e3a018 DevTools: update error indices when elements are added/removed (#22144) 2021-08-20 11:55:42 -04:00
Brian VaughnandGitHub b54e67dc6c Scheduling Profiler: Add network measures (#22112) 2021-08-18 12:17:59 -04:00
Brian VaughnandGitHub 80a6a5c73e Fixed Components tree indentation bug for Chrome extension (#22083)
By upgrading react-virtualized-auto-sizer to 1.0.6

See https://github.com/bvaughn/react-virtualized-auto-sizer/pull/39
2021-08-12 20:41:56 -04:00
Brian VaughnandGitHub 75998b720d Updated @reach packages to fix unmount bug (#22075) 2021-08-11 14:43:25 -04:00
Byron LukandGitHub b694529172 Devtools/function context change (#22047) 2021-08-10 14:16:54 -04:00
Brian VaughnandGitHub 104cd23817 Scheduling profiler: Added lane labels and durations to React measures (#22029) 2021-08-05 13:50:39 -04:00
Brian VaughnandGitHub abcc0fc26e DevTools scheduling profiler: Add React component measures (#22013) 2021-08-03 13:03:29 -04:00
Vyacheslav 'SLEL' SolominandGitHub 8f58479c00 [DevTools] Fix: highlight updates with memoized components (#22008) 2021-08-03 11:50:00 -04:00
Kevin ChavezandGitHub f2ec168af1 Switch on enableProfilerChangedHookIndices flag for OSS devtools builds (#22011) 2021-08-03 08:55:15 -04:00
Brian VaughnandGitHub c6ec6b99f1 DevTools: Scheduling profiler (#22006) 2021-08-02 14:30:43 -04:00
40d345be50 Devtools: Refactor imperative theme code (#21950)
Co-authored-by: Brian Vaughn <[email protected]>
2021-08-02 11:20:04 -04:00
Brian VaughnandGitHub 6c5dd58d02 Scheduling profiler UX changes (#21990) 2021-08-02 09:23:48 -04:00
65434875df Some remaining instances of master to main (#21982)
Co-authored-by: Shubham Pandey <[email protected]>
2021-07-30 08:56:55 -04:00
Piotr SzulcandGitHub c14bc9cf45 Devtools: Display as link if value is in specified protocols (#21964) 2021-07-28 09:29:13 -04:00
Brian VaughnandGitHub 146ac21caf Scheduling profiler: Improve native events UI (#21966)
Also highlight events that have synchronous updates inside of them. (We may want to relax this highlighting later to not warn about event handlers that are still fast enough.)
2021-07-26 19:30:43 -04:00
Brian VaughnandGitHub 30af515939 [DevTools] Add native events to the scheduling profiler (#21947) 2021-07-26 10:36:16 -04:00
Brian VaughnandGitHub ff12ccb0e2 [DRAFT] Import scheduling profiler into DevTools Profiler (#21897) 2021-07-22 13:58:57 -04:00
Lucas CorreiaandGitHub e59caaa3d5 DevTools: Parse named source AST in a worker (#21902)
Resolves #21855

Ended up using workerize in order to setup the worker once it allows easy imports (for babel's parse function) and exports.
2021-07-21 12:16:08 -04:00
Brian VaughnandGitHub 5685b8c1f2 Remove named hooks feature flag (#21894) 2021-07-16 00:14:20 -04:00
Brian VaughnandGitHub d7481d9745 Clear named hooks Suspense and AST cache after a Fast Refresh (#21891) 2021-07-15 23:39:30 -04:00
houssemchebebandGitHub 1b872f2b0b Fix typo (#21671) 2021-07-14 20:42:54 -04:00
76bd3c8299 Devtools Profiler: allow user to enter commit number (#19957)
Co-authored-by: Brian Vaughn <[email protected]>
2021-07-14 20:37:02 -04:00
Andrew ClarkandGitHub 2d9d27548c act: Batch updates, even in legacy roots (#21797)
In legacy roots, if an update originates outside of `batchedUpdates`,
check if it's inside an `act` scope; if so, treat it as if it were
batched. This is only necessary in legacy roots because in concurrent
roots, updates are batched by default.

With this change, the Test Utils and Test Renderer versions of `act` are
nothing more than aliases of the isomorphic API (still not exposed, but
will likely be the recommended API that replaces the others).
2021-07-12 17:15:20 -07:00
Andrew ClarkandGitHub b7bea5ca7a Bugfix: Flush legacy sync passive effects at beginning of event (#21846)
* Re-land recent flushSync changes

Adds back #21776 and #21775, which were removed due to an internal
e2e test failure.

Will attempt to fix in subsequent commits.

* Failing test: Legacy mode sync passive effects

In concurrent roots, if a render is synchronous, we flush its passive
effects synchronously. In legacy roots, we don't do this because all
updates are synchronous — so we need to flush at the beginning of the
next event. This is how `discreteUpdates` worked.

* Flush legacy passive effects at beginning of event

Fixes test added in previous commit.
2021-07-10 11:15:11 -07:00
Brian VaughnandGitHub aef8ae0177 Reset inspected element cache in the event of an error (#21821) 2021-07-08 14:07:15 -04:00
Brian VaughnandGitHub d26467e643 DevTool: hook names cache no longer loses entries between selection (#21831)
Made several changes to the hooks name cache to avoid losing cached data between selected elements:
1. No longer use React-managed cache. This had the unfortunate side effect of the inspected element cache also clearing the hook names cache. For now, instead, a module-level WeakMap cache is used. This isn't great but we can revisit it later.
2. Hooks are no longer the cache keys (since hook objects get recreated between element inspections). Instead a hook key string made of fileName + line number + column number is used.
3. If hook names have already been loaded for a component, skip showing the load button and just show the hook names by default when selecting the component.
2021-07-08 13:54:16 -04:00
Brian VaughnandGitHub bf04edd1ea DevTools show error icon when hook name parsing fails (#21820) 2021-07-07 16:27:39 -04:00
Brian VaughnandGitHub af79324ffa Reverting recent flushSync changes (#21816) 2021-07-07 15:07:55 -04:00
Brian VaughnandGitHub 91e90d06a1 DevTooks: Don't dehydrate hook source fileNames (#21814) 2021-07-07 14:24:17 -04:00
64cc858d3b [WIP] DevTools: Support named hooks for >1 module in a bundle (#21790)
* Add named hooks test case built with Rollup

* Fix prepareStackTrace unpatching, remove sourceURL

* Prettier

* Resolve source map URL/path relative to the script

* Add failing tests for multi-module bundle

* Parse hook names from multiple modules in a bundle

* Create a HookSourceData per location key (file, line, column).
* Cache the source map per runtime URL ( = file part of location key).
* Don't store sourceMapContents - only store a consumer instance.
* Look up original source URLs in the source map correctly.
* Cache the code + AST per original URL.
* Fix off-by-one column number lookup.
* Some naming and typing tweaks related to the above.
* Stop storing the consumer outside the with() callback, which is a bug.

* Lint fix for 8d8dd25

* Added devDependencies to react-devtools-extensions package.json

* Added some debug logging and TODO comments

* Added additional DEBUG logging to hook names cache

Co-authored-by: Brian Vaughn <[email protected]>
2021-07-07 13:07:58 -04:00
Andrew ClarkandGitHub fe9d9a3842 Replace unbatchedUpdates with flushSync (#21776)
There's a weird quirk leftover from the old Stack (pre-Fiber)
implementation where the initial mount of a leagcy (ReactDOM.render)
root is flushed synchronously even inside `batchedUpdates`.

The original workaround for this was an internal method called
`unbatchedUpdates`. We've since added another API that works almost the
same way, `flushSync`.

The only difference is that `unbatchedUpdates` would not cause other
pending updates to flush too, only the newly mounted root. `flushSync`
flushes all pending sync work across all roots. This was to preserve
the exact behavior of the Stack implementation.

But since it's close enough, let's just use `flushSync`. It's unlikely
anyone's app accidentally relies on this subtle difference, and the
legacy API is deprecated in 18, anyway.
2021-07-01 15:14:07 -07:00
34902f78af DevTools: Show hook names based on variable usage (#21641)
Co-authored-by: Brian Vaughn <[email protected]>
Co-authored-by: Saphal Patro <[email protected]>
Co-authored-by: VibhorCodecianGupta <[email protected]>
2021-07-01 14:39:18 -04:00
Brian VaughnandGitHub 78f9773c62 Updated scripts and config to replace "master" with "main" branch (#21768) 2021-06-29 14:26:24 -04:00
Brian VaughnandGitHub 89fcb7442c DevTools: Update tests to fix warnings/errors (#21748)
Some new ones had slipped in (e.g. deprecated ReactDOM.render message from 18)
2021-06-24 22:42:44 -04:00
Brian VaughnandGitHub c7ac19663e DevTools: Fix Settings dialog scroll/size bug in Firefox (#21747) 2021-06-24 11:19:57 -04:00
Andrew ClarkandGitHub 66bcc9758c Remove internal act builds from public modules (#21721)
* Move internal version of act to shared module

No reason to have three different copies of this anymore.

I've left the the renderer-specific `act` entry points because legacy
mode tests need to also be wrapped in `batchedUpdates`. Next, I'll update
the tests to use `batchedUpdates` manually when needed.

* Migrates tests to use internal module directly

Instead of the `unstable_concurrentAct` exports. Now we can drop those
from the public builds.

I put it in the jest-react package since that's where we put our other
testing utilities (like `toFlushAndYield`). Not so much so it can be
consumed publicly (nobody uses that package except us), but so it works
with our build tests.

* Remove unused internal fields

These were used by the old act implementation. No longer needed.
2021-06-22 14:29:35 -07:00
Brian VaughnandGitHub 8b979898fd DevTools can inspect Proxies that return broken iterator functions (#21660) 2021-06-11 10:15:48 -04:00
Andrew ClarkandGitHub 6038150703 Deprecate ReactDOM.render and ReactDOM.hydrate (#21652)
* Use existing test warning filter for server tests

We have a warning filter for our internal tests to ignore warnings
that are too noisy or that we haven't removed from our test suite yet:
shouldIgnoreConsoleError.

Many of our server rendering tests don't use this filter, though,
because it has its own special of asserting warnings.

So I added the warning filter to the server tests, too.

* Deprecate ReactDOM.render and ReactDOM.hydrate

These are no longer supported in React 18. They are replaced by the
`createRoot` API.

The warning includes a link to documentation of the new API. Currently
it redirects to the corresponding working group post. Here's the PR to
set up the redirect: https://github.com/reactjs/reactjs.org/pull/3730

Many of our tests still use ReactDOM.render. We will need to gradually
migrate them over to createRoot.

In the meantime, I added the warnings to our internal warning filter.
2021-06-09 13:46:55 -07:00
Ikko AshimineandGitHub 107f68d7aa Fix typo in bridge.js (#21621) 2021-06-04 11:42:09 -04:00
b2844b7d9a Devtools: add feature to trigger an error boundary (#21583)
Co-authored-by: Brian Vaughn <[email protected]>
2021-06-03 11:21:44 -04:00
Brian VaughnandGitHub 4324b0479f DevTools: Format error message (#21580)
To support GitHub API fuzzy issue search
2021-05-27 15:44:14 -04:00
Brian VaughnandGitHub 206a7facc6 Enabled Profiling feature flags for OSS release (#21565)
* Enabled Profiling feature flags for OSS release

`enableProfilerCommitHooks` and `enableProfilerNestedUpdatePhase`
2021-05-25 17:32:14 -04:00
Brian VaughnandGitHub bdae1b3f4a DevTools: Support an element mounting before its owner (#21562) 2021-05-25 14:49:05 -04:00
Brian VaughnandGitHub ae049a0dc5 DevTools: Revert force deep re-mount when Fast Refresh detected (#21539)
This reverts the most expensive part of 68db562f6 (which seems to no longer be necessary after subsequent changes).
2021-05-20 15:28:59 -04:00
Brian VaughnandGitHub 2ad45b36ad Fix edge-case Fast Refresh bug that caused Fibers with warnings/errors to be untracked prematurely (#21536)
Refactor error/warning count tracking to avoid pre-allocating an ID for Fibers that aren't yet mounted. Instead, we store a temporary reference to the Fiber itself and later check to see if it successfully mounted before merging pending error/warning counts.

This avoids a problematic edge case where a force-remounted Fiber (from Fast Refresh) caused us to untrack a Fiber that was still mounted, resulting in a DevTools error if that Fiber was inspected in the Components tab.
2021-05-20 11:24:08 -04:00
Brian VaughnandGitHub 27d29a696a Add key to inspected-element error boundary (#21535)
This way changing the selected element also recreates/resets the boundary automatically.
2021-05-19 17:38:12 -04:00