@@ -121,7 +121,6 @@ import {
121
121
captureCommitPhaseError ,
122
122
resolveRetryWakeable ,
123
123
markCommitTimeOfFallback ,
124
- enqueuePendingPassiveProfilerEffect ,
125
124
schedulePassiveEffectCallback ,
126
125
} from './ReactFiberWorkLoop.new' ;
127
126
import {
@@ -507,57 +506,55 @@ function commitHookEffectListMount2(fiber: Fiber): void {
507
506
}
508
507
}
509
508
510
- export function commitPassiveEffectDurations (
509
+ function commitProfilerPassiveEffect (
511
510
finishedRoot : FiberRoot ,
512
511
finishedWork : Fiber ,
513
512
) : void {
514
513
if ( enableProfilerTimer && enableProfilerCommitHooks ) {
515
- // Only Profilers with work in their subtree will have an Update effect scheduled.
516
- if ( ( finishedWork . flags & Update ) !== NoFlags ) {
517
- switch ( finishedWork . tag ) {
518
- case Profiler : {
519
- const { passiveEffectDuration } = finishedWork . stateNode ;
520
- const { id , onPostCommit } = finishedWork . memoizedProps ;
521
-
522
- // This value will still reflect the previous commit phase.
523
- // It does not get reset until the start of the next commit phase.
524
- const commitTime = getCommitTime ( ) ;
525
-
526
- if ( typeof onPostCommit === 'function' ) {
527
- if ( enableSchedulerTracing ) {
528
- onPostCommit (
529
- id ,
530
- finishedWork . alternate === null ? 'mount' : 'update' ,
531
- passiveEffectDuration ,
532
- commitTime ,
533
- finishedRoot . memoizedInteractions ,
534
- ) ;
535
- } else {
536
- onPostCommit (
537
- id ,
538
- finishedWork. alternate === null ? 'mount' : 'update' ,
539
- passiveEffectDuration ,
540
- commitTime ,
541
- ) ;
542
- }
514
+ switch ( finishedWork . tag ) {
515
+ case Profiler : {
516
+ const { passiveEffectDuration } = finishedWork . stateNode ;
517
+ const { id , onPostCommit } = finishedWork . memoizedProps ;
518
+
519
+ // This value will still reflect the previous commit phase.
520
+ // It does not get reset until the start of the next commit phase.
521
+ const commitTime = getCommitTime ( ) ;
522
+
523
+ if ( typeof onPostCommit === 'function' ) {
524
+ if ( enableSchedulerTracing ) {
525
+ onPostCommit (
526
+ id ,
527
+ finishedWork . alternate === null ? 'mount' : 'update' ,
528
+ passiveEffectDuration ,
529
+ commitTime ,
530
+ finishedRoot . memoizedInteractions ,
531
+ ) ;
532
+ } else {
533
+ onPostCommit (
534
+ id ,
535
+ finishedWork. alternate === null ? 'mount' : 'update' ,
536
+ passiveEffectDuration ,
537
+ commitTime ,
538
+ ) ;
543
539
}
540
+ }
544
541
545
- // Bubble times to the next nearest ancestor Profiler.
546
- // After we process that Profiler, we'll bubble further up.
547
- let parentFiber = finishedWork . return ;
548
- while ( parentFiber !== null ) {
549
- if ( parentFiber . tag === Profiler ) {
550
- const parentStateNode = parentFiber . stateNode ;
551
- parentStateNode . passiveEffectDuration += passiveEffectDuration ;
552
- break ;
553
- }
554
- parentFiber = parentFiber . return ;
542
+ // Bubble times to the next nearest ancestor Profiler.
543
+ // After we process that Profiler, we'll bubble further up.
544
+ // TODO: Use JS Stack instead
545
+ let parentFiber = finishedWork . return ;
546
+ while ( parentFiber !== null ) {
547
+ if ( parentFiber . tag === Profiler ) {
548
+ const parentStateNode = parentFiber . stateNode ;
549
+ parentStateNode . passiveEffectDuration += passiveEffectDuration ;
550
+ break ;
555
551
}
556
- break ;
552
+ parentFiber = parentFiber . return ;
557
553
}
558
- default :
559
- break ;
554
+ break ;
560
555
}
556
+ default :
557
+ break ;
561
558
}
562
559
}
563
560
}
@@ -841,13 +838,9 @@ function commitLifeCycles(
841
838
}
842
839
}
843
840
844
- // Schedule a passive effect for this Profiler to call onPostCommit hooks.
845
- // This effect should be scheduled even if there is no onPostCommit callback for this Profiler,
846
- // because the effect is also where times bubble to parent Profilers.
847
- enqueuePendingPassiveProfilerEffect ( finishedWork ) ;
848
-
849
841
// Propagate layout effect durations to the next nearest Profiler ancestor.
850
842
// Do not reset these values until the next render so DevTools has a chance to read them first.
843
+ // TODO: Use JS Stack instead
851
844
let parentFiber = finishedWork . return ;
852
845
while ( parentFiber !== null ) {
853
846
if ( parentFiber . tag === Profiler ) {
@@ -1912,6 +1905,7 @@ function commitPassiveWork(finishedWork: Fiber): void {
1912
1905
finishedWork ,
1913
1906
finishedWork . return ,
1914
1907
) ;
1908
+ break ;
1915
1909
}
1916
1910
}
1917
1911
}
@@ -1933,13 +1927,21 @@ function commitPassiveUnmount(
1933
1927
}
1934
1928
}
1935
1929
1936
- function commitPassiveLifeCycles ( finishedWork : Fiber ) : void {
1930
+ function commitPassiveLifeCycles (
1931
+ finishedRoot : FiberRoot ,
1932
+ finishedWork : Fiber ,
1933
+ ) : void {
1937
1934
switch ( finishedWork . tag ) {
1938
1935
case FunctionComponent :
1939
1936
case ForwardRef :
1940
1937
case SimpleMemoComponent :
1941
1938
case Block : {
1942
1939
commitHookEffectListMount2 ( finishedWork ) ;
1940
+ break ;
1941
+ }
1942
+ case Profiler : {
1943
+ commitProfilerPassiveEffect ( finishedRoot , finishedWork ) ;
1944
+ break ;
1943
1945
}
1944
1946
}
1945
1947
}
0 commit comments