@@ -29,6 +29,7 @@ import {
29
29
deferPassiveEffectCleanupDuringUnmount ,
30
30
enableSchedulerTracing ,
31
31
enableProfilerTimer ,
32
+ enableProfilerCommitHooks ,
32
33
enableSuspenseServerRenderer ,
33
34
enableDeprecatedFlareAPI ,
34
35
enableFundamentalAPI ,
@@ -183,7 +184,11 @@ const callComponentWillUnmountWithTimer = function(current, instance) {
183
184
startPhaseTimer ( current , 'componentWillUnmount' ) ;
184
185
instance . props = current . memoizedProps ;
185
186
instance . state = current . memoizedState ;
186
- if ( enableProfilerTimer && current . mode & ProfileMode ) {
187
+ if (
188
+ enableProfilerTimer &&
189
+ enableProfilerCommitHooks &&
190
+ current . mode & ProfileMode
191
+ ) {
187
192
try {
188
193
startLayoutEffectTimer ( ) ;
189
194
instance . componentWillUnmount ( ) ;
@@ -447,7 +452,11 @@ export function commitPassiveHookEffects(finishedWork: Fiber): void {
447
452
// TODO (#17945) We should call all passive destroy functions (for all fibers)
448
453
// before calling any create functions. The current approach only serializes
449
454
// these for a single fiber.
450
- if ( enableProfilerTimer && finishedWork . mode & ProfileMode ) {
455
+ if (
456
+ enableProfilerTimer &&
457
+ enableProfilerCommitHooks &&
458
+ finishedWork . mode & ProfileMode
459
+ ) {
451
460
try {
452
461
startPassiveEffectTimer ( ) ;
453
462
commitHookEffectListUnmount (
@@ -480,7 +489,7 @@ export function commitPassiveEffectDurations(
480
489
finishedRoot : FiberRoot ,
481
490
finishedWork : Fiber ,
482
491
) : void {
483
- if ( enableProfilerTimer ) {
492
+ if ( enableProfilerTimer && enableProfilerCommitHooks ) {
484
493
// Only Profilers with work in their subtree will have an Update effect scheduled.
485
494
if ( ( finishedWork . effectTag & Update ) !== NoEffect ) {
486
495
switch ( finishedWork . tag ) {
@@ -546,7 +555,11 @@ function commitLifeCycles(
546
555
// This is done to prevent sibling component effects from interfering with each other,
547
556
// e.g. a destroy function in one component should never override a ref set
548
557
// by a create function in another component during the same commit.
549
- if ( enableProfilerTimer && finishedWork . mode & ProfileMode ) {
558
+ if (
559
+ enableProfilerTimer &&
560
+ enableProfilerCommitHooks &&
561
+ finishedWork . mode & ProfileMode
562
+ ) {
550
563
try {
551
564
startLayoutEffectTimer ( ) ;
552
565
commitHookEffectListMount ( HookLayout | HookHasEffect , finishedWork ) ;
@@ -597,7 +610,11 @@ function commitLifeCycles(
597
610
}
598
611
}
599
612
}
600
- if ( enableProfilerTimer && finishedWork . mode & ProfileMode ) {
613
+ if (
614
+ enableProfilerTimer &&
615
+ enableProfilerCommitHooks &&
616
+ finishedWork . mode & ProfileMode
617
+ ) {
601
618
try {
602
619
startLayoutEffectTimer ( ) ;
603
620
instance . componentDidMount ( ) ;
@@ -645,7 +662,11 @@ function commitLifeCycles(
645
662
}
646
663
}
647
664
}
648
- if ( enableProfilerTimer && finishedWork . mode & ProfileMode ) {
665
+ if (
666
+ enableProfilerTimer &&
667
+ enableProfilerCommitHooks &&
668
+ finishedWork . mode & ProfileMode
669
+ ) {
649
670
try {
650
671
startLayoutEffectTimer ( ) ;
651
672
instance . componentDidUpdate (
@@ -773,40 +794,42 @@ function commitLifeCycles(
773
794
}
774
795
}
775
796
776
- if ( typeof onCommit === 'function' ) {
777
- if ( enableSchedulerTracing ) {
778
- onCommit (
779
- finishedWork . memoizedProps . id ,
780
- current === null ? 'mount' : 'update' ,
781
- effectDuration ,
782
- commitTime ,
783
- finishedRoot . memoizedInteractions ,
784
- ) ;
785
- } else {
786
- onCommit (
787
- finishedWork . memoizedProps . id ,
788
- current === null ? 'mount' : 'update' ,
789
- effectDuration ,
790
- commitTime ,
791
- ) ;
797
+ if ( enableProfilerCommitHooks ) {
798
+ if ( typeof onCommit === 'function' ) {
799
+ if ( enableSchedulerTracing ) {
800
+ onCommit (
801
+ finishedWork . memoizedProps . id ,
802
+ current === null ? 'mount' : 'update' ,
803
+ effectDuration ,
804
+ commitTime ,
805
+ finishedRoot . memoizedInteractions ,
806
+ ) ;
807
+ } else {
808
+ onCommit (
809
+ finishedWork . memoizedProps . id ,
810
+ current === null ? 'mount' : 'update' ,
811
+ effectDuration ,
812
+ commitTime ,
813
+ ) ;
814
+ }
792
815
}
793
- }
794
816
795
- // Schedule a passive effect for this Profiler to call onPostCommit hooks.
796
- // This effect should be scheduled even if there is no onPostCommit callback for this Profiler,
797
- // because the effect is also where times bubble to parent Profilers.
798
- enqueuePendingPassiveProfilerEffect ( finishedWork ) ;
799
-
800
- // Propagate layout effect durations to the next nearest Profiler ancestor.
801
- // Do not reset these values until the next render so DevTools has a chance to read them first.
802
- let parentFiber = finishedWork . return ;
803
- while ( parentFiber !== null ) {
804
- if ( parentFiber . tag === Profiler ) {
805
- const parentStateNode = parentFiber . stateNode ;
806
- parentStateNode . effectDuration += effectDuration ;
807
- break ;
817
+ // Schedule a passive effect for this Profiler to call onPostCommit hooks.
818
+ // This effect should be scheduled even if there is no onPostCommit callback for this Profiler,
819
+ // because the effect is also where times bubble to parent Profilers.
820
+ enqueuePendingPassiveProfilerEffect ( finishedWork ) ;
821
+
822
+ // Propagate layout effect durations to the next nearest Profiler ancestor.
823
+ // Do not reset these values until the next render so DevTools has a chance to read them first.
824
+ let parentFiber = finishedWork . return ;
825
+ while ( parentFiber !== null ) {
826
+ if ( parentFiber . tag === Profiler ) {
827
+ const parentStateNode = parentFiber . stateNode ;
828
+ parentStateNode . effectDuration += effectDuration ;
829
+ break ;
830
+ }
831
+ parentFiber = parentFiber . return ;
808
832
}
809
- parentFiber = parentFiber . return ;
810
833
}
811
834
}
812
835
return ;
@@ -958,7 +981,11 @@ function commitUnmount(
958
981
if ( ( tag & HookPassive ) !== NoHookEffect ) {
959
982
enqueuePendingPassiveHookEffectUnmount ( current , effect ) ;
960
983
} else {
961
- if ( enableProfilerTimer && current . mode & ProfileMode ) {
984
+ if (
985
+ enableProfilerTimer &&
986
+ enableProfilerCommitHooks &&
987
+ current . mode & ProfileMode
988
+ ) {
962
989
startLayoutEffectTimer ( ) ;
963
990
safelyCallDestroy ( current , destroy ) ;
964
991
recordLayoutEffectDuration ( current ) ;
@@ -991,7 +1018,11 @@ function commitUnmount(
991
1018
do {
992
1019
const { destroy, tag} = effect ;
993
1020
if ( destroy !== undefined ) {
994
- if ( enableProfilerTimer && current . mode & ProfileMode ) {
1021
+ if (
1022
+ enableProfilerTimer &&
1023
+ enableProfilerCommitHooks &&
1024
+ current . mode & ProfileMode
1025
+ ) {
995
1026
if ( ( tag & HookPassive ) !== NoHookEffect ) {
996
1027
safelyCallDestroy ( current , destroy ) ;
997
1028
} else {
@@ -1543,7 +1574,11 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1543
1574
// This prevents sibling component effects from interfering with each other,
1544
1575
// e.g. a destroy function in one component should never override a ref set
1545
1576
// by a create function in another component during the same commit.
1546
- if ( enableProfilerTimer && finishedWork . mode & ProfileMode ) {
1577
+ if (
1578
+ enableProfilerTimer &&
1579
+ enableProfilerCommitHooks &&
1580
+ finishedWork . mode & ProfileMode
1581
+ ) {
1547
1582
try {
1548
1583
startLayoutEffectTimer ( ) ;
1549
1584
commitHookEffectListUnmount (
@@ -1598,7 +1633,11 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1598
1633
// This prevents sibling component effects from interfering with each other,
1599
1634
// e.g. a destroy function in one component should never override a ref set
1600
1635
// by a create function in another component during the same commit.
1601
- if ( enableProfilerTimer && finishedWork . mode & ProfileMode ) {
1636
+ if (
1637
+ enableProfilerTimer &&
1638
+ enableProfilerCommitHooks &&
1639
+ finishedWork . mode & ProfileMode
1640
+ ) {
1602
1641
try {
1603
1642
startLayoutEffectTimer ( ) ;
1604
1643
commitHookEffectListUnmount ( HookLayout | HookHasEffect , finishedWork ) ;
0 commit comments