Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move stackIndex existence check at if condition in SampleTooltipContents #5353

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

theoniko
Copy link
Contributor

@theoniko theoniko commented Feb 6, 2025

Solves #5290

Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! It looks like the logic needs to be changed, see my comment below.

Also see my comment #5290 (comment) to how to reproduce it locally, so you can test it.

@@ -136,8 +136,9 @@ export class SampleTooltipContents extends React.PureComponent<Props> {
const sampleTime = samples.time[sampleIndex];
const stackIndex = samples.stack[sampleIndex];
const hasSamples = samples.length > 0 && stackTable.length > 1;
const hasValidStackIndex = (stackIndex !== null) || (stackIndex !== undefined);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| needs to be && here. We need to make sure that stack index is not null AND not undefined. (also there is an extra space on the right side of the or operator).

@mstange
Copy link
Contributor

mstange commented Feb 6, 2025

I'm not sure about this patch. If sampleIndex can be an invalid index, it means there's a bug somewhere else.

@julienw
Copy link
Contributor

julienw commented Feb 7, 2025

I'm not sure about this patch. If sampleIndex can be an invalid index, it means there's a bug somewhere else.

yeah, null could happen when it's filtered out (this is what @canova hits with this STR), but undefined as in the original bug, i'm not so sure. Even null IMO shouldn't happen because we should not show the tooltip at all and therefore not render the component in the first place... therefore the condition might need to be in the SampleGraph itself for Nazim's case.

@canova
Copy link
Member

canova commented Feb 7, 2025

Yeah, for the SampleGraph case, we were passing the filteredThread initially directly because they get removed once you drop samples etc. That time it made sense to just get the filtered thread and use that since we don't need the unfiltered one / range filtered one.

There is this case now:

  1. You hover over the sample in the sample graph and show the tooltip.
  2. You don't move the mouse so the hovered sample doesn't get updated.
  3. You drop the sample.

So in this case we still have the same hoveredSample in the sample graph. And we only check for the sample itself being null or not in the SampleGraph case. We might want to pass only the rangeFilteredThread to the SampleTooltipContents, but i don't think it's a great solution either as we will still continue to see the removed sample tooltip when we drop samples.
So SampleGraph solution might be to check the stack itself and add the tooltip only if it's not null during its render.

Even null IMO shouldn't happen because we should not show the tooltip at all and therefore not render the component in the first place...

We actually show the tooltip in case the sample is not there, but this case is slightly different. For example when you profile without the stack sampling, but you still capture the CPU usage, we will not sample; but every sample will only contain the CPU usage values. You can try this case locally by checking the No Periodic Sampling option.


For the undefined case, it's really weird and probably coming from somewhere else. Not so sure where it comes from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants