GeezerVison is showing github.com — [Transition Tracing] Add Offscreen Queue (#24341) · react/react@f7cf077
File treeExpand file treeCollapse file tree Open diff view settings packages/react-reconciler/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.new.js +32Lines changed: 32 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,7 @@ import type {SuspenseContext} from './ReactFiberSuspenseContext.new'; | 26 | 26 | import type { | 27 | 27 | OffscreenProps, | 28 | 28 | OffscreenState, | | 29 | + OffscreenQueue, | 29 | 30 | } from './ReactFiberOffscreenComponent'; | 30 | 31 | import type { | 31 | 32 | Cache, | @@ -255,6 +256,7 @@ import { | 255 | 256 | getSuspendedCache, | 256 | 257 | pushTransition, | 257 | 258 | getOffscreenDeferredCache, | | 259 | + getSuspendedTransitions, | 258 | 260 | } from './ReactFiberTransition.new'; | 259 | 261 |
| 260 | 262 | const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | @@ -2161,6 +2163,16 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2161 | 2163 | renderLanes, | 2162 | 2164 | ); | 2163 | 2165 | workInProgress.memoizedState = SUSPENDED_MARKER; | | 2166 | + if (enableTransitionTracing) { | | 2167 | + const currentTransitions = getSuspendedTransitions(); | | 2168 | + if (currentTransitions !== null) { | | 2169 | + const primaryChildUpdateQueue: OffscreenQueue = { | | 2170 | + transitions: currentTransitions, | | 2171 | + }; | | 2172 | + primaryChildFragment.updateQueue = primaryChildUpdateQueue; | | 2173 | + } | | 2174 | + } | | 2175 | + | 2164 | 2176 | return fallbackFragment; | 2165 | 2177 | } else if ( | 2166 | 2178 | enableCPUSuspense && | @@ -2281,6 +2293,15 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2281 | 2293 | prevOffscreenState === null | 2282 | 2294 | ? mountSuspenseOffscreenState(renderLanes) | 2283 | 2295 | : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); | | 2296 | + if (enableTransitionTracing) { | | 2297 | + const currentTransitions = getSuspendedTransitions(); | | 2298 | + if (currentTransitions !== null) { | | 2299 | + const primaryChildUpdateQueue: OffscreenQueue = { | | 2300 | + transitions: currentTransitions, | | 2301 | + }; | | 2302 | + primaryChildFragment.updateQueue = primaryChildUpdateQueue; | | 2303 | + } | | 2304 | + } | 2284 | 2305 | primaryChildFragment.childLanes = getRemainingWorkInPrimaryTree( | 2285 | 2306 | current, | 2286 | 2307 | renderLanes, | @@ -2322,6 +2343,17 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2322 | 2343 | current, | 2323 | 2344 | renderLanes, | 2324 | 2345 | ); | | 2346 | + | | 2347 | + if (enableTransitionTracing) { | | 2348 | + const currentTransitions = getSuspendedTransitions(); | | 2349 | + if (currentTransitions !== null) { | | 2350 | + const primaryChildUpdateQueue: OffscreenQueue = { | | 2351 | + transitions: currentTransitions, | | 2352 | + }; | | 2353 | + primaryChildFragment.updateQueue = primaryChildUpdateQueue; | | 2354 | + } | | 2355 | + } | | 2356 | + | 2325 | 2357 | // Skip the primary children, and continue working on the | 2326 | 2358 | // fallback children. | 2327 | 2359 | workInProgress.memoizedState = SUSPENDED_MARKER; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.old.js +32Lines changed: 32 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,7 @@ import type {SuspenseContext} from './ReactFiberSuspenseContext.old'; | 26 | 26 | import type { | 27 | 27 | OffscreenProps, | 28 | 28 | OffscreenState, | | 29 | + OffscreenQueue, | 29 | 30 | } from './ReactFiberOffscreenComponent'; | 30 | 31 | import type { | 31 | 32 | Cache, | @@ -255,6 +256,7 @@ import { | 255 | 256 | getSuspendedCache, | 256 | 257 | pushTransition, | 257 | 258 | getOffscreenDeferredCache, | | 259 | + getSuspendedTransitions, | 258 | 260 | } from './ReactFiberTransition.old'; | 259 | 261 |
| 260 | 262 | const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | @@ -2161,6 +2163,16 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2161 | 2163 | renderLanes, | 2162 | 2164 | ); | 2163 | 2165 | workInProgress.memoizedState = SUSPENDED_MARKER; | | 2166 | + if (enableTransitionTracing) { | | 2167 | + const currentTransitions = getSuspendedTransitions(); | | 2168 | + if (currentTransitions !== null) { | | 2169 | + const primaryChildUpdateQueue: OffscreenQueue = { | | 2170 | + transitions: currentTransitions, | | 2171 | + }; | | 2172 | + primaryChildFragment.updateQueue = primaryChildUpdateQueue; | | 2173 | + } | | 2174 | + } | | 2175 | + | 2164 | 2176 | return fallbackFragment; | 2165 | 2177 | } else if ( | 2166 | 2178 | enableCPUSuspense && | @@ -2281,6 +2293,15 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2281 | 2293 | prevOffscreenState === null | 2282 | 2294 | ? mountSuspenseOffscreenState(renderLanes) | 2283 | 2295 | : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); | | 2296 | + if (enableTransitionTracing) { | | 2297 | + const currentTransitions = getSuspendedTransitions(); | | 2298 | + if (currentTransitions !== null) { | | 2299 | + const primaryChildUpdateQueue: OffscreenQueue = { | | 2300 | + transitions: currentTransitions, | | 2301 | + }; | | 2302 | + primaryChildFragment.updateQueue = primaryChildUpdateQueue; | | 2303 | + } | | 2304 | + } | 2284 | 2305 | primaryChildFragment.childLanes = getRemainingWorkInPrimaryTree( | 2285 | 2306 | current, | 2286 | 2307 | renderLanes, | @@ -2322,6 +2343,17 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { | 2322 | 2343 | current, | 2323 | 2344 | renderLanes, | 2324 | 2345 | ); | | 2346 | + | | 2347 | + if (enableTransitionTracing) { | | 2348 | + const currentTransitions = getSuspendedTransitions(); | | 2349 | + if (currentTransitions !== null) { | | 2350 | + const primaryChildUpdateQueue: OffscreenQueue = { | | 2351 | + transitions: currentTransitions, | | 2352 | + }; | | 2353 | + primaryChildFragment.updateQueue = primaryChildUpdateQueue; | | 2354 | + } | | 2355 | + } | | 2356 | + | 2325 | 2357 | // Skip the primary children, and continue working on the | 2326 | 2358 | // fallback children. | 2327 | 2359 | workInProgress.memoizedState = SUSPENDED_MARKER; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCommitWork.new.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2781,6 +2781,11 @@ function commitPassiveMountOnFiber( | 2781 | 2781 | } | 2782 | 2782 | } | 2783 | 2783 | } | | 2784 | + | | 2785 | + if (enableTransitionTracing) { | | 2786 | + // TODO: Add code to actually process the update queue | | 2787 | + finishedWork.updateQueue = null; | | 2788 | + } | 2784 | 2789 | break; | 2785 | 2790 | } | 2786 | 2791 | case CacheComponent: { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCommitWork.old.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2781,6 +2781,11 @@ function commitPassiveMountOnFiber( | 2781 | 2781 | } | 2782 | 2782 | } | 2783 | 2783 | } | | 2784 | + | | 2785 | + if (enableTransitionTracing) { | | 2786 | + // TODO: Add code to actually process the update queue | | 2787 | + finishedWork.updateQueue = null; | | 2788 | + } | 2784 | 2789 | break; | 2785 | 2790 | } | 2786 | 2791 | case CacheComponent: { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberOffscreenComponent.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import type {ReactNodeList, OffscreenMode} from 'shared/ReactTypes'; | 11 | 11 | import type {Lanes} from './ReactFiberLane.old'; | 12 | 12 | import type {SpawnedCachePool} from './ReactFiberCacheComponent.new'; | 13 | 13 | import type {Transition} from './ReactFiberTracingMarkerComponent.new'; | | 14 | + | 14 | 15 | export type OffscreenProps = {| | 15 | 16 | // TODO: Pick an API before exposing the Offscreen type. I've chosen an enum | 16 | 17 | // for now, since we might have multiple variants. For example, hiding the | @@ -33,4 +34,8 @@ export type OffscreenState = {| | 33 | 34 | transitions: Set<Transition> | null, | 34 | 35 | |}; | 35 | 36 |
| | 37 | +export type OffscreenQueue = {| | | 38 | + transitions: Array<Transition> | null, | | 39 | +|} | null; | | 40 | + | 36 | 41 | export type OffscreenInstance = {}; |
|