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