@@ -33,6 +33,7 @@ import {
3333 enableComponentPerformanceTrack ,
3434} from 'shared/ReactFeatureFlags' ;
3535
36+ import getComponentNameFromFiber from './getComponentNameFromFiber' ;
3637import { isAlreadyRendering } from './ReactFiberWorkLoop' ;
3738
3839// Intentionally not named imports because Rollup would use dynamic dispatch for
@@ -68,6 +69,8 @@ export let blockingClampTime: number = -0;
6869export let blockingUpdateTime : number = - 1.1 ; // First sync setState scheduled.
6970export let blockingUpdateTask : null | ConsoleTask = null ; // First sync setState's stack trace.
7071export let blockingUpdateType : UpdateType = 0 ;
72+ export let blockingUpdateMethodName : null | string = null ; // The name of the method that caused first sync update.
73+ export let blockingUpdateComponentName : null | string = null ; // The name of the component where first sync update happened.
7174export let blockingEventTime : number = - 1.1 ; // Event timeStamp of the first setState.
7275export let blockingEventType : null | string = null ; // Event type of the first setState.
7376export let blockingEventIsRepeat : boolean = false ;
@@ -78,6 +81,8 @@ export let transitionStartTime: number = -1.1; // First startTransition call bef
7881export let transitionUpdateTime : number = - 1.1 ; // First transition setState scheduled.
7982export let transitionUpdateType : UpdateType = 0 ;
8083export let transitionUpdateTask : null | ConsoleTask = null ; // First transition setState's stack trace.
84+ export let transitionUpdateMethodName : null | string = null ; // The name of the method that caused first transition update.
85+ export let transitionUpdateComponentName : null | string = null ; // The name of the component where first transition update happened.
8186export let transitionEventTime : number = - 1.1 ; // Event timeStamp of the first transition.
8287export let transitionEventType : null | string = null ; // Event type of the first transition.
8388export let transitionEventIsRepeat : boolean = false ;
@@ -94,14 +99,22 @@ export function startYieldTimer(reason: SuspendedReason) {
9499 yieldReason = reason ;
95100}
96101
97- export function startUpdateTimerByLane ( lane : Lane , method : string ) : void {
102+ export function startUpdateTimerByLane (
103+ lane : Lane ,
104+ method : string ,
105+ fiber : Fiber | null ,
106+ ) : void {
98107 if ( ! enableProfilerTimer || ! enableComponentPerformanceTrack ) {
99108 return ;
100109 }
101110 if ( isSyncLane ( lane ) || isBlockingLane ( lane ) ) {
102111 if ( blockingUpdateTime < 0 ) {
103112 blockingUpdateTime = now ( ) ;
104113 blockingUpdateTask = createTask ( method ) ;
114+ blockingUpdateMethodName = method ;
115+ if ( __DEV__ && fiber != null ) {
116+ blockingUpdateComponentName = getComponentNameFromFiber ( fiber ) ;
117+ }
105118 if ( isAlreadyRendering ( ) ) {
106119 blockingUpdateType = SPAWNED_UPDATE ;
107120 }
@@ -125,6 +138,10 @@ export function startUpdateTimerByLane(lane: Lane, method: string): void {
125138 if ( transitionUpdateTime < 0 ) {
126139 transitionUpdateTime = now ( ) ;
127140 transitionUpdateTask = createTask ( method ) ;
141+ transitionUpdateMethodName = method ;
142+ if ( __DEV__ && fiber != null ) {
143+ transitionUpdateComponentName = getComponentNameFromFiber ( fiber ) ;
144+ }
128145 if ( transitionStartTime < 0 ) {
129146 const newEventTime = resolveEventTimeStamp ( ) ;
130147 const newEventType = resolveEventType ( ) ;
@@ -225,6 +242,8 @@ export function trackSuspendedTime(lanes: Lanes, renderEndTime: number) {
225242export function clearBlockingTimers ( ) : void {
226243 blockingUpdateTime = - 1.1 ;
227244 blockingUpdateType = 0 ;
245+ blockingUpdateMethodName = null ;
246+ blockingUpdateComponentName = null ;
228247 blockingSuspendedTime = - 1.1 ;
229248 blockingEventIsRepeat = true ;
230249}
0 commit comments