@@ -126,7 +126,6 @@ import {
126126 captureCommitPhaseError ,
127127 resolveRetryWakeable ,
128128 markCommitTimeOfFallback ,
129- enqueuePendingPassiveProfilerEffect ,
130129} from './ReactFiberWorkLoop.new' ;
131130import {
132131 NoFlags as NoHookEffect ,
@@ -411,63 +410,6 @@ function commitHookEffectListMount(tag: number, finishedWork: Fiber) {
411410 }
412411}
413412
414- export function commitPassiveEffectDurations (
415- finishedRoot : FiberRoot ,
416- finishedWork : Fiber ,
417- ) : void {
418- if ( enableProfilerTimer && enableProfilerCommitHooks ) {
419- // Only Profilers with work in their subtree will have an Update effect scheduled.
420- if ( ( finishedWork . flags & Update ) !== NoFlags ) {
421- switch ( finishedWork . tag ) {
422- case Profiler : {
423- const { passiveEffectDuration } = finishedWork . stateNode ;
424- const { id , onPostCommit } = finishedWork . memoizedProps ;
425-
426- // This value will still reflect the previous commit phase.
427- // It does not get reset until the start of the next commit phase.
428- const commitTime = getCommitTime ( ) ;
429-
430- let phase = finishedWork . alternate === null ? 'mount' : 'update' ;
431- if ( enableProfilerNestedUpdatePhase ) {
432- if ( isCurrentUpdateNested ( ) ) {
433- phase = 'nested-update' ;
434- }
435- }
436-
437- if ( typeof onPostCommit === 'function' ) {
438- if ( enableSchedulerTracing ) {
439- onPostCommit (
440- id ,
441- phase ,
442- passiveEffectDuration ,
443- commitTime ,
444- finishedRoot . memoizedInteractions ,
445- ) ;
446- } else {
447- onPostCommit ( id , phase, passiveEffectDuration, commitTime) ;
448- }
449- }
450-
451- // Bubble times to the next nearest ancestor Profiler.
452- // After we process that Profiler, we'll bubble further up.
453- let parentFiber = finishedWork . return ;
454- while ( parentFiber !== null ) {
455- if ( parentFiber . tag === Profiler ) {
456- const parentStateNode = parentFiber . stateNode ;
457- parentStateNode . passiveEffectDuration += passiveEffectDuration ;
458- break ;
459- }
460- parentFiber = parentFiber . return ;
461- }
462- break ;
463- }
464- default :
465- break ;
466- }
467- }
468- }
469- }
470-
471413function commitLifeCycles (
472414 finishedRoot : FiberRoot ,
473415 current : Fiber | null ,
@@ -749,11 +691,6 @@ function commitLifeCycles(
749691 }
750692 }
751693
752- // Schedule a passive effect for this Profiler to call onPostCommit hooks.
753- // This effect should be scheduled even if there is no onPostCommit callback for this Profiler,
754- // because the effect is also where times bubble to parent Profilers.
755- enqueuePendingPassiveProfilerEffect ( finishedWork ) ;
756-
757694 // Propagate layout effect durations to the next nearest Profiler ancestor.
758695 // Do not reset these values until the next render so DevTools has a chance to read them first.
759696 let parentFiber = finishedWork . return ;
@@ -1888,6 +1825,53 @@ function commitPassiveMountOnFiber(
18881825 }
18891826 break ;
18901827 }
1828+ case Profiler : {
1829+ if ( enableProfilerTimer && enableProfilerCommitHooks ) {
1830+ // Only Profilers with work in their subtree will have an Update effect scheduled.
1831+ if ( ( finishedWork . flags & Update ) !== NoFlags ) {
1832+ const { passiveEffectDuration } = finishedWork . stateNode ;
1833+ const { id , onPostCommit } = finishedWork . memoizedProps ;
1834+
1835+ // This value will still reflect the previous commit phase.
1836+ // It does not get reset until the start of the next commit phase.
1837+ const commitTime = getCommitTime ( ) ;
1838+
1839+ let phase = finishedWork . alternate === null ? 'mount' : 'update' ;
1840+ if ( enableProfilerNestedUpdatePhase ) {
1841+ if ( isCurrentUpdateNested ( ) ) {
1842+ phase = 'nested-update' ;
1843+ }
1844+ }
1845+
1846+ if ( typeof onPostCommit === 'function' ) {
1847+ if ( enableSchedulerTracing ) {
1848+ onPostCommit (
1849+ id ,
1850+ phase ,
1851+ passiveEffectDuration ,
1852+ commitTime ,
1853+ finishedRoot . memoizedInteractions ,
1854+ ) ;
1855+ } else {
1856+ onPostCommit ( id , phase, passiveEffectDuration, commitTime) ;
1857+ }
1858+ }
1859+
1860+ // Bubble times to the next nearest ancestor Profiler.
1861+ // After we process that Profiler, we'll bubble further up.
1862+ let parentFiber = finishedWork . return ;
1863+ while ( parentFiber !== null ) {
1864+ if ( parentFiber . tag === Profiler ) {
1865+ const parentStateNode = parentFiber . stateNode ;
1866+ parentStateNode . passiveEffectDuration += passiveEffectDuration ;
1867+ break ;
1868+ }
1869+ parentFiber = parentFiber . return ;
1870+ }
1871+ }
1872+ }
1873+ break ;
1874+ }
18911875 }
18921876}
18931877
0 commit comments