Skip to content

fix(flamegraph): Fix continuous flamegraph non call order#104582

Merged
Zylphrex merged 2 commits intomasterfrom
txiao/fix/fix-continuous-flamegraph-non-call-order
Dec 9, 2025
Merged

fix(flamegraph): Fix continuous flamegraph non call order#104582
Zylphrex merged 2 commits intomasterfrom
txiao/fix/fix-continuous-flamegraph-non-call-order

Conversation

@Zylphrex
Copy link
Copy Markdown
Member

@Zylphrex Zylphrex commented Dec 9, 2025

When using a non call order mode (e.g. alphabetical or left heavy), it's possible the start of the profile is empty. When this happens, the offset can push the actual flamegraph off screen. So don't use an offset in these sortings.

@Zylphrex Zylphrex requested a review from a team as a code owner December 9, 2025 17:00
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 9, 2025
Comment on lines +607 to 617
configSpaceTransform:
// For continuous flamegraphs, we only want to adjust when the sorting is
// call order. This is because we need to offset it to align with the
// specified start/end but when sorting by left heavy or alphabetical,
// we always align it at 0.
sorting === 'call order'
? getProfileOffset(profile, configSpaceQueryParam[0])
: undefined,
},
});

This comment was marked as outdated.

// we always align it at 0.
sorting === 'call order'
? getProfileOffset(profile, configSpaceQueryParam[0])
: undefined,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Inconsistent offset logic between flamegraph and related chart views

The fix conditionally applies configSpaceTransform only when sorting === 'call order' for the flamegraphView, but the related views (uiFramesView, batteryChartView, cpuChartView, memoryChartView) still unconditionally apply the offset via getProfileOffset. When using alphabetical or left heavy sorting, the flamegraph won't have an offset but the charts will, causing visual misalignment between these synchronized views that share the same X-axis.

Additional Locations (2)

Fix in Cursor Fix in Web

@Zylphrex Zylphrex enabled auto-merge (squash) December 9, 2025 20:40
Comment on lines +607 to +614
configSpaceTransform:
// For continuous flamegraphs, we only want to adjust when the sorting is
// call order. This is because we need to offset it to align with the
// specified start/end but when sorting by left heavy or alphabetical,
// we always align it at 0.
sorting === 'call order'
? getProfileOffset(profile, configSpaceQueryParam[0])
: undefined,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Overlay views (uiFramesView, batteryChartView, cpuChartView, memoryChartView) unconditionally apply getProfileOffset() causing misalignment when flamegraphView uses undefined for configSpaceTransform in non-'call order' sorting.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

When the flamegraph is sorted by a non-'call order' mode, the main flamegraphView is configured with configSpaceTransform: undefined (which becomes an identity matrix). However, the dependent overlay views (uiFramesView, batteryChartView, cpuChartView, memoryChartView) unconditionally apply getProfileOffset() to their configSpaceTransform. This discrepancy in transformation matrices for views sharing the same canvas but having synchronized configView rects causes them to render at different screen positions, leading to visual misalignment between the flamegraph and its overlaid metrics.

💡 Suggested Fix

Conditionally apply getProfileOffset() to configSpaceTransform for uiFramesView, batteryChartView, cpuChartView, and memoryChartView using the pattern sorting === 'call order' ? getProfileOffset(...) : undefined.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/components/profiling/flamegraph/continuousFlamegraph.tsx#L607-L614

Potential issue: When the flamegraph is sorted by a non-'call order' mode, the main
`flamegraphView` is configured with `configSpaceTransform: undefined` (which becomes an
identity matrix). However, the dependent overlay views (`uiFramesView`,
`batteryChartView`, `cpuChartView`, `memoryChartView`) unconditionally apply
`getProfileOffset()` to their `configSpaceTransform`. This discrepancy in transformation
matrices for views sharing the same canvas but having synchronized `configView` rects
causes them to render at different screen positions, leading to visual misalignment
between the flamegraph and its overlaid metrics.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 6607484

@Zylphrex Zylphrex merged commit f854d1f into master Dec 9, 2025
48 checks passed
@Zylphrex Zylphrex deleted the txiao/fix/fix-continuous-flamegraph-non-call-order branch December 9, 2025 20:57
@github-actions github-actions bot locked and limited conversation to collaborators Dec 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants