Commit Graph

13617 Commits

Author SHA1 Message Date
Brian Vaughn
12adaffef7 Remove scheduler sampling profiler shared array buffer (#20840)
No one has been using this data so there's no reason to collect it. Event log has been maintained and tests have been updated.
2021-03-22 20:01:35 +00:00
Brian Vaughn
b2bbee7ba3 Disable (unstable) scheduler sampling profiler for OSS builds (#20832)
* Disabled Scheduler sampling profiler for OSS builds
* Added missing conditional feature flag around profiling calls
2021-03-22 19:57:29 +00:00
Toru Kobayashi
8cc6ff2488 fix: use SharedArrayBuffer only when cross-origin isolation is enabled (#20831)
* fix: check cross-origin isolation for SharedArrayBuffer

* chore: remove unused a $FlowFixMe comment

* prettier
2021-03-22 19:50:49 +00:00
Dan Abramov
8e5adfbd7e Remove usage of Array#fill (#20071) 2020-10-22 12:59:20 +01:00
Dan Abramov
89b610969d Bump versions for 17 2020-10-20 21:33:44 +01:00
Shivam Sandbhor
4ead6b5305
Treat <time> tag as a normal HTML tag. (#19951)
<time> tag has been supported by Chrome since Chrome 62.0.
Remove workarounds which were in place to avoid friction with
versions before Chrome 62.

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
2020-10-06 03:15:32 +01:00
Brian Vaughn
1992d97306
Revert "Temporarily disable Profiler commit hooks flag (#19900)" (#19960) 2020-10-05 15:49:52 -04:00
Brian Vaughn
44d39c4d76
Removed skip-error-boundaries modifications from old fork (#19961)
Technically this change is unnecessary, since the feature is controlled by a flag, but since we decided not to ship this in v17– I'm going to remove it for now entirely.
2020-10-05 15:49:44 -04:00
Brian Vaughn
461cd84944
Revert "DevTools: Improve browser extension iframe support (#19854)" (#19959)
This reverts commit a99bf5c5f4.
2020-10-05 09:44:08 -04:00
Paul Doyle
cc77be957e
Remove unnecessary error overriding in (#19949) 2020-10-02 22:10:46 +01:00
Brian Vaughn
97625272ab
Debug tracing tests for CPU bound suspense (#19943) 2020-10-01 12:02:26 -04:00
Eugene Maslovich
43363e2795
Fix codestyle for typeof comparison (#19928) 2020-10-01 16:26:49 +01:00
John Wilson
8657ad4278
Fix(React DevTools) - prevent phishing attacks (#19934)
When a link opens a URL in a new tab with target="_blank", it is very simple for the opened page to change the location of the original page because the JavaScript variable window.opener is not null and thus "window.opener.location can be set by the opened page. This exposes the user to very simple phishing attacks.
2020-10-01 16:25:38 +01:00
Saikat Guha
91d2b6ef01
DevTools: Remove ReactJS.org version check "cheat" (#19939)
Remove dead code as facebook.github.io/react always redirects to reactjs.org, which has prod version of react. so removing the "cheat" (#19939)
2020-10-01 10:16:50 -04:00
Brian Vaughn
5427b4657b
Temporarily disable Profiler commit hooks flag (#19900)
Temporarily disable Profiler commit hooks flag to verify it does not cause a regression.
2020-09-30 15:58:20 -04:00
Andrew Clark
1faf9e3dd5
Suspense for CPU-bound trees (#19936)
Adds a new prop to the Suspense component type,
`unstable_expectedLoadTime`. The presence of this prop indicates that
the content is computationally expensive to render.

During the initial mount, React will skip over expensive trees by
rendering a placeholder — just like we do with trees that are waiting
for data to resolve. That will help unblock the initial skeleton for the
new screen. Then we will continue rendering in the next commit.

For now, while we experiment with the API internally, any number passed
to `unstable_expectedLoadTime` will be treated as "computationally
expensive", no matter how large or small. So it's basically a boolean.
The reason it's a number is that, in the future, we may try to be clever
with this additional information. For example, SuspenseList could use
it as part of its heuristic to determine whether to keep rendering
additional rows.

Background
----------

Much of our early messaging and research into Suspense focused on its
ability to throttle the appearance of placeholder UIs. Our theory was
that, on a fast network, if everything loads quickly, excessive
placeholders will contribute to a janky user experience. This was backed
up by user research and has held up in practice.

However, our original demos made an even stronger assertion: not only is
it preferable to throttle successive loading states, but up to a certain
threshold, it’s also preferable to remain on the previous screen; or in
other words, to delay the transition.

This strategy has produced mixed results. We’ve found it works well for
certain transitions, but not for all them. When performing a full page
transition, showing an initial skeleton as soon as possible is crucial
to making the transition feel snappy. You still want throttle the nested
loading states as they pop in, but you need to show something on the new
route. Remaining on the previous screen can make the app feel
unresponsive.

That’s not to say that delaying the previous screen always leads to a
bad user experience. Especially if you can guarantee that the delay is
small enough that the user won’t notice it. This threshold is a called a
Just Noticeable Difference (JND). If we can stay under the JND, then
it’s worth skipping the first placeholder to reduce overall thrash.

Delays that are larger than the JND have some use cases, too. The main
one we’ve found is to refresh existing data, where it’s often preferable
to keep stale content on screen while the new data loads in the
background. It’s also useful as a fallback strategy if something
suspends unexpectedly, to avoid hiding parts of the UI that are already
visible.

We’re still in the process of optimizing our heuristics for the most
common patterns. In general, though, we are trending toward being more
aggressive about prioritizing the initial skeleton.

For example, Suspense is usually thought of as a feature for displaying
placeholders when the UI is missing data — that is, when rendering is
bound by pending IO.

But it turns out that the same principles apply to CPU-bound
transitions, too. It’s worth deferring a tree that’s slow to render if
doing so unblocks the rest of the transition — regardless of whether
it’s slow because of missing data or because of expensive CPU work.

We already take advantage of this idea in a few places, such as
hydration. Instead of hydrating server-rendered UI in a single pass,
React splits it into chunks. It can do this because the initial HTML
acts as its own placeholder. React can defer hydrating a chunk of UI as
long as it wants until the user interacts it. The boundary we use to
split the UI into chunks is the same one we use for IO-bound subtrees:
the <Suspense /> component.

SuspenseList does something similar. When streaming in a list of items,
it will occasionally stop to commit whatever items have already
finished, before continuing where it left off. It does this by showing a
placeholder for the remaining items, again using the same <Suspense />
component API, even if the item is CPU-bound.

Unresolved questions
--------------------

There is a concern that showing a placeholder without also loading new
data could be disorienting. Users are trained to believe that a
placeholder signals fresh content. So there are still some questions
we’ll need to resolve.
2020-09-30 12:57:33 -07:00
Brian Vaughn
7f08e908b1
Fix missing context to componentDidMount() when double-invoking lifecycles (#19935) 2020-09-30 15:56:19 -04:00
Brian Vaughn
9198a5cec0
Refactor layout effect methods (#19895)
Commit phase durations (layout and passive) are stored on the nearest (ancestor) Profiler and bubble up during the commit phase. This bubbling used to be implemented by traversing the return path each time we finished working on a Profiler to find the next nearest Profiler.

This commit removes that traversal. Instead, we maintain a stack of nearest Profiler ancestor while recursing the tree. This stack is maintained in the work loop (since that's where the recursive functions are) and so bubbling of durations has also been moved from commit-work to the work loop.

This PR also refactors the methods used to recurse and apply effects in preparation for the new Offscreen component type.
2020-09-29 15:58:20 -04:00
Andrew Clark
ba82eea383
Remove disableSchedulerTimeoutInWorkLoop flag (#19902)
We found and mitigated the root cause of the regression that led us to
temporarily revert this change. So now I'm un-reverting it.
2020-09-28 10:19:14 -07:00
Dmitriy Kovalenko
71bc8ac74c
Improve wording for inline DevTools README.md (#19897) 2020-09-28 09:25:18 -04:00
Dan Abramov
480626a9e9
Create Synthetic Events Lazily (#19909) 2020-09-25 13:33:28 +01:00
Dan Abramov
0a00804494
Remove Array.from() from hot path (#19908)
* Remove Array.from() from hot path

* Fix build

Don't declare block variables inside loops
2020-09-25 11:33:07 +01:00
Dan Abramov
1890159a5d
Separate SyntheticEvent constructors to prevent deopts (#19907)
* Remove arguments from hot path

* Make SyntheticEvent subtypes monomorphic

* Maybe fix Flow?
2020-09-25 11:31:00 +01:00
Luna Ruan
c63741fb3d
offscreen double invoke effects (#19523)
This PR double invokes effects in __DEV__ mode.

We are thinking about unmounting layout and/or passive effects for a hidden tree. To understand potential issues with this, we want to double invoke effects. This PR changes the behavior in DEV when an effect runs from create() to create() -> destroy() -> create(). The effect cleanup function will still be called before the effect runs in both dev and prod. (Note: This change is purely for research for now as it is likely to break real code.)

**Note: The change is fully behind a flag and does not affect any of the code on npm.**
2020-09-24 13:42:17 -07:00
6h057
a99bf5c5f4
DevTools: Improve browser extension iframe support (#19854)
Co-authored-by: Joel DSouza <joel.dsouza@kapturecrm.com>
Co-authored-by: Damien Maillard <damien.maillard@dailymotion.com>
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-09-23 16:56:13 -04:00
Brian Vaughn
c6917346ff
Fixed broken Profiler test (#19894) 2020-09-23 15:33:25 -04:00
Brian Vaughn
87c023b1c1
Profiler onRender only called when we do work (#19885)
If we didn't perform any work in the subtree, skip calling onRender.
2020-09-22 14:47:13 -04:00
Todor Totev
92c7e49895
Don't consumer iterators while inspecting (#19831)
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-09-22 14:23:20 -04:00
Andrew Clark
81aaee56af
Don't call onCommit et al if there are no effects (#19863)
* Don't call onCommit et al if there are no effects

Checks `subtreeFlags` before scheduling an effect on the Profiler.

* Fix failing Profiler tests

The change to conditionally call Profiler commit hooks only if updates were scheduled broke a few of the Profiler tests. I've fixed the tests by either:
* Adding a no-op passive effect into the subtree or
* Converting onPostCommit to onCommit

When possible, I opted to add the no-op passive effect to the tests since that that hook is called later (during passive phase) so the test is a little broader. In a few cases, this required adding awkward act() wrappers so I opted to go with onCommit instead.

Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-09-22 11:20:26 -07:00
Andrew Clark
7355bf575a
Consolidate commit phase hook functions (#19864)
There were a few pairs of commit phase functions that were almost
identical except for one detail. I've refactored them a bit to
consolidate their implementations:

- Lifted error handling logic when mounting a fiber's passive hook
effects to surround the entire list, instead of surrounding each effect.
- Lifted profiler duration tracking to surround the entire list.

In both cases, this matches the corresponding code for the layout phase.

The naming is still a bit of a mess but I'm not too concerned because
my next step is to refactor each commit sub-phase (layout, mutation)
so that we can store values on the JS stack. So the existing function
boundaries are about to change, anyway.
2020-09-22 11:16:27 -07:00
Dan Abramov
c91c1c4ebe Release script: allow preparing RC from npm 2020-09-22 14:27:50 +01:00
E-Liang Tan
04e21efd09
Add scheduling profiler deployment CI job (#19874)
* Add vercel to scheduling profiler dev deps
* Add vercel.json
* Add CD job
* Add CD setup instructions
2020-09-22 08:34:06 -04:00
Brian Vaughn
ded2a83ebf
Improved DevTools context test harness (#19878) 2020-09-21 16:39:53 -04:00
E-Liang Tan
6d73063ddf
Enable building of DevTools and scheduling profiler in CI (#19691)
Re-enables building of main DevTools in CI and add new CI target for building the scheduling profiler.
2020-09-21 11:49:07 -04:00
Brian Vaughn
a8de69f358
DevTools: Drop IE 11 support (#19875)
DevTools shared Babel config previously supported IE 11 to target Hermes (for the standalone backend that gets embedded within React Native apps). This targeting resulted in less optimal code for other DevTools targets though which did not need to support IE 11. This PR updates the shared config to remove IE 11 support by default, and only enables it for the standalone backend target.
2020-09-21 11:07:45 -04:00
Dan Abramov
bc6b7b6b16
Don't trigger lazy in DEV during element creation (#19871) 2020-09-21 16:04:49 +01:00
Gustavo Saiani
a774502e0f
Use single quotes in getComponentName return (#19873) 2020-09-21 13:35:21 +01:00
Andrew Clark
8b2d3783e5
Use Passive flag to schedule onPostCommit (#19862)
Instead of calling `onPostCommit` in a separate phase, we can fire
them during the same traversal as the rest of the passive effects.

This works because effects are executed depth-first. So by the time we
reach a Profiler node, we'll have already executed all the effects in
its subtree.
2020-09-18 13:02:26 -07:00
Brian Vaughn
50d9451f32
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
Johnny Pribyl
b3b1bb9ce2
Enable source maps for DevTools production builds (#19773)
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-09-18 10:07:22 -04:00
Brian Vaughn
26857ecfa9
Revert "DevTools: Improve browser extension iframe support (#19827)" (#19852)
This reverts commit ec39a5e901.
2020-09-17 14:57:44 -04:00
Dan Abramov
6fddca27e7
Remove passive intervention flag (#19849) 2020-09-17 15:37:12 +01:00
Adnaan Bheda
36df9185c5
chore(docs): Removed outdated comment about fb.me link (#19830) 2020-09-16 08:07:16 -04:00
Brian Vaughn
16fb2b6f9e
Moved resetChildLanes into complete work (#19836)
This allows us to inline a few checks that are specific to a certain tag-type.
2020-09-15 17:12:48 -04:00
Andrew Clark
b93f3e7d2d
Fix act bundle size regression (#19832)
Adds back the `TestUtils.act` implementation that I had removed
in #19745. This version of `act` is implemented in "userspace" (i.e. not
the reconciler), so it doesn't add to the production bundle size.

I had removed this in #19745 in favor of the `act` exported by the
reconciler because I thought we would remove support for `act` in
production in the impending major release. (It currently warns.)

However, we've since decided to continue supporting `act` in prod for
now, so that it doesn't block people from upgrading to v17. We'll drop
support in a future major release.

So, to avoid bloating the production bundle size, we need to move the
public version of `act` back to "userspace", like it was before.

This doesn't negate the main goal of #19745, though, which was to
decouple the public version(s) of `act` from the internal one that we
use to test React itself.
2020-09-14 10:11:47 -07:00
6h057
ec39a5e901
DevTools: Improve browser extension iframe support (#19827)
Co-authored-by: Joel DSouza <joel.dsouza@kapturecrm.com>
Co-authored-by: Damien Maillard <damien.maillard@dailymotion.com>
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-09-14 10:04:46 -04:00
6h057
917cb01a58
React DevTools: Show symbols used as keys in state (#19786)
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-09-14 09:55:19 -04:00
Dan Abramov
11ee82df45
[Events] Make passiveness and priority non-configurable (#19807) 2020-09-14 13:54:08 +01:00
Seth Webster
ebb2253428
updates mailmap entries (#19824) 2020-09-12 13:05:52 -04:00
Dan Abramov
cc581065df eslint-plugin-react-hooks@4.1.2 2020-09-11 13:18:44 +01:00