From 2662a2d30285992a7cec245067de84a4b3dde3e9 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Tue, 19 Jul 2016 00:00:59 +0430 Subject: [PATCH 1/4] prevent spamming warnings related to performance measurement code --- src/renderers/shared/ReactDebugTool.js | 45 +++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/renderers/shared/ReactDebugTool.js b/src/renderers/shared/ReactDebugTool.js index 006f538f54bc..04dc337e22d2 100644 --- a/src/renderers/shared/ReactDebugTool.js +++ b/src/renderers/shared/ReactDebugTool.js @@ -52,6 +52,9 @@ var currentTimerStartTime = null; var currentTimerNestedFlushDuration = null; var currentTimerType = null; +var beginLifeCycleTimerHasWarned = false; +var endLifeCycleTimerHasWarned = false; + function clearHistory() { ReactComponentTreeDevtool.purgeUnmountedComponents(); ReactHostOperationHistoryDevtool.clearHistory(); @@ -109,15 +112,18 @@ function beginLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - warning( - !currentTimerType, - 'There is an internal error in the React performance measurement code. ' + - 'Did not expect %s timer to start while %s timer is still in ' + - 'progress for %s instance.', - timerType, - currentTimerType || 'no', - (debugID === currentTimerDebugID) ? 'the same' : 'another' - ); + if (!beginLifeCycleTimerHasWarned) { + warning( + !currentTimerType, + 'There is an internal error in the React performance measurement code. ' + + 'Did not expect %s timer to start while %s timer is still in ' + + 'progress for %s instance.', + timerType, + currentTimerType || 'no', + (debugID === currentTimerDebugID) ? 'the same' : 'another' + ); + beginLifeCycleTimerHasWarned = true; + } currentTimerStartTime = performanceNow(); currentTimerNestedFlushDuration = 0; currentTimerDebugID = debugID; @@ -128,15 +134,18 @@ function endLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - warning( - currentTimerType === timerType, - 'There is an internal error in the React performance measurement code. ' + - 'We did not expect %s timer to stop while %s timer is still in ' + - 'progress for %s instance. Please report this as a bug in React.', - timerType, - currentTimerType || 'no', - (debugID === currentTimerDebugID) ? 'the same' : 'another' - ); + if (!endLifeCycleTimerHasWarned) { + warning( + currentTimerType === timerType, + 'There is an internal error in the React performance measurement code. ' + + 'We did not expect %s timer to stop while %s timer is still in ' + + 'progress for %s instance. Please report this as a bug in React.', + timerType, + currentTimerType || 'no', + (debugID === currentTimerDebugID) ? 'the same' : 'another' + ); + endLifeCycleTimerHasWarned = true; + } if (isProfiling) { currentFlushMeasurements.push({ timerType, From 5bfb08bb0821314e020a618235fbdc9c82b15ec8 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Tue, 19 Jul 2016 01:17:33 +0430 Subject: [PATCH 2/4] minor changes in names and such --- src/renderers/shared/ReactDebugTool.js | 47 ++++++++++++-------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/renderers/shared/ReactDebugTool.js b/src/renderers/shared/ReactDebugTool.js index 04dc337e22d2..017d14d745da 100644 --- a/src/renderers/shared/ReactDebugTool.js +++ b/src/renderers/shared/ReactDebugTool.js @@ -52,8 +52,7 @@ var currentTimerStartTime = null; var currentTimerNestedFlushDuration = null; var currentTimerType = null; -var beginLifeCycleTimerHasWarned = false; -var endLifeCycleTimerHasWarned = false; +var lifeCycleTimerHasWarned = false; function clearHistory() { ReactComponentTreeDevtool.purgeUnmountedComponents(); @@ -112,18 +111,16 @@ function beginLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - if (!beginLifeCycleTimerHasWarned) { - warning( - !currentTimerType, - 'There is an internal error in the React performance measurement code. ' + - 'Did not expect %s timer to start while %s timer is still in ' + - 'progress for %s instance.', - timerType, - currentTimerType || 'no', - (debugID === currentTimerDebugID) ? 'the same' : 'another' - ); - beginLifeCycleTimerHasWarned = true; - } + warning( + !currentTimerType || lifeCycleTimerHasWarned, + 'There is an internal error in the React performance measurement code. ' + + 'Did not expect %s timer to start while %s timer is still in ' + + 'progress for %s instance.', + timerType, + currentTimerType || 'no', + (debugID === currentTimerDebugID) ? 'the same' : 'another' + ); + lifeCycleTimerHasWarned = true; currentTimerStartTime = performanceNow(); currentTimerNestedFlushDuration = 0; currentTimerDebugID = debugID; @@ -134,18 +131,16 @@ function endLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - if (!endLifeCycleTimerHasWarned) { - warning( - currentTimerType === timerType, - 'There is an internal error in the React performance measurement code. ' + - 'We did not expect %s timer to stop while %s timer is still in ' + - 'progress for %s instance. Please report this as a bug in React.', - timerType, - currentTimerType || 'no', - (debugID === currentTimerDebugID) ? 'the same' : 'another' - ); - endLifeCycleTimerHasWarned = true; - } + warning( + currentTimerType === timerType || lifeCycleTimerHasWarned, + 'There is an internal error in the React performance measurement code. ' + + 'We did not expect %s timer to stop while %s timer is still in ' + + 'progress for %s instance. Please report this as a bug in React.', + timerType, + currentTimerType || 'no', + (debugID === currentTimerDebugID) ? 'the same' : 'another' + ); + lifeCycleTimerHasWarned = true; if (isProfiling) { currentFlushMeasurements.push({ timerType, From 2d51f65b5aea626e7000236d4fc81ea7b80eeda3 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Tue, 19 Jul 2016 03:30:27 +0430 Subject: [PATCH 3/4] - --- src/renderers/shared/ReactDebugTool.js | 44 ++++++++++++++------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/renderers/shared/ReactDebugTool.js b/src/renderers/shared/ReactDebugTool.js index 017d14d745da..2cce31842046 100644 --- a/src/renderers/shared/ReactDebugTool.js +++ b/src/renderers/shared/ReactDebugTool.js @@ -111,16 +111,18 @@ function beginLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - warning( - !currentTimerType || lifeCycleTimerHasWarned, - 'There is an internal error in the React performance measurement code. ' + - 'Did not expect %s timer to start while %s timer is still in ' + - 'progress for %s instance.', - timerType, - currentTimerType || 'no', - (debugID === currentTimerDebugID) ? 'the same' : 'another' - ); - lifeCycleTimerHasWarned = true; + if (!lifeCycleTimerHasWarned) { + warning( + !currentTimerType, + 'There is an internal error in the React performance measurement code. ' + + 'Did not expect %s timer to start while %s timer is still in ' + + 'progress for %s instance.', + timerType, + currentTimerType || 'no', + (debugID === currentTimerDebugID) ? 'the same' : 'another' + ); + lifeCycleTimerHasWarned = true; + } currentTimerStartTime = performanceNow(); currentTimerNestedFlushDuration = 0; currentTimerDebugID = debugID; @@ -131,16 +133,18 @@ function endLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - warning( - currentTimerType === timerType || lifeCycleTimerHasWarned, - 'There is an internal error in the React performance measurement code. ' + - 'We did not expect %s timer to stop while %s timer is still in ' + - 'progress for %s instance. Please report this as a bug in React.', - timerType, - currentTimerType || 'no', - (debugID === currentTimerDebugID) ? 'the same' : 'another' - ); - lifeCycleTimerHasWarned = true; + if (!lifeCycleTimerHasWarned) { + warning( + currentTimerType === timerType, + 'There is an internal error in the React performance measurement code. ' + + 'We did not expect %s timer to stop while %s timer is still in ' + + 'progress for %s instance. Please report this as a bug in React.', + timerType, + currentTimerType || 'no', + (debugID === currentTimerDebugID) ? 'the same' : 'another' + ); + lifeCycleTimerHasWarned = true; + } if (isProfiling) { currentFlushMeasurements.push({ timerType, From c5d98dd0923079413e13227c1178d6d5bd62854e Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Tue, 19 Jul 2016 04:19:49 +0430 Subject: [PATCH 4/4] - --- src/renderers/shared/ReactDebugTool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderers/shared/ReactDebugTool.js b/src/renderers/shared/ReactDebugTool.js index 2cce31842046..e8c5d2f16d65 100644 --- a/src/renderers/shared/ReactDebugTool.js +++ b/src/renderers/shared/ReactDebugTool.js @@ -111,9 +111,9 @@ function beginLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - if (!lifeCycleTimerHasWarned) { + if (currentTimerType && !lifeCycleTimerHasWarned) { warning( - !currentTimerType, + false, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', @@ -133,9 +133,9 @@ function endLifeCycleTimer(debugID, timerType) { if (currentFlushNesting === 0) { return; } - if (!lifeCycleTimerHasWarned) { + if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) { warning( - currentTimerType === timerType, + false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.',