@@ -107,15 +107,27 @@ const markerInstanceStack: StackCursor<Array<TracingMarkerInstance> | null> = cr
107107
108108export function pushRootMarkerInstance ( workInProgress : Fiber ) : void {
109109 if ( enableTransitionTracing ) {
110+ // On the root, every transition gets mapped to it's own map of
111+ // suspense boundaries. The transition is marked as complete when
112+ // the suspense boundaries map is empty. We do this because every
113+ // transition completes at different times and depends on different
114+ // suspense boundaries to complete. We store all the transitions
115+ // along with its map of suspense boundaries in the root incomplete
116+ // transitions map. Each entry in this map functions like a tracing
117+ // marker does, so we can push it onto the marker instance stack
110118 const transitions = getWorkInProgressTransitions ( ) ;
111119 const root = workInProgress . stateNode ;
112120 let incompleteTransitions = root . incompleteTransitions ;
113121 if ( transitions !== null ) {
122+ // Create a mapping from transition to suspense boundaries
123+ // We instantiate this lazily, only if transitions exist
114124 if ( incompleteTransitions === null ) {
115125 root . incompleteTransitions = incompleteTransitions = new Map ( ) ;
116126 }
117127
118128 transitions . forEach ( transition => {
129+ // We need to create a new map here because we only have access to the
130+ // object instance in the commit phase
119131 incompleteTransitions . set ( transition , new Map ( ) ) ;
120132 } ) ;
121133 }
@@ -124,6 +136,9 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
124136 push ( markerInstanceStack , null , workInProgress ) ;
125137 } else {
126138 const markerInstances = [ ] ;
139+ // For ever transition on the suspense boundary, we push the transition
140+ // along with its map of pending suspense boundaries onto the marker
141+ // instance stack.
127142 incompleteTransitions . forEach ( ( pendingSuspenseBoundaries , transition ) => {
128143 markerInstances . push ( {
129144 transitions : new Set ( [ transition ] ) ,
@@ -143,12 +158,9 @@ export function popRootMarkerInstance(workInProgress: Fiber) {
143158
144159export function pushMarkerInstance (
145160 workInProgress : Fiber ,
146- transitions : Set < Transition > | null ,
147- pendingSuspenseBoundaries : PendingSuspenseBoundaries | null ,
161+ markerInstance : TracingMarkerInstance ,
148162) : void {
149163 if ( enableTransitionTracing ) {
150- const markerInstance = { transitions, pendingSuspenseBoundaries} ;
151-
152164 if ( markerInstanceStack . current === null ) {
153165 push ( markerInstanceStack , [ markerInstance ] , workInProgress ) ;
154166 } else {
0 commit comments