@@ -66,7 +66,12 @@ import {
6666} from './ReactChildFiber' ;
6767import { processUpdateQueue } from './ReactUpdateQueue' ;
6868import { NoWork , Never } from './ReactFiberExpirationTime' ;
69- import { ConcurrentMode , StrictMode , NoContext } from './ReactTypeOfMode' ;
69+ import {
70+ ConcurrentMode ,
71+ NoContext ,
72+ ProfileMode ,
73+ StrictMode ,
74+ } from './ReactTypeOfMode' ;
7075import {
7176 shouldSetTextContent ,
7277 shouldDeprioritizeSubtree ,
@@ -743,7 +748,7 @@ function mountLazyComponent(
743748) {
744749 if ( _current !== null ) {
745750 // An lazy component only mounts if it suspended inside a non-
746- // concurrent tree, in an inconsistent state. We want to tree it like
751+ // concurrent tree, in an inconsistent state. We want to treat it like
747752 // a new mount, even though an empty version of it already committed.
748753 // Disconnect the alternate pointers.
749754 _current . alternate = null ;
@@ -829,7 +834,7 @@ function mountIncompleteClassComponent(
829834) {
830835 if ( _current !== null ) {
831836 // An incomplete component only mounts if it suspended inside a non-
832- // concurrent tree, in an inconsistent state. We want to tree it like
837+ // concurrent tree, in an inconsistent state. We want to treat it like
833838 // a new mount, even though an empty version of it already committed.
834839 // Disconnect the alternate pointers.
835840 _current . alternate = null ;
@@ -886,7 +891,7 @@ function mountIndeterminateComponent(
886891) {
887892 if ( _current !== null ) {
888893 // An indeterminate component only mounts if it suspended inside a non-
889- // concurrent tree, in an inconsistent state. We want to tree it like
894+ // concurrent tree, in an inconsistent state. We want to treat it like
890895 // a new mount, even though an empty version of it already committed.
891896 // Disconnect the alternate pointers.
892897 _current . alternate = null ;
@@ -1188,6 +1193,19 @@ function updateSuspenseComponent(
11881193 }
11891194 }
11901195
1196+ // Because primaryChildFragment is a new fiber that we're inserting as the
1197+ // parent of a new tree, we need to set its treeBaseDuration.
1198+ if ( enableProfilerTimer && workInProgress . mode & ProfileMode ) {
1199+ // treeBaseDuration is the sum of all the child tree base durations.
1200+ let treeBaseDuration = 0 ;
1201+ let hiddenChild = primaryChildFragment . child ;
1202+ while ( hiddenChild !== null ) {
1203+ treeBaseDuration += hiddenChild . treeBaseDuration ;
1204+ hiddenChild = hiddenChild . sibling ;
1205+ }
1206+ primaryChildFragment . treeBaseDuration = treeBaseDuration ;
1207+ }
1208+
11911209 // Clone the fallback child fragment, too. These we'll continue
11921210 // working on.
11931211 const fallbackChildFragment = ( primaryChildFragment . sibling = createWorkInProgress (
@@ -1239,6 +1257,7 @@ function updateSuspenseComponent(
12391257 NoWork ,
12401258 null ,
12411259 ) ;
1260+
12421261 primaryChildFragment . effectTag |= Placement ;
12431262 primaryChildFragment . child = currentPrimaryChild ;
12441263 currentPrimaryChild . return = primaryChildFragment ;
@@ -1254,6 +1273,19 @@ function updateSuspenseComponent(
12541273 primaryChildFragment . child = progressedPrimaryChild ;
12551274 }
12561275
1276+ // Because primaryChildFragment is a new fiber that we're inserting as the
1277+ // parent of a new tree, we need to set its treeBaseDuration.
1278+ if ( enableProfilerTimer && workInProgress . mode & ProfileMode ) {
1279+ // treeBaseDuration is the sum of all the child tree base durations.
1280+ let treeBaseDuration = 0 ;
1281+ let hiddenChild = primaryChildFragment . child ;
1282+ while ( hiddenChild !== null ) {
1283+ treeBaseDuration += hiddenChild . treeBaseDuration ;
1284+ hiddenChild = hiddenChild . sibling ;
1285+ }
1286+ primaryChildFragment . treeBaseDuration = treeBaseDuration ;
1287+ }
1288+
12571289 // Create a fragment from the fallback children, too.
12581290 const fallbackChildFragment = ( primaryChildFragment . sibling = createFiberFromFragment (
12591291 nextFallbackChildren ,
0 commit comments