Commit Graph

14106 Commits

Author SHA1 Message Date
Brian Vaughn
2a7bb41548 Preparing DevTools 4.12.4 -> 4.13.0 release (#21378) 2021-04-28 12:36:24 -04:00
Brian Vaughn
7edd628134 Removed (deleted) tracing fixture test from relesae scripts 2021-04-28 12:36:09 -04:00
Brian Vaughn
a0d6b155dc DevTools should iterate over siblings during mount (#21377)
Previously, DevTools recursed over both children and siblings during mount. This caused potential stack overflows when there were a lot of children (e.g. a list containing many items).

Given the following example component tree:

       A
    B  C  D
    E     F
          G

A method that recurses for every child and sibling leads to a max depth of 6:

    A
    A -> B
    A -> B -> E
    A -> B -> C
    A -> B -> C -> D
    A -> B -> C -> D -> F
    A -> B -> C -> D -> F -> G

The stack gets deeper as the tree gets either deeper or wider.

A method that recurses for every child and iterates over siblings leads to a max depth of 4:

    A
    A -> B
    A -> B -> E
    A -> C
    A -> D
    A -> D -> F
    A -> D -> F -> G

The stack gets deeper as the tree gets deeper but is resilient to wide trees (e.g. lists containing many items).
2021-04-28 10:29:22 -04:00
Brian Vaughn
a5267faad5 Updated DevTools CHANGELOG for 4.10 releases 2021-04-28 08:58:27 -04:00
Brian Vaughn
5196a95fd1 Updated DevTools to replace fburl.com link with fb.me link 2021-04-27 23:49:30 -04:00
Brian Vaughn
ecb599cd87 DevTools supports multiple modal dialogs at once (#21370) 2021-04-27 20:33:11 -04:00
Brian Vaughn
8e2bb3e89c DevTools: Add Bridge protocol version backend/frontend (#21331)
Add an explicit Bridge protocol version to the frontend and backend components as well as a check during initialization to ensure that both are compatible. If not, the frontend will display either upgrade or downgrade instructions.

Note that only the `react-devtools-core` (React Native) and `react-devtools-inline` (Code Sandbox) packages implement this check. Browser extensions inject their own backend and so the check is unnecessary. (Arguably the `react-devtools-inline` check is also unlikely to be necessary _but_ has been added as an extra guard for use cases such as Replay.io.)
2021-04-27 17:26:07 -04:00
Brian Vaughn
22ab39be68 DevTools console patching should handle Symbols without erroring (#21368) 2021-04-27 16:36:20 -04:00
Sebastian Markbåge
2182563dc4 Let value override defaultValue if both are specified (#21369)
There's a DEV warning for this case but we still test for the production
behavior.
2021-04-27 13:18:42 -07:00
Sebastian Silbermann
29faeb2df3 Remove unnecessary type cast (#21363) 2021-04-27 12:37:14 -04:00
Sebastian Silbermann
4edbcdc327 Update supported devEngines (#21364) 2021-04-27 12:03:25 -04:00
Sebastian Markbage
9a2591681e Fix export 2021-04-27 09:44:17 -04:00
Sebastian Markbåge
4a8deb0836 Switch the isPrimaryRender flag based on the stream config (#21357) 2021-04-26 22:37:05 -04:00
Sebastian Markbåge
bd4f056a3e [Fizz] Implement lazy components and nodes (#21355)
* Implement lazy components

* Implement lazy elements / nodes

This is used by Flight to encode not yet resolved nodes of any kind.
2021-04-26 18:46:46 -07:00
Sebastian Markbåge
a2ae42db90 Escape style values (#21356) 2021-04-26 18:46:36 -07:00
Brian Vaughn
fc33f12bde Remove unstable scheduler/tracing API (#20037) 2021-04-26 19:16:18 -04:00
Brian Vaughn
7212383945 Enable strict effects mode for React Native Facebook builds (#21354) 2021-04-26 16:32:05 -04:00
Sebastian Silbermann
84b9162cbe Use toMatchInlineSnapshot for dehydrated values (#20618) 2021-04-26 12:30:34 -04:00
Andrew Clark
48740429b4 Expiration: Do nothing except disable time slicing (#21345)
We have a feature called "expiration" whose purpose is to prevent
a concurrent update from being starved by higher priority events.
If a lane is CPU-bound for too long, we finish the rest of the work
synchronously without allowing further interruptions.

In the current implementation, we do this in sort of a roundabout way:
once a lane is determined to have expired, we entangle it with SyncLane
and switch to the synchronous work loop.

There are a few flaws with the approach. One is that SyncLane has a
particular semantic meaning besides its non-yieldiness. For example,
`flushSync` will force remaining Sync work to finish; currently, that
also includes expired work, which isn't an intended behavior, but rather
an artifact of the implementation.

An event worse example is that passive effects triggered by a Sync
update are flushed synchronously, before paint, so that its result
is guaranteed to be observed by the next discrete event. But expired
work has no such requirement: we're flushing expired effects before
paint unnecessarily.

Aside from the behaviorial implications, the current implementation has
proven to be fragile: more than once, we've accidentally regressed
performance due to a subtle change in how expiration is handled.

This PR aims to radically simplify how we model starvation protection by
scaling back the implementation as much as possible. In this new model,
if a lane is expired, we disable time slicing. That's it. We don't
entangle it with SyncLane. The only thing we do is skip the call to
`shouldYield` in between each time slice. This is identical to how we
model synchronous-by-default updates in React 18.
2021-04-24 16:32:48 -07:00
Andrew Clark
0f5ebf366e Delete unreferenced type (#21343)
Had already deleted all the uses but didn't remove the type itself.
2021-04-23 15:41:53 -07:00
Sebastian Markbåge
9cd52b27fe Restore context after an error happens (#21341)
Typically we don't need to restore the context here because we assume that
we'll terminate the rest of the subtree so we don't need the correct
context since we're not rendering any siblings.

However, after a nested suspense boundary we need to restore the context.
The boundary could do this but since we're already doing this in the
suspense branch of renderNode, we might as well do it in the error case
which isn't very perf sensitive anyway.
2021-04-23 12:24:10 -07:00
Sebastian Markbåge
ad091759a9 Revert "Emit reactroot attribute on the first element we discover (#21154)" (#21340)
This reverts commit 266c26ad45.
2021-04-23 10:28:44 -07:00
Sebastian Markbåge
709f948412 [Fizz] Add FB specific streaming API and build (#21337)
Add FB specific streaming API and build
2021-04-22 16:54:29 -07:00
Sebastian Markbåge
af5037a7a8 [Fizz] Wire up the Fixture (#21273)
* Wire up fizz to fixture

* Fixed typo conditional
2021-04-22 15:00:35 -07:00
Andrew Clark
e8cdce40d6 Don't flush sync at end of discreteUpdates (#21327)
All it should do is change the priority. The updates will be flushed
by the microtask.
2021-04-22 15:28:05 -05:00
Andrew Clark
a155860018 Fix: Don't flush discrete at end of batchedUpdates (#21229)
The outermost `batchedUpdates` call flushes pending sync updates at the
end. This was intended for legacy sync mode, but it also happens to
flush discrete updates in concurrent mode.

Instead, we should only flush sync updates at the end of
`batchedUpdates` for legacy roots. Discrete sync updates can wait to
flush in the microtask.

`discreteUpdates` has the same issue, which is how I originally noticed
this, but I'll change that one in a separate commit since it requires
updating a few (no longer relevant) internal tests.
2021-04-21 09:32:09 -07:00
Andrew Clark
89847bf6e6 Continuous updates should interrupt transitions (#21323)
Even when updates are sync by default.

Discovered this quirk while working on #21322. Previously, when sync
default updates are enabled, continuous updates are treated like
default updates. We implemented this by assigning DefaultLane to
continous updates. However, an unintended consequence of that approach
is that continuous updates would no longer interrupt transitions,
because default updates are not supposed to interrupt transitions.

To fix this, I changed the implementation to always assign separate
lanes for default and continuous updates. Then I entangle the
lanes together.
2021-04-21 08:51:04 -07:00
Andrew Clark
ef37d55b68 Use performConcurrentWorkOnRoot for "sync default" (#21322)
Instead of `performSyncWorkOnRoot`.

The conceptual model is that the only difference between sync default
updates (in React 18) and concurrent default updates (in a future major
release) is time slicing. All other behavior should be the same
(i.e. the stuff in `finishConcurrentRender`).

Given this, I think it makes more sense to model the implementation this
way, too. This exposed a quirk in the previous implementation where
non-sync work was sometimes mistaken for sync work and flushed too
early. In the new implementation, `performSyncWorkOnRoot` is only used
for truly synchronous renders (i.e. `SyncLane`), which should make these
mistakes less common.

Fixes most of the tests marked with TODOs from #21072.
2021-04-21 08:29:31 -07:00
Ricky
a632f7de3b Flip tuple order of useTransition (#20976) 2021-04-20 12:21:44 -04:00
Andrew Clark
bd7f4a013b Fix sloppy factoring in performSyncWorkOnRoot (#21246)
* Warn if `finishedLanes` is empty in commit phase

See #21233 for context.

* Fix sloppy factoring when assigning finishedLanes

`finishedLanes` is assigned in `performSyncWorkOnRoot` and
`performSyncWorkOnRoot`. It's meant to represent whichever lanes we
used to render, but because of some sloppy factoring, it can sometimes
equal `NoLanes`.

The fixes are:
- Always check if the lanes are not `NoLanes` before entering the work
loop. There was a branch where this wasn't always true.
- In `performSyncWorkOnRoot`, don't assume the next lanes are sync; the
priority may have changed, or they may have been flushed by a
previous task.
- Don't re-assign the `lanes` variable (the one that gets assigned to
`finishedLanes` until right before we enter the work loop, so that it
is always corresponds to the newest complete root.
2021-04-20 09:14:55 -07:00
Andrew Clark
78120032d4 Remove flushDiscreteUpdates from end of event (#21223)
We don't need this anymore because we flush in a microtask.

This should allow us to remove the logic in the event system that
tracks nested event dispatches.

I added a test to confirm that nested event dispatches don't triggger
a synchronous flush, like they would if we wrapped them `flushSync`. It
already passed; I added it to prevent a regression.
2021-04-20 08:25:31 -07:00
Ricky
a3a7adb83e Turn off enableSyncDefaultUpdates in test renderer (#21319) 2021-04-19 22:20:48 -07:00
Brian Vaughn
cdb6b4c554 Only hide outermost host nodes when Offscreen is hidden (#21250) 2021-04-19 21:33:42 -04:00
Brian Vaughn
7becb2ff1b DevTools version bump 4.12.3 -> 4.12.4 2021-04-19 21:23:01 -04:00
Brian Vaughn
83bdc565f9 Remove @octokit/rest dependency from DevTools (#21317) 2021-04-19 21:20:34 -04:00
Brian Vaughn
b9c6a2b30e Remove LayoutStatic check from commit phase (#21249) 2021-04-19 15:16:24 -04:00
Brian Vaughn
8f202a7c8d DevTools version bump 4.12.2 -> 4.12.3 2021-04-19 13:09:07 -04:00
Brian Vaughn
4def1ceee2 Update DevTools Error strings to support GitHub fuzzy search (#21314) 2021-04-19 13:05:28 -04:00
Andrew Clark
af1a4cbf7a Revert expiration for retry lanes (#21300)
Retries should be allowed to expire if they are CPU bound for too long,
but when I made this change it caused a spike in browser crashes. There
must be some other underlying bug; not super urgent but ideally should
figure out why and fix it. Unfortunately we don't have a repro for the
crashes, only detected via production metrics.
2021-04-16 16:45:09 -05:00
Brian Vaughn
c3cb2c2b30 Fix DevTools test target (#21267) 2021-04-16 16:19:05 -04:00
Brian Vaughn
d14b6a4bdd DevTools version bump 4.12.1 -> 4.12.2 2021-04-16 12:35:29 -04:00
Brian Vaughn
5027eb4650 DevTools fork console patching logic (#21301)
React has its own component stack generation code that DevTools embeds a fork of, but both of them use a shared helper for disabling console logs. This shared helper is DEV only though, because it was intended for use with React DEV-only warnings and we didn't want to unnecessarily add bytes to production builds.

But DevTools itself always ships as a production build– even when it's used to debug DEV bundles of product apps (with third party DEV-only warnings). That means this helper was always a noop.

The resolveCurrentDispatcher method was changed recently to replace the thrown error with a call to console.error. This newly logged error ended up slipping through and being user visible because of the above issue.

This PR updates DevTools to also fork the console patching logic (to remove the DEV-only guard).

Note that I didn't spot this earlier because my test harness (react-devtools-shell) always runs in DEV mode. 🤡
2021-04-16 12:01:47 -04:00
Brian Vaughn
c1a53ad2b2 DevTools pre-filter GH issues by repo (#21292) 2021-04-15 19:56:41 -04:00
Sebastian Markbåge
cc4b431dab Mark boundary as client rendered even if aborting fallback (#21294) 2021-04-15 19:16:40 -04:00
Ricky
f7cdc89361 Also turn off enableSyncDefaultUpdates in RN test renderer (#21293) 2021-04-15 16:31:46 -04:00
Ricky
4c9eb2af1e Add dynamic flags to React Native (#21291)
* Add dynamic flags to React Native

* Hardcode the setting to false instead
2021-04-15 15:30:09 -04:00
Brian Vaughn
f3337aa544 DevTools error boundary: Search for pre-existing GH issues (#21279) 2021-04-15 13:34:54 -04:00
Sebastian Markbåge
9eddfbf5af [Fizz] Two More Fixes (#21288)
* Emit value of option tags

* Mask the legacy context passed to classes
2021-04-15 10:26:49 -07:00
Sebastian Markbåge
11b07597ee Fix classes (#21283) 2021-04-15 08:06:31 -07:00
Sebastian Markbåge
96d00b9bba [Fizz] Random Fixes (#21277) 2021-04-14 23:29:30 -04:00