Commit Graph

13965 Commits

Author SHA1 Message Date
Sebastian Markbåge fb8c1917e9 Don't use nested objects to "namespace" namespace constants (#21073) 2021-03-24 09:58:23 -07:00
Andrew Clark fa868d6be7 Make opaque EventPriority type a Lane internally (#21065)
Instead of LanePriority, we can use a Lane and skip the extra
conversion. Eventually I want to get rid of LanePriority completely.
2021-03-24 09:55:24 -07:00
Ari Perkkiö eb58c3909a react-hooks/exhaustive-deps: Handle optional chained methods as dependency (#20204) (#20247) 2021-03-24 16:45:27 +00:00
Dan Abramov 7b84dbd169 Fail build on deep requires in npm packages (#21063) 2021-03-24 02:43:55 +00:00
Dan Abramov 2c9d8efc8e Add react-reconciler/constants entry point (#21062)
* Add react-reconciler/constants entry point

* Move root tags to /constants
2021-03-24 02:13:43 +00:00
Andrew Clark d0eaf78293 Move priorities to separate import to break cycle (#21060)
The event priority constants exports by the reconciler package are
meant to be used by the reconciler (host config) itself. So it doesn't
make sense to export them from a module that requires them.

To break the cycle, we can move them to a separate module and import
that. This looks like a "deep import" of an internal module, which we
try to avoid, but conceptually these are part of the public interface
of the reconciler module. So, no different than importing from the main
`react-reconciler`.

We do need to be careful about not mixing these types of imports with
implementation details. Those are the ones to really avoid.

An unintended benefit of the reconciler fork infra is that it makes
deep imports harder. Any module that we treat as "public", like this
one, needs to account for the `enableNewReconciler` flag and forward
to the correct implementation.
2021-03-23 13:57:28 -07:00
Sebastian Markbåge 435cff9866 [Fizz] Expose callbacks in options for when various stages of the content is done (#21056)
* Report errors to a global handler

This allows you to log errors or set things like status codes.

* Add complete callback

* onReadyToStream callback

This is typically not needed because if you want to stream when the
root is ready you can just start writing immediately.

* Rename onComplete -> onCompleteAll
2021-03-23 11:39:38 -07:00
Benoit Girard 25bfa287f6 [Experiment] Add feature flag for more aggressive memory clean-up of deleted fiber trees (#21039)
* Add feature flag: enableStrongMemoryCleanup

Add a feature flag that will test doing a recursive clean of an unmount
node. This will disconnect the fiber graph making leaks less severe.

* Detach sibling pointers in old child list

When a fiber is deleted, it's still part of the previous (alternate)
parent fiber's list of children. Because children are a linked list, an
earlier sibling that's still alive will be connected to the deleted
fiber via its alternate:


  live fiber
  --alternate--> previous live fiber
  --sibling--> deleted fiber

We can't disconnect `alternate` on nodes that haven't been deleted
yet, but we can disconnect the `sibling` and `child` pointers.

Will use this feature flag to test the memory impact.

* Combine into single enum flag

I combined `enableStrongMemoryCleanup` and `enableDetachOldChildList`
into a single enum flag. The flag has three possible values. Each level
is a superset of the previous one and performs more aggressive clean up.

We will use this to compare the memory impact of each level.

* Add Flow type to new host config method

* Re-use existing recursive clean up path

We already have a recursive loop that visits every deleted fiber. We
can re-use that one for clean up instead of adding another one.

Co-authored-by: Andrew Clark <git@andrewclark.io>
2021-03-22 21:54:53 -07:00
Dan Abramov 7c4e6aae3e Oops, it's 2021 already 2021-03-22 22:50:37 +00:00
Sebastian Markbåge 8fe7810e70 Remove already completed comment (#21054) 2021-03-22 15:41:22 -07:00
Dan Abramov cc1a46dfd2 React 17.0.2 Changelog (#21052)
## 17.0.2 (March 22, 2020)

### React DOM

* Remove an unused dependency to address the [`SharedArrayBuffer` cross-origin isolation warning](https://developer.chrome.com/blog/enabling-shared-array-buffer/). ([@koba04](https://github.com/koba04) and [@bvaughn](https://github.com/bvaughn) in [#20831](https://github.com/facebook/react/pull/20831), [#20832](https://github.com/facebook/react/pull/20832), and [#20840](https://github.com/facebook/react/pull/20840))
2021-03-22 21:57:59 +00:00
Dan Abramov a5c3baeecd Fix a broken link 2021-03-22 21:04:13 +00:00
Sebastian Markbåge 6c3202b1e1 [Fizz] Use identifierPrefix to avoid conflicts within the same response (#21037)
* Use identifierPrefix to avoid conflicts within the same response

identifierPrefix as an option exists to avoid useOpaqueIdentifier conflicting
when different renders are used within one HTML response.

This lets this be configured for the DOM renderer specifically since it's DOM
specific whether they will conflict across trees or not.

* Add test for using multiple containers in one HTML document
2021-03-22 13:10:57 -07:00
Andrew Clark dcdf8de7e1 Remove discrete lanes and priorities (#21040)
We use SyncLane everywhere we used to use InputDiscreteLane or
InputDiscreteHydrationLane. So we can delete them now, along with their
associated lane priority levels.
2021-03-22 09:51:40 -07:00
Ricky ca99ae97b4 Replace some flushExpired callsites (#20975) 2021-03-22 12:44:19 -04:00
Andrew Clark 1fafac0028 Use SyncLane for discrete event hydration (#21038)
Discrete event hydration doesn't need to be interruptible, since
there's nothing higher priority than discrete events. So we can use
SyncLane instead of a special hydration lane.
2021-03-22 09:05:43 -07:00
Andrew Clark 6d3ecb70dc Remove unstable_changedBits (#20953)
We added this unstable feature a few years ago, as a way to opt out of
context updates, but it didn't prove useful in practice.

We have other proposals for how to address the same problem, like
context selectors.

Since it was prefixed with `unstable_`, we should be able to remove it
without consequence. The hook API already warned if you used it.

Even if someone is using it somewhere, it's meant to be an optimization
only, so if they are using the API properly, it should not have any
semantic impact.
2021-03-19 15:36:51 -07:00
Andrew Clark 754e307284 Delete immediateQueueCallbackNode (#20980)
We don't need this anymore. It only existed so we could cancel the
callback later. But canceling isn't necessary, was only an
"optimization" for something that almost never happens in practice.
2021-03-19 15:36:23 -07:00
Andrew Clark be5a2e231a Land enableSyncMicrotasks (#20979) 2021-03-19 15:28:41 -07:00
Sebastian Markbåge f6bc9c8243 [Fizz] Expose maxBoundarySize as an option (#21029)
* Expose maxBoundarySize as an option

* Adjust the heuristic

* Rename to progressiveChunkSize
2021-03-19 09:41:25 -07:00
Brian Vaughn 7d06b80af6 Fixed primitive hook badge colors for light theme (#21034) 2021-03-19 09:52:59 -04:00
Sebastian Markbåge 154b85213a [Fizz] Expose a method to explicitly start writing to a Node stream (#21028)
* Expose an explicit point when to start writing in the Node API

* Add a previously failing test
2021-03-18 12:43:40 -07:00
Sebastian Markbåge cf485e6f6b [Fizz] Expose a method to abort a pending request (#21027)
* Track all suspended work while it's still pending

This allows us to abort work and put everything into client rendered mode
if we don't want to wait for further I/O.

It also allows us to cancel fallbacks if we complete the main content
before the fallback.

* Expose abort API to the browser streams

Since this API already returns a value, we need to use destructuring to
expose more options.

* Add a test including the client actually client rendering it

* Use AbortSignal option for W3C streams instead of external control

* Clean up listener after it's used once
2021-03-18 09:46:15 -07:00
Timothy Yung 3fb11eed9a React Native: Touch Instrumentation Interface (#21024) 2021-03-17 13:46:43 -07:00
Brian Vaughn 119736b1c2 [FB-only] Show which hooks (indices) changed when profiling (#20998) 2021-03-17 12:28:21 -04:00
Brian Vaughn bf11788bf0 DevTools Profiler: Add commit and post-commit durations to UI (#20984) 2021-03-17 12:27:37 -04:00
Sebastian Markbåge 825c3021f0 Don't delete trailing mismatches during hydration at the root (#21021)
* Don't delete any trailing nodes in the container during hydration error

* Warn when an error during hydration causes us to clear the container

* Encode unfortunate case in test

* Wrap the root for tests that are applicable to nested cases

* Now we can pipe Fizz into a container

* Grammatical fix
2021-03-17 08:18:42 -07:00
Sebastian Markbåge 1d1e49cfa4 [Fizz] Assign an ID to the first DOM element in a fallback or insert a dummy (and testing infra) (#21020)
* Patches

* Add Fizz testing infra structure

* Assign an ID to the first DOM node in a fallback or insert a dummy

* unstable_createRoot
2021-03-16 14:05:52 -07:00
Brian Vaughn 533aed8de6 Speed up DevTools local build script (#21018) 2021-03-16 14:02:24 -04:00
Brian Vaughn 466b26c926 Store commit durations on HostRoot for DevTools access (#20983)
Also add missing feature flag wrappers around effect duration attributes.
2021-03-16 13:53:15 -04:00
Ricky 89acfa639b Fix native event batching in concurrent mode (#21010)
* Fix native event batching in concurrent mode

* Wrap DevTools test updates with act

These tests expect the `scheduleUpdate` DevTools hook to trigger a
synchronous re-render with legacy semantics, but flushing in a microtask
is fine. Wrapping the updates with `act` fixes it.

* Testing nits

* Nit: Check executionContext === NoContext first

In the common case it will be false and the binary expression will
short circuit.

Co-authored-by: Andrew Clark <git@andrewclark.io>
2021-03-16 13:15:00 -04:00
susiwen8 0203b6567c chore: update react-reconciler README (#21016) 2021-03-16 11:37:34 +00:00
Timothy Yung c9f6d0a3a8 Sync ReactNativeTypes from React Native (#21015) 2021-03-15 23:48:59 -07:00
Joshua Gross f8979e0e28 Revert 'Fabric-compatible implementation of feature' and have Fabric noop when setJSResponder is called for now (#21009) 2021-03-15 12:22:26 -07:00
Sebastian Markbåge b9c4a01f71 Allow the streaming config to decide how to precompute or compute chunks (#21008)
Some legacy environments can not encode non-strings. Those would specify
both as strings. They'll throw for binary data.

Some environments have to encode strings (like web streams). Those would
encode both as uint8array.

Some environments (like Node) can do either. It can be beneficial to leave
things as strings in case the native stream can do something smart with it.
2021-03-15 10:36:23 -07:00
Sebastian Silbermann 00d4f95c2a Document prerequisites for download-experimental-build (#21005) 2021-03-15 09:48:44 -04:00
Hector Rincon c06d245fc7 Update devtools-extensions build script to reflect changes in local b… (#21004)
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2021-03-15 09:46:46 -04:00
Sebastian Markbåge f227e7f26b Clean up unused functions from SSR (#20995) 2021-03-13 07:23:06 -08:00
Sebastian Markbåge 14e4fd1ff2 [Fizz] Move DOM/Native format configs to their respective packages (#20994)
* Move DOM/Native format configs to their respective packages

The streaming configs (Node/Browser) are different because they operate at
another dimension that exists in each package.

* Use escapeTextForBrowser to encode dynamic strings

We can now use local dependencies
2021-03-13 06:54:59 -08:00
Sebastian Markbåge f2b6bf7c86 [Fizz] Destroy the stream with an error if the root throws (#20992)
* Destroy the stream with an error if the root throws

But not if the error happens inside a suspense boundary.

* Try rewriting the test to see if it works in other Node envs
2021-03-12 15:21:02 -08:00
Sebastian Markbåge 10cc400184 Basic Fizz Architecture (#20970)
* Copy some infra structure patterns from Flight

* Basic data structures

* Move structural nodes and instruction commands to host config

* Move instruction command to host config

In the DOM this is implemented as script tags. The first time it's emitted
it includes the function. Future calls invoke the same function.

The side of the complete boundary function in particular is unfortunately
large.

* Implement Fizz Noop host configs

This is implemented not as a serialized protocol but by-passing the
serialization when possible and instead it's like a live tree being
built.

* Implement React Native host config

This is not wired up. I just need something for the flow types since
Flight and Fizz are both handled by the isServerSupported flag.

Might as well add something though.

The principle of this format is the same structure as for HTML but a
simpler binary format.

Each entry is a tag followed by some data and terminated by null.

* Check in error codes

* Comment
2021-03-11 12:01:41 -08:00
Chris Dobson bd245c1bab Ensure sync-xhr is allowed before reload and profile (#20879)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2021-03-11 10:31:57 -05:00
Andrew Clark b7e6310669 Stop tracking roots with pending discrete updates (#20978)
Now that discrete updates are flushed synchronously in a microtask,
there's no need to track them in their on queue. They're already in
the queue we use for all sync work. So we can call that directly.
2021-03-10 23:29:29 -08:00
Ricky 860f673a7a Remove Blocking Mode (again) (#20974)
* Remove Blocking Mode (again)

* Rename batchingmode file and comment
2021-03-10 18:34:35 -05:00
Ricky acde654698 Unify InputDiscreteLane with SyncLane (#20968)
* Unify sync priority and input discrete

* Fix lint

* Use update lane instead

* Update sync lane labels
2021-03-10 17:36:13 -05:00
Brian Vaughn 6556e2a874 Cleaned up unused PassiveUnmountPendingDev DEV flag (#20973) 2021-03-10 17:09:24 -05:00
Ricky 60182d64ca Cleanup tests using runWithPriority. (#20958)
* Remove Scheduler.runWithPriority from some tests

* Mark experimental test experimental
2021-03-10 12:44:25 -05:00
Brian Vaughn ec372faefe Remove DevTools dependency on Scheduler runWithPriority (#20967) 2021-03-10 08:52:19 -05:00
Ricky e4d4b7074d Land enableNativeEventPriorityInference (#20955)
* Land enableNativeEventPriorityInference

* Move schedulerPriorityToLanePriority

* Remove obsolete comment
2021-03-09 23:59:02 -05:00
Ricky 5d1d1679bf Remove scheduler priority from hydration (#20957) 2021-03-09 17:25:23 -05:00