Skip to content

Translate URL track-index state through profile sanitization#6000

Open
fatadel wants to merge 2 commits into
firefox-devtools:mainfrom
fatadel:issue-2947
Open

Translate URL track-index state through profile sanitization#6000
fatadel wants to merge 2 commits into
firefox-devtools:mainfrom
fatadel:issue-2947

Conversation

@fatadel
Copy link
Copy Markdown
Contributor

@fatadel fatadel commented May 6, 2026

Previously, hidden non-thread tracks (screenshots, network, IPC) reappeared after publishing a sanitized profile when sanitization also removed a thread: the URL state's hidden-track sets and track-order were reset whenever threads were re-indexed, even though the non-thread tracks still existed in the sanitized profile. When a tab filter was active, the bug also affected tracks in surviving processes because the tabToThreadIndexesMap used to filter the new global track list still referenced pre-sanitization thread indexes.

attemptToPublish now builds an old-to-new TrackIndex map by matching tracks on stable identity (pid, screenshot id, threadIndex, counterIndex, visual-progress singleton) and translates hiddenGlobalTracks, globalTrackOrder, hiddenLocalTracksByPid, and localTrackOrderByPid through it on SANITIZED_PROFILE_PUBLISHED. The tabToThreadIndexesMap is rebuilt from the sanitized profile's threads and pages so its ThreadIndex values are valid in the new track-index space; the innerWindowID → tabID computation is extracted into a shared computeInnerWindowIDToTabMap helper that the existing getInnerWindowIDToTabMap selector also uses. Marker tracks key on a string-table index that sanitization reshuffles, so they are not matched.

Fixes #2947.
The work is built upon the draft PR by @julienw.

STR are available in the original issues, here is the deploy preview profile.

@fatadel fatadel requested review from canova and mstange May 6, 2026 16:17
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 86.15385% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.80%. Comparing base (41473d3) to head (d935cc7).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/actions/publish.ts 73.07% 14 Missing ⚠️
src/profile-logic/tracks.ts 96.66% 2 Missing ⚠️
src/profile-logic/profile-data.ts 85.71% 1 Missing ⚠️
src/reducers/url-state.ts 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6000      +/-   ##
==========================================
+ Coverage   83.77%   83.80%   +0.02%     
==========================================
  Files         329      329              
  Lines       34423    34540     +117     
  Branches     9627     9649      +22     
==========================================
+ Hits        28839    28946     +107     
- Misses       5155     5165      +10     
  Partials      429      429              

☔ 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
Copy Markdown
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 it's working mostly well! I found one more case where publishing makes some tracks reappear again. For example use this deploy preview:

https://deploy-preview-6000--perf-html.netlify.app/public/br9dcd5c81kz02ttzx4czvv9qj77ytc9709x02g/marker-chart/?globalTrackOrder=30w2&hiddenGlobalTracks=0&hiddenLocalTracksByPid=73972-0w5~64964-01~73997-0&localTrackOrderByPid=64964-01&markerSearch=scree&tabID=20&thread=k&v=16

Then click "re-upload", uncheck "Include hidden threads" and then upload it. Notice that firefox.com content process' network track appears again.

Note that I selected profiler.firefox.com origin in the top left corner in the tab selector. I think this is happening because the indexes for the tab selector are not translated (probably tabToThreadIndexesMap).

fatadel added 2 commits May 18, 2026 11:25
Previously, hidden non-thread tracks (screenshots, network, IPC)
reappeared after publishing a sanitized profile when sanitization also
removed a thread: the URL state's hidden-track sets and track-order were
reset whenever threads were re-indexed, even though the non-thread
tracks still existed in the sanitized profile.

attemptToPublish now builds an old to new TrackIndex map by matching
tracks on stable identity (pid, screenshot id, threadIndex,
counterIndex, visual-progress singleton) and translates
hiddenGlobalTracks, globalTrackOrder, hiddenLocalTracksByPid, and
localTrackOrderByPid through it on SANITIZED_PROFILE_PUBLISHED. Marker
tracks key on a string-table index that sanitization reshuffles, so
they are not matched.

Fixes firefox-devtools#2947
When a tab filter was active during publishing, a hidden non-thread
track (e.g. a screenshot or a per-process network track) could
reappear after sanitization. attemptToPublish was remapping the URL
state's hidden-track set against a global track list filtered using
the prePublishedState's tabToThreadIndexesMap; that map's
Set<ThreadIndex> values referred to old thread indexes, so when
sanitization shifted surviving threads down by removing an earlier
thread, filterGlobalTracksByTab picked the wrong threads and the
hidden track ended up at a stale TrackIndex.

attemptToPublish now builds the map from the sanitized profile's
threads and pages so its ThreadIndex values are valid in the new
track-index space. The innerWindowID to tabID computation is
extracted into a shared computeInnerWindowIDToTabMap helper that the
getInnerWindowIDToTabMap selector also uses.
@fatadel
Copy link
Copy Markdown
Contributor Author

fatadel commented May 18, 2026

Thanks for the PR, it looks like it's working mostly well! I found one more case where publishing makes some tracks reappear again. For example use this deploy preview:

https://deploy-preview-6000--perf-html.netlify.app/public/br9dcd5c81kz02ttzx4czvv9qj77ytc9709x02g/marker-chart/?globalTrackOrder=30w2&hiddenGlobalTracks=0&hiddenLocalTracksByPid=73972-0w5~64964-01~73997-0&localTrackOrderByPid=64964-01&markerSearch=scree&tabID=20&thread=k&v=16

Then click "re-upload", uncheck "Include hidden threads" and then upload it. Notice that firefox.com content process' network track appears again.

Note that I selected profiler.firefox.com origin in the top left corner in the tab selector. I think this is happening because the indexes for the tab selector are not translated (probably tabToThreadIndexesMap).

Thanks! Fixed now.

@fatadel fatadel requested a review from canova May 18, 2026 12:13
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.

Some hidden tracks reappear after sanitization

2 participants