From cbb27279f67a6bb8337127ea1fcdd29dcc162966 Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Thu, 15 Dec 2022 17:22:37 +0100 Subject: [PATCH] Do not show a tooltip when the stack index of the hovered sample is null, instead of crashing Fixes #4363 --- src/components/shared/thread/ActivityGraphFills.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/shared/thread/ActivityGraphFills.js b/src/components/shared/thread/ActivityGraphFills.js index 6f0f785deb..82e52a2acc 100644 --- a/src/components/shared/thread/ActivityGraphFills.js +++ b/src/components/shared/thread/ActivityGraphFills.js @@ -405,7 +405,6 @@ export class ActivityFillGraphQuerier { ): HoveredPixelState | null { const { rangeFilteredThread: { samples, stackTable }, - greyCategoryIndex, } = this.renderedComponentSettings; const { devicePixelRatio } = window; const deviceX = Math.round(cssX * devicePixelRatio); @@ -437,10 +436,13 @@ export class ActivityFillGraphQuerier { // iteration - in the first iteration, yPercentage can be == categoryLowerEdge.) for (const { sample, contribution } of candidateSamples) { const stackIndex = samples.stack[sample]; - const sampleCategory = - stackIndex !== null - ? stackTable.category[stackIndex] - : greyCategoryIndex; + if (stackIndex === null) { + console.error( + `Stack index was null for sample index ${sample}, this shouldn't happen normally, please fix your source of data.` + ); + continue; + } + const sampleCategory = stackTable.category[stackIndex]; const upperEdgeOfThisSample = upperEdgeOfPreviousSample + contribution; // Checking the sample category here because there are samples with different // categories that has y percentage is lower than the upperEdgeOfThisSample.