Commit Graph

1090 Commits

Author SHA1 Message Date
acdlite 64e263fc13 Make prerendering always non-blocking (#31056)
When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.

This happens automatically when there's a Suspense boundary, because we
immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

DiffTrain build for commit https://github.com/facebook/react/commit/0f1856c49febe96923e469f98c0b123130ea015c.
2024-09-25 13:40:14 -07:00
acdlite cae834ff8c Unify perform{Sync,Concurrent}WorkOnRoot implementation (#31029)
Over time the behavior of these two paths has converged to be
essentially the same. So this merges them back into one function. This
should save some code size and also make it harder for the behavior to
accidentally diverge. (For the same reason, rolling out this change
might expose some areas where we had already accidentally diverged.)

DiffTrain build for commit https://github.com/facebook/react/commit/3c7667a694face1827356a7c90ee6f86a9c0baa0.
2024-09-25 12:41:53 -07:00
jackpope 84c55046e6 Increase nested update limit to 100 (#31061)
We're seeing the limit hit in some tests after enabling sibling
prerendering. Let's bump the limit so we can run more tests and gather
more signal on the changes. When we understand the scope of the problem
we can determine whether we need to change how the updates are counted
in prerenders and/or fix specific areas of product code.

DiffTrain build for commit https://github.com/facebook/react/commit/f9ebd85a196948be17efdd6774b4d0464b3b1f53.
2024-09-25 08:59:33 -07:00
poteto 4b77c87461 DiffTrain build for commit https://github.com/facebook/react/commit/. 2024-09-24 09:00:00 -07:00
Tim Yung c2c2363b4d Move react-dom/{ => cjs/}*.js 2024-09-23 16:56:38 -07:00
sebmarkbage 1aa95c1c69 [Fiber] Log the Render/Commit phases and the gaps in between (#31016)
A slight behavior change here too is that I now mark the start of the
commit phase before the BeforeMutationEffect phase. This affects
`<Profiler>` too.

The named sequences are as follows:

Render -> Suspended or Throttled -> Commit -> Waiting for Paint ->
Remaining Effects

The Suspended phase is only logged if we delay the Commit due to CSS /
images.

The Throttled phase is only logged if we delay the commit due to the
Suspense throttling timer.

<img width="1246" alt="Screenshot 2024-09-20 at 9 14 23 PM"
src="https://github.com/user-attachments/assets/8d01f444-bb85-472b-9b42-6157d92c81b4">

I don't yet log render phases that don't complete. I think I also need
to special case renders that or don't commit after being suspended.

DiffTrain build for commit https://github.com/facebook/react/commit/4e9540e3c2a8f9ae56318b967939c99b3a815190.
2024-09-23 11:17:19 -07:00
sebmarkbage 7afe7c4a5c [Fiber] Track Event Time, startTransition Time and setState Time (#31008)
This tracks the current window.event.timeStamp the first time we
setState or call startTransition. For either the blocking track or
transition track. We can use this to show how long we were blocked by
other events or overhead from when the user interacted until we got
called into React.

Then we track the time we start awaiting a Promise returned from
startTransition. We can use this track how long we waited on an Action
to complete before setState was called.

Then finally we track when setState was called so we can track how long
we were blocked by other word before we could actually start rendering.
For a Transition this might be blocked by Blocking React render work.

We only log these once a subsequent render actually happened. If no
render was actually scheduled, then we don't log these. E.g. if an
isomorphic Action doesn't call startTransition there's no render so we
don't log it.

We only log the first event/update/transition even if multiple are
batched into it later. If multiple Actions are entangled they're all
treated as one until an update happens. If no update happens and all
entangled actions finish, we clear the transition so that the next time
a new sequence starts we can log it.

We also clamp these (start the track later) if they were scheduled
within a render/commit. Since we share a single track we don't want to
create overlapping tracks.

The purpose of this is not to show every event/action that happens but
to show a prelude to how long we were blocked before a render started.
So you can follow the first event to commit.

<img width="674" alt="Screenshot 2024-09-20 at 1 59 58 AM"
src="https://github.com/user-attachments/assets/151ba9e8-6b3c-4fa1-9f8d-e3602745eeb7">

I still need to add the rendering/suspended phases to the timeline which
why this screenshot has a gap.

<img width="993" alt="Screenshot 2024-09-20 at 12 50 27 AM"
src="https://github.com/user-attachments/assets/155b6675-b78a-4a22-a32b-212c15051074">

In this case it's a Form Action which started a render into the form
which then suspended on the action. The action then caused a refresh,
which interrupts with its own update that's blocked before rendering.
Suspended roots like this is interesting because we could in theory
start working on a different root in the meantime which makes this
timeline less linear.

DiffTrain build for commit https://github.com/facebook/react/commit/d4688dfaafe51a4cb6e3c51fc2330662cb4e2296.
2024-09-20 11:34:48 -07:00
jackpope 45b2fc15d7 Update react-native/react-dom build directory (#31006)
Commit artifact actions are breaking after
https://github.com/facebook/react/pull/30711

See:
https://github.com/facebook/react/actions/runs/10930658977/job/30344033974

> mv: cannot stat 'build/facebook-react-native/react/dom/': No such file
or directory

After build, the new artifacts are in `/react-dom/cjs`, not
`/react/dom/`
```
$> yarn build
$> ls build/facebook-react-native/react/
# ... no dom
$> ls build/facebook-react-native/react-dom/cjs
```

DiffTrain build for commit https://github.com/facebook/react/commit/e4953922a99b5477c3bcf98cdaa2b13ac0a81f0d.
2024-09-19 15:11:59 -07:00
sebmarkbage 304fbaee2b Don't read currentTransition back from internals (#30991)
This code is weird. It reads back the transition that it just set from
the shared internals. It's almost like it expects it to be a getter or
something.

This avoids that and makes it consistent with what ReactFiberHooks
already does.

DiffTrain build for commit https://github.com/facebook/react/commit/15da9174518f18f82869767ebe2a21be2fc8bd90.
2024-09-17 12:32:15 -07:00
sebmarkbage f8e3da903b [Fiber] Optimize enableProfilerCommitHooks by Collecting Elapsed Effect Duration in Module Scope (#30981)
Stacked on #30979.

The problem with the previous approach is that it recursively walked the
tree up to propagate the resulting time from recording a layout effect.

Instead, we keep a running count of the effect duration on the module
scope. Then we reset it when entering a nested Profiler and then we add
its elapsed count when we exit the Profiler.

This also fixes a bug where we weren't previously including unmount
times for some detached trees since they couldn't bubble up to find the
profiler.

DiffTrain build for commit https://github.com/facebook/react/commit/4549be0f846e7df5a4eaabf06369d93bd120271e.
2024-09-17 12:19:37 -07:00
sebmarkbage 52878f5c6b Remove execution context check from shouldProfile (#30971)
I don't know why this is here since all these callsites are within the
CommitWork/CommitEffects helpers.

This should help with inlining.

DiffTrain build for commit https://github.com/facebook/react/commit/8152e5cd27721e792f395c0b62c8a7769a54777a.
2024-09-16 12:07:14 -07:00
javache 4c48f1fc24 [react-native] Fix misleading crash when view config is not found (#30970)
## Summary

When a view config can not be found, it currently errors with
`TypeError: Cannot read property 'bubblingEventTypes' of null`. Instead
invariant at the correct location and prevent further processing of the
null viewConfig to improve the error logged.

## How did you test this change?

Build and run RN playground app referencing an invalid native view
through `requireNativeComponent`.

DiffTrain build for commit https://github.com/facebook/react/commit/26855e4680dedb21f2c73a069ed691822a242db1.
2024-09-16 09:58:00 -07:00
sebmarkbage 4c73996cfd [Fiber] Log Component Renders to Custom Performance Track (#30967)
Stacked on #30960 and #30966. Behind the enableComponentPerformanceTrack
flag.

This is the first step of performance logging. This logs the start and
end time of a component render in the passive effect phase. We use the
data we're already tracking on components when the Profiler component or
DevTools is active in the Profiling or Dev builds. By backdating this
after committing we avoid adding more overhead in the hot path. By only
logging things that actually committed, we avoid the costly unwinding of
an interrupted render which was hard to maintain in earlier versions.

We already have the start time but we don't have the end time. That's
because `actualStartTime + actualDuration` isn't enough since
`actualDuration` counts the actual CPU time excluding yields and
suspending in the render.

Instead, we infer the end time to be the start time of the next sibling
or the complete time of the whole root if there are no more siblings. We
need to pass this down the passive effect tree. This will mean that any
overhead and yields are attributed to this component's span. In a follow
up, we'll need to start logging these yields to make it clear that this
is not part of the component's self-time.

In follow ups, I'll do the same for commit phases. We'll also need to
log more information about the phases in the top track. We'll also need
to filter out more components from the trees that we don't need to
highlight like the internal Offscreen components. It also needs polish
on colors etc.

Currently, I place the components into separate tracks depending on
which lane currently committed. That way you can see what was blocking
Transitions or Suspense etc. One problem that I've hit with the new
performance.measure extensions is that these tracks show up in the order
they're used which is not the order of priority that we use. Even when
you add fake markers they have to actually be within the performance run
since otherwise the calls are noops so it's not enough to do that once.

However, I think this visualization is actually not good because these
trees end up so large that you can't see any other lanes once you expand
one. Therefore, I think in a follow up I'll actually instead switch to a
model where Components is a single track regardless of lane since we
don't currently have overlap anyway. Then the description about what is
actually rendering can be separate lanes.

<img width="1512" alt="Screenshot 2024-09-15 at 10 55 55 PM"
src="https://github.com/user-attachments/assets/5ca3fa74-97ce-40c7-97f7-80c1dd7d6470">

<img width="1512" alt="Screenshot 2024-09-15 at 10 56 27 PM"
src="https://github.com/user-attachments/assets/557ad65b-4190-465f-843c-0bc6cbb9326d">

DiffTrain build for commit https://github.com/facebook/react/commit/f2df5694f2be141954f22618fd3ad035203241a3.
2024-09-16 08:53:02 -07:00
sebmarkbage a2e2949b98 [Fiber] Move Profiler onPostCommit processing of passive effect durations to plain passive effect (#30966)
We used to queue a separate third passive phase to invoke onPostCommit
but this is unnecessary. We can just treat it as a plain passive effect.
This means it is interleaved with other passive effects but we only need
to know the duration of the things below us which is already done at
this point.

I also extracted the user space call to onPostCommit into
ReactCommitEffects. Same as onCommit. It's now covered by
runWithFiberInDEV and catches.

DiffTrain build for commit https://github.com/facebook/react/commit/ee1a403a3019dd8bffb12174d269d8c85bfab8a1.
2024-09-16 08:17:45 -07:00
sebmarkbage baaa97f36b [Fiber] Profiler - Use two separate functions instead of branch by flag (#30957)
Nit: I don't trust flags in hot code. While it can take somewhat longer
to compile two functions and JIT them. After that they don't need to
check branches. Also makes it clearer the purpose.

DiffTrain build for commit https://github.com/facebook/react/commit/3d95c43b8967d4dda1ec9a22f0d9ea4999fee8b8.
2024-09-13 18:59:00 -07:00
rickhanlonii b42180d84a Call cleanup of insertion effects when hidden (#30954)
Insertion effects do not unmount when a subtree is removed while
offscreen.

Current behavior for an insertion effect is if the component goes

- *visible -> removed:* calls insertion effect cleanup
- *visible -> offscreen -> removed:* insertion effect cleanup is never
called

This makes it so we always call insertion effect cleanup when removing
the component.

Likely also fixes https://github.com/facebook/react/issues/26670

---------

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

DiffTrain build for commit https://github.com/facebook/react/commit/d3d4d3a46b014ab0f6edc443c19fcdba09105f20.
2024-09-13 13:25:38 -07:00
sebmarkbage 03205d9bd9 [Fiber] Set profiler values to doubles (#30942)
At some point this trick was added to initialize the value first to NaN
and then replace them with zeros and negative ones.

This is to address the issue noted in
https://github.com/facebook/react/issues/14365 where these hidden
classes can be initialized to SMIs at first and then deopt when we
realize they're actually doubles.

However, this fix has been long broken and has deopted the profiling
build for years because closure compiler optimizes out the first write.

I'm not sure because I haven't A/B-tested this in the JIT yet but I
think we can use negative zero and -1.1 as the initial values instead
since they're not simple integers. Negative zero `===` zero (but not
Object.is) so is the same as far as our code is concerned. The negative
value is just `< 0` comparisons.

DiffTrain build for commit https://github.com/facebook/react/commit/94e4acaa1477e65cac02ba86058cde0afe4c8f1f.
2024-09-13 09:33:56 -07:00
acdlite f9e2396524 Start prerendering Suspense retries immediately (#30934)
When a component suspends and is replaced by a fallback, we should start
prerendering the fallback immediately, even before any new data is
received. During the retry, we can enter prerender mode directly if
we're sure that no new data was received since we last attempted to
render the boundary.

To do this, when completing the fallback, we leave behind a pending
retry lane on the Suspense boundary. Previously we only did this once a
promise resolved, but by assigning a lane during the complete phase, we
will know that there's speculative work to be done.

Then, upon committing the fallback, we mark the retry lane as suspended
— but only if nothing was pinged or updated in the meantime. That allows
us to immediately enter prerender mode (i.e. render without skipping any
siblings) when performing the retry.

DiffTrain build for commit https://github.com/facebook/react/commit/d6cb4e771341ff82489c00f4907990cb8a75696b.
2024-09-11 08:49:11 -07:00
sebmarkbage 9b5d5c32af [Fiber] Don't call performance.now() twice in a row (#30936)
DiffTrain build for commit https://github.com/facebook/react/commit/a5a7f1063e6f190c64c779b2aa54d28fb7b92cfb.
2024-09-10 13:54:16 -07:00
acdlite c56b0edd51 Prerender during same pass if blocked anyway (#30879)
If something suspends in the shell — i.e. we won't replace the suspended
content with a fallback — we might as well prerender the siblings during
the current render pass, instead of spawning a separate prerender pass.

This is implemented by setting the "is prerendering" flag to true
whenever we suspend in the shell. But only if we haven't already skipped
over some siblings, because if so, then we need to schedule a separate
prerender pass regardless.

DiffTrain build for commit https://github.com/facebook/react/commit/66cf2cfc8a8c4b09d2b783fd7302ae6b24150935.
2024-09-10 10:30:51 -07:00
SamChou19815 12971be8e9 [flow] Upgrade Flow to 0.245.2 (#30919)
## Summary

This PR bumps Flow all the way to the latest 0.245.2.

Most of the suppressions comes from Flow v0.239.0's change to include
undefined in the return of `Array.pop`.

I also enabled `react.custom_jsx_typing=true` and added custom jsx
typing to match the old behavior that `React.createElement` is
effectively any typed. This is necessary since various builtin
components like `React.Fragment` is actually symbol in the React repo
instead of `React.AbstractComponent<...>`. It can be made more accurate
by customizing the `React$CustomJSXFactory` type, but I will leave it to
the React team to decide.

## How did you test this change?

`yarn flow` for all the renderers

DiffTrain build for commit https://github.com/facebook/react/commit/e210d08180a63f42079b91acaa7f6af15eef6d32.
2024-09-09 08:51:21 -07:00
josephsavona 15892717ea Fix useMemoCache with setState in render
Fixes the bug that @alexmckenley and @mofeiZ found where setState-in-render can reset useMemoCache and cause an infinite loop. The bug was that renderWithHooksAgain() was not resetting hook state when rerendering (so useMemo values were preserved) but was resetting the updateQueue. This meant that the entire memo cache was cleared on a setState-in-render.

The fix here is to call a new helper function to clear the update queue. It nulls out other properties, but for memoCache it just sets the index back to zero.

ghstack-source-id: fc0947ce21
Pull Request resolved: https://github.com/facebook/react/pull/30889

DiffTrain build for commit https://github.com/facebook/react/commit/727b3615287074ddaa28069bfbd2dfee8cf73575.
2024-09-06 14:40:39 -07:00
sebmarkbage 6f1fca9c4f [Fiber] Move runWithFiberInDEV from CommitWork to CommitEffects (#30882)
Stacked on #30881.

Move `runWithFiberInDEV` from the recursive part of the commit phase and
instead wrap each call into user space. These should really map 1:1 with
where we're using `try/catch` since that's where we're calling into user
space.

The goal of this is to avoid the extra stack frames added by
`enableOwnerStacks` in the recursive parts to avoid stack overflow. This
way we only have a couple of extra at the end of the stack instead of a
couple of extra at every depth of the tree.

DiffTrain build for commit https://github.com/facebook/react/commit/a03254bc60b06c535c37e43c53b1fd40757b2ef4.
2024-09-05 18:04:03 -07:00
sebmarkbage d118acbb84 [Fiber] Extract Functions that Call User Space and Host Configs in Commit to Separate Modules (#30881)
This is mostly just moves and same code extracted into utility
functions.

This is to help clarify what needs to be wrapped in try/catch and
runWithFiberInDEV. I'll do the runWithFiberInDEV changes in a follow up.

This leaves ReactCommitWork mostly to do matching on the tag and the
recursive loops.

DiffTrain build for commit https://github.com/facebook/react/commit/fe03c56d1e51379a18676b04cf185e76f04cd457.
2024-09-05 18:02:01 -07:00
acdlite 9e99471041 Schedule prerender after something suspends (#30800)
Adds the concept of a "prerender". These special renders are spawned
whenever something suspends (and we're not already prerendering).

The purpose is to move speculative rendering work into a separate phase
that does not block the UI from updating. For example, during a
transition, if something suspends, we should not speculatively prerender
siblings that will be replaced by a fallback in the UI until *after* the
fallback has been shown to the user.

DiffTrain build for commit https://github.com/facebook/react/commit/e10e8681824e56c10fdb14e0359d878bcd748937.
2024-09-04 11:04:03 -07:00
acdlite 9625df2bf8 Temporarily disable suspending during work loop (#30762)
### Based on

- #30761
- #30759

---

`use` has an optimization where in some cases it can suspend the work
loop during the render phase until the data has resolved, rather than
unwind the stack and lose context. However, the current implementation
is not compatible with sibling prerendering. So I've temporarily
disabled it until the sibling prerendering has been refactored. We will
add it back in a later step.

DiffTrain build for commit https://github.com/facebook/react/commit/8b4c54c00f5c047a72a4cecc2689196786c3e5ff.
2024-09-04 09:47:08 -07:00
sebmarkbage 18e907e144 [Fiber] Stash ThenableState on the Dependencies Object for Use By DevTools (#30866)
This lets us track what a Component might suspend on from DevTools. We
could already collect this by replaying a component's Hooks but that
would be expensive to collect from a whole tree.

The thenables themselves might contain useful information but mainly
we'd want access to the `_debugInfo` on the thenables which might
contain additional information from the server.

https://github.com/facebook/react/blob/19bd26beb689e554fceb0b929dc5199be8cba594/packages/shared/ReactTypes.js#L114

In a follow up we should really do something similar in Flight to
transfer `use()` on the debugInfo of that Server Component.

DiffTrain build for commit https://github.com/facebook/react/commit/8d68da3f7396064614f34b84881fe8833b6039ac.
2024-09-03 13:12:53 -07:00
rickhanlonii 3ba4b124b2 Enable suspenseCallback on React Native (#29210)
## Summary

suspenseCallback feature has proved to be useful for FB Web. Let's look
at enabling the feature for the React Native build.

## How did you test this change?

Will sync the react changes with a React Native build and will verify
that performance logging is correctly notified of suspense promises
during the suspense callback.

DiffTrain build for commit https://github.com/facebook/react/commit/246d7bfeb0c90ecccd9531929b60a79d628a4c78.
2024-08-26 19:14:20 -07:00
acdlite 6c99ba76c9 Fix: Synchronous popstate transitions (#30759)
This is a refactor of the fix in #27505.

When a transition update is scheduled by a popstate event, (i.e. a back/
forward navigation) we attempt to render it synchronously even though
it's a transition, since it's likely the previous page's data is cached.

In #27505, I changed the implementation so that it only "upgrades" the
priority of the transition for a single attempt. If the attempt
suspends, say because the data is not cached after all, from then on it
should be treated as a normal transition.

But it turns out #27505 did not work as intended, because it relied on
marking the root with pending synchronous work (root.pendingLanes),
which was never cleared until the popstate update completed.

The test scenarios I wrote accidentally worked for a different reason
related to suspending the work loop, which I'm currently in the middle
of refactoring.

DiffTrain build for commit https://github.com/facebook/react/commit/ee7f6757c446c4e79ecc7e2bc22b8c9b712834b7.
2024-08-23 09:38:02 -07:00
SamChou19815 99d43a14d0 [flow] Eliminate a few React.Element type that will be synced to react-native (#30719)
## Summary

Flow will eventually remove the specific `React.Element` type. For most
of the code, it can be replaced with `React.MixedElement` or
`React.Node`.

When specific react elements are required, it needs to be replaced with
either `React$Element` which will trigger a `internal-type` lint error
that can be disabled project-wide, or use
`ExactReactElement_DEPRECATED`.

Fortunately in this case, this one can be replaced with just
`React.MixedElement`.

## How did you test this change?

`flow`

DiffTrain build for commit https://github.com/facebook/react/commit/85fb95cdffdd95f2f908ee71974cae06b1c866e1.
2024-08-16 10:03:44 -07:00
gaearon 220e25c8db [Fresh] Always reset useMemoCache on Fast Refresh (#30700)
Stacked on https://github.com/facebook/react/pull/30662.

Alternative to https://github.com/facebook/react/pull/30663 and
https://github.com/facebook/react/pull/30677.

During a Fast Refresh, we always want to evict the memo cache, same as
we do with normal `useMemo`. The mechanism used by `useMemo` and other
Hooks is this module-level variable:

https://github.com/facebook/react/blob/fca5d655d78917400a2722287351c20938166669/packages/react-reconciler/src/ReactFiberHooks.js#L304-L307

which has DEV-only behavior as if the dependencies are always different:

https://github.com/facebook/react/blob/fca5d655d78917400a2722287351c20938166669/packages/react-reconciler/src/ReactFiberHooks.js#L451-L460

The `useMemoCache` Hook doesn't use a dependency array but conceptually
I think we want the same behavior.

## Test Plan

The test passes.

---------

Co-authored-by: Lauren Tan <poteto@users.noreply.github.com>

DiffTrain build for commit https://github.com/facebook/react/commit/7e8a06cf4c628be45171da52c1a8e97f9869b7ee.
2024-08-14 17:11:17 -07:00
kassens 7a7933bb8c Cloned flag to avoid extra clones in persistent renderer (#27647)
Persistent renderers used the `Update` effect flag to check if a subtree
needs to be cloned. In some cases, that causes extra renders, such as
when a layout effect is triggered which only has an effect on the JS
side, but doesn't update the host components.

It's been a bit tricky to find the right places where this needs to be
set and I'm not 100% sure I got all the cases even though the tests
passed.

DiffTrain build for commit https://github.com/facebook/react/commit/5fb67fa25c4ea8be046c6d9af41047f3cc379279.
2024-08-01 12:18:26 -07:00
eps1lon 9fc6c4cfa7 [Devtools] Ensure initial read of useFormStatus returns NotPendingTransition (#28728)
DiffTrain build for commit https://github.com/facebook/react/commit/88ee14ffa57beb0689f26f0c52c357e3ac446af8.
2024-08-01 02:03:31 -07:00
jackpope b85f79ca45 Set enableLazyContextPropagation to dynamic on RN (#30516)
DiffTrain build for commit https://github.com/facebook/react/commit/3f8b1333daade70117e5915304cca19f14e87b53.
2024-07-30 15:38:52 -07:00
gaearon b255b4eed0 Remove RefreshRuntime.findAffectedHostInstances (#30538)
I originally added this with a plan to visualize which nodes got updated
after a Fast Refresh. I didn't end up implementing that part, and to my
knowledge, no actively used integration actually does that or use this
method.

- [Webpack plugin doesn't use
it](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/f1c8b9a44198449093ca95f85af5df97925e1cfc/lib/runtime/RefreshUtils.js)
- [RN doesn't use
it](https://github.com/facebook/react-native/blob/23c5c42de01953ed7b8e8938c2d3a8fac82250a0/packages/react-native/Libraries/Core/setUpReactRefresh.js)
- [Global GitHub code
search](https://github.com/search?q=findAffectedHostInstances&type=code&p=1)
only shows copies of this code and the type definition based on it, but
not actual calls to it

We should be able to delete this without a problem.

DiffTrain build for commit https://github.com/facebook/react/commit/96f3093becc1f26e06549b9a54b93db9df8f5689.
2024-07-30 14:14:58 -07:00
sebmarkbage 69c4befd2e [Fiber] Make DevTools Config use Static Injection (#30522)
We use static dependency injection. We shouldn't use this dynamic
dependency injection we do for DevTools internals. There's also meta
programming like spreading and stuff that isn't needed.

This moves the config from `injectIntoDevTools` to the FiberConfig so it
can be statically resolved.

Closure Compiler has some trouble generating optimal code for this
anyway so ideally we'd refactor this further but at least this is better
and saves a few bytes and avoids some code paths (when minified).

DiffTrain build for commit https://github.com/facebook/react/commit/146df7c311831a1d5b35f3783dae4a7030638fcf.
2024-07-30 12:11:02 -07:00
sebmarkbage a3617011b8 [Fiber/DevTools] Stop injecting findHostInstanceByFiber (#30519)
This is not used by DevTools since it has its own implementation of it.

This function is getting removed since `findDOMNode` is getting removed
so we shouldn't keep around extra bytes unnecessarily.

There is also `findHostInstancesForRefresh` which should really be
implemented on the `react-refresh` side. Not using an injection but
that's a heavier lift and only affects `__DEV__`.

DiffTrain build for commit https://github.com/facebook/react/commit/bea5a2bc46cc95713392175c3c6307e49c14cd98.
2024-07-29 17:12:31 -07:00
kassens aaac27a414 [RN] experiment to move Fabric completeWork to the commit phase (#30513)
There is currently a mismatch in how the persistent mode JS API and the
Fabric native code interpret `completeRoot`.

This is a short-lived experiment to see the effect of moving the Fabric
`completeRoot` call from `finalizeContainerChildren` to
`replaceContainerChildren` which in some cases does not get called.

DiffTrain build for commit https://github.com/facebook/react/commit/6b82f3c9048ff0dd7e6d628dc5770faf85d32a87.
2024-07-29 16:00:27 -07:00
poteto f98078e3fb [ci] Fix invalid username and email in synthetic commit
ghstack-source-id: 951d0ef445
Pull Request resolved: https://github.com/facebook/react/pull/30486

DiffTrain build for commit https://github.com/facebook/react/commit/b9af819f8b0e7f14200cfffe04da835b56f2f75d.
2024-07-26 12:22:37 -07:00
sebmarkbage f902e21009 Switch to binding the console with badging instead of calling it directly (#30461)
This is a major nit but this avoids an extra stack frame when we're
replaying logs.

Normally the `printToConsole` frame doesn't show up because it'd be
ignore listed.

<img width="421" alt="Screenshot 2024-07-25 at 11 49 39 AM"
src="https://github.com/user-attachments/assets/81334c2f-e19e-476a-871e-c4db9dee294e">

When you expand to show ignore listed frames a ton of other frames show
up.

<img width="516" alt="Screenshot 2024-07-25 at 11 49 47 AM"
src="https://github.com/user-attachments/assets/2ab8bdfb-464c-408d-9176-ee2fabc114b6">

The annoying thing about this frame is that it's at the top of the stack
where as typically framework stuff ends up at the bottom and something
you can ignore. The user space stack comes first.

With this fix there's no longer any `printToConsole` frame.

<img width="590" alt="Screenshot 2024-07-25 at 12 09 09 PM"
src="https://github.com/user-attachments/assets/b8365d53-31f3-43df-abce-172d608d3c9c">

Am I wiling to eat the added complexity and slightly slower performance
for this nit? Definitely.

DiffTrain build for commit https://github.com/facebook/react/commit/e8df0cf9f7c7f641192f19841db9bf34b6a0abf7.
2024-07-25 09:37:11 -07:00
jackpope 4609b0b955 Remove allowConcurrentByDefault flag (#30445)
Following https://github.com/facebook/react/pull/30436

Concurrent by default strategy has been unshipped. Here we clean up the
`allowConcurrentByDefault` path and related logic/tests.

For now, this keeps the `concurrentUpdatesByDefaultOverride` argument in
`createContainer` and `createHydrationContainer` and ignores the value
to prevent more breaking changes to `react-reconciler` in the RC stage.

DiffTrain build for commit https://github.com/facebook/react/commit/14a4699ff173936a30ec453f7b94d47105bbb252.
2024-07-25 09:04:45 -07:00
sebmarkbage b7c63f31fb [Fiber] Call life-cycles with a react-stack-bottom-frame stack frame (#30429)
Stacked on #30427.

Most hooks and such are called inside renders which already have these
on the stack but life-cycles that call out on them are useful to cut off
too.

Typically we don't create JSX in here so they wouldn't be part of owner
stacks anyway but they can be apart of plain stacks such as the ones
prefixes to console logs or printed by error dialogs.

This lets us cut off any React internals below. This should really be
possible using just ignore listing too ideally.

At this point we should maybe just build a Babel plugin that lets us
annotate a function to need to have this name.

DiffTrain build for commit https://github.com/facebook/react/commit/da4abf0047cf6dc6d9bff505bd93815264c8c3b7.
2024-07-23 15:54:36 -07:00
eps1lon 8f1a56e603 Log Fragment name when trying to render a lazy fragment (#30372)
DiffTrain build for commit https://github.com/facebook/react/commit/9cc0f6e68de2b83b11d1fb2b514d2f508c2da6f7.
2024-07-23 10:07:58 -07:00
kassens 3e6614efa7 [BE] upgrade prettier to 3.3.3 (#30420)
Mostly just changes in ternary formatting.

DiffTrain build for commit https://github.com/facebook/react/commit/b7e7f1a3fab87e8fc19e86a8088a9e0fe4710973.
2024-07-22 13:16:06 -07:00
kassens 24e446f038 Set enableFastJSX flag to true (#30343)
When these to diffs are landed, we can merge this

- [x] D59772879
- [x] D59773043

DiffTrain build for commit https://github.com/facebook/react/commit/d025ddd3b954dfc52ad7e6a036913946a8ca2644.
2024-07-22 08:55:34 -07:00
sebmarkbage 716cb62466 Tag all user space call sites with the "react-stack-bottom-frame" name (#30369)
Ideally we wouldn't need to filter out React internals and it'd just be
covered by ignore listing by any downstream tool. E.g. a framework using
captureOwnerStack could have its own ignore listing. Printed owner
stacks would get browser source map ignore-listing. React DevTools could
have its own ignore list for internals. However, it's nice to be able to
provide nice owner stacks without a bunch of noise by default.
Especially on the server since they have to be serialized.

We currently call each function that calls into user space and track its
stack frame. However, this needs code for checking each one and doesn't
let us work across bundles.

Instead, we can name each of these frame something predictable by giving
the function a name.

Unfortunately, it's a common practice to rename functions or inline them
in compilers. Even if we didn't, others downstream from us or a dev-mode
minifier could. I use this `.bind()` trick to avoid minifying these
functions and ensure they get a unique name added to them in all
browsers. It's not 100% fool proof since a smart enough compiler could
also discover that the `this` value is not used and strip out the
function and then inline it but nobody does this yet at least.

This lets us find the bottom stack easily from stack traces just by
looking for the name.

DiffTrain build for commit https://github.com/facebook/react/commit/792f1921145e51bd06b836ffa0a16ecc39c8ee82.
2024-07-22 07:52:52 -07:00
kassens 0c7969e88f [native-fb] set disableDefaultPropsExceptForClasses flag to true (#30339)
Reflecting D59402048

DiffTrain build for commit https://github.com/facebook/react/commit/1d5a208fda6064022d25204ee47da29a3229648f.
2024-07-15 11:26:30 -07:00
dmytrorykun 7e80855357 Fix fastAddProperties to properly nullify style props (#30334)
## Summary

This PR fixes the `fastAddProperties` function. Now it nullifies a prop
if it was defined in one of the items of a style array, but then set to
`undefined` or `null` in one of the subsequent items. E.g. `style:
[{top: 0}, {top: undefined}]` should evaluate to `{top: null}`. Also
added a test case for that.

## How did you test this change?
```
yarn test packages/react-native-renderer -r=xplat --variant=false
yarn test packages/react-native-renderer -r=xplat --variant=true
yarn flow native
```

DiffTrain build for commit https://github.com/facebook/react/commit/f510ece86d4621d3b0faf9fe59d850f7807dbb16.
2024-07-15 09:38:05 -07:00
kassens 7d4aaba495 [native-fb] set consoleManagedByDevToolsDuringStrictMode flag to true (#30338)
Reflecting D59232098.

DiffTrain build for commit https://github.com/facebook/react/commit/fc1371f6bf656821e92c3c41bf65f58686504001.
2024-07-15 09:36:09 -07:00
sebmarkbage e7770a1921 Disable consoleWithStackDev Transform except in RN/WWW (#30313)
Stacked on #30308.

This is now a noop module so we can stop applying the transform of
console.error using the Babel plugin in the mainline builds. I'm keeping
the transform for RN/WWW for now although it might be nice if the
transform moved into those systems as it gets synced instead of keeping
it upstream.

In jest tests we're already not running the forks for RN/WWW so we don't
need it at all there.

DiffTrain build for commit https://github.com/facebook/react/commit/ff89ba734668fdac06e8de476486830bbf9e0785.
2024-07-12 11:44:31 -07:00