Skip to content

Conversation

@canova
Copy link
Member

@canova canova commented Nov 27, 2025

Fixes #5689.

The root cause of this issue was that expanded call node paths from the transformed tree remained in state when navigating back via the browser. These paths were invalid in the untransformed tree, and they were causing errors when the transform was re-applied.

The fix adds a lastSeenTransformCount field to ThreadViewOptions to track the number of transforms applied to each thread. When UPDATE_URL_STATE fires via browser back button, we compare the new transform count with the old count. If we notice that a transform was removed, we reset all call node paths to ensure they're always valid for the current tree structure.

This matches the existing behavior of POP_TRANSFORMS_FROM_STACK (removing the transform from the filter navigator bar), which already resets paths.

Deploy preview: before / after

@canova canova requested a review from mstange November 27, 2025 13:40
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.63%. Comparing base (48a9e86) to head (27f4f53).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5701   +/-   ##
=======================================
  Coverage   85.62%   85.63%           
=======================================
  Files         312      312           
  Lines       30880    30892   +12     
  Branches     8512     8420   -92     
=======================================
+ Hits        26441    26453   +12     
  Misses       4009     4009           
  Partials      430      430           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@mstange mstange left a comment

Choose a reason for hiding this comment

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

Looks good, even if it feels a bit brittle.

I wonder if we have other state outside the UrlState which is affected by actions that also affect the UrlState, and which needs to be kept "in sync" with those changes. If that were the case, we might need to handle UPDATE_URL_STATE in more places to avoid similar bugs.

Ideally the answer would be "no, our actions affect either only state in the UrlState or only state outside the UrlState". So in the long run we should move these thread view options into the UrlState.

@canova
Copy link
Member Author

canova commented Dec 2, 2025

I wonder if we have other state outside the UrlState which is affected by actions that also affect the UrlState, and which needs to be kept "in sync" with those changes. If that were the case, we might need to handle UPDATE_URL_STATE in more places to avoid similar bugs.

Ideally the answer would be "no, our actions affect either only state in the UrlState or only state outside the UrlState". So in the long run we should move these thread view options into the UrlState.

Yeah, I couldn't find more like that, but it's possible. We should still have a proper audit and move them if needed.

… it removes transforms

When using the browser back button after applying a focus-category
transform, re-applying the transform would fail with the error:
"We couldn't find a node with prefix -1 and func X, this shouldn't happen."

The root cause was that expanded call node paths from the transformed tree
remained in state when navigating back via the browser. These paths were
invalid in the untransformed tree, and they were causing errors when the
transform was re-applied.

The fix adds a lastSeenTransformCount field to ThreadViewOptions to
track the number of transforms applied to each thread. When
UPDATE_URL_STATE fires via browser back button, we compare the new
transform count with the old count. If we notice that a transform was
removed, we reset all call node paths to ensure they're always valid
for the current tree structure.

This matches the existing behavior of POP_TRANSFORMS_FROM_STACK
(removing the transform from the filter navigator bar), which already
resets paths correctly.
@canova canova force-pushed the focus-category-nav-bug branch from c375f0f to 27f4f53 Compare December 2, 2025 16:24
@canova canova merged commit 90fe67e into firefox-devtools:main Dec 3, 2025
21 checks passed
valenting pushed a commit to valenting/profiler that referenced this pull request Dec 3, 2025
… it removes transforms (firefox-devtools#5701)

Fixes firefox-devtools#5689.

The root cause of this issue was that expanded call node paths from the
transformed tree remained in state when navigating back via the browser.
These paths were invalid in the untransformed tree, and they were
causing errors when the transform was re-applied.

The fix adds a lastSeenTransformCount field to ThreadViewOptions to
track the number of transforms applied to each thread. When
UPDATE_URL_STATE fires via browser back button, we compare the new
transform count with the old count. If we notice that a transform was
removed, we reset all call node paths to ensure they're always valid for
the current tree structure.

This matches the existing behavior of POP_TRANSFORMS_FROM_STACK
(removing the transform from the filter navigator bar), which already
resets paths.
@canova canova mentioned this pull request Dec 18, 2025
canova added a commit that referenced this pull request Dec 18, 2025
Changes:

[Markus Stange] Use a longer test timeout when debugging with VS code.
(#5679)
[Markus Stange] Move Jest config from package.json to jest.config.js
(#5680)
[Markus Stange] Make binary profile format parsing use Uint8Array
instead of ArrayBuffer (#5678)
[Markus Stange] Use workbox-cli to generate the service worker (#5681)
[Nazım Can Altınova] Migrate from Appveyor to GitHub Actions Windows
runners (#5660)
[Nazım Can Altınova] Remove some unused dependencies (#5696)
[Nazım Can Altınova] Update the document links and sections (#5705)
[Nazım Can Altınova] Clear selected and expanded call node paths on
browser back button if it removes transforms (#5701)
[Nazım Can Altınova] Properly type the Map and Set objects (#5623)
[Valentin Gosu] Add priorityHeader field to network requests (#5707)
[Nazım Can Altınova] Redirect unpublished url loads to the homepage
similar to from-file (#5712)
[Florian Quèze/Nazım Can Altınova] Add an importer for the text format
taken as input by flamegraph.pl. (#5359)
[Florian Quèze] Improve the import of profiles generated from clang
-ftime-trace=file.json (#5714)
[Markus Stange] Move React stuff out of marker schema logic module.
(#5720)

And thanks to our localizers:

en-CA: chutten
en-CA: Paul
es-CL: ravmn
fr: Théo Chevalier
fur: Fabio Tomat
ru: berry
tr: Selim Şumlu
zh-CN: Olvcpr423
zh-CN: wxie
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.

"Focus category" transform fails in this profile

2 participants