Repository navigation
perf(browser): map only first frame for trace locations - #11613
Merged
sheremet-va merged 3 commits intoOct 16, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hi-ogawa
commented
Oct 16, 2026
| if (!position) { | ||
| return stack | ||
| } | ||
| function mapStackFrame( |
Collaborator
Author
There was a problem hiding this comment.
This just extracted a loop. See with "hide whitespace" https://github.com/vitest-dev/vitest/pull/11613/changes?w=1
hi-ogawa
marked this pull request as ready for review
October 16, 2026 05:51
sheremet-va
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Trace view records a timeline of steps, each with its timing and source location, and takes a DOM snapshot at every step. On real app pages the snapshot is usually the larger cost. But #10310 and #11592 move toward keeping the timeline while taking snapshots only on failure, so the timeline can be shown for every failure, including in terminal output. Then the cost every passing test pays is collecting the timeline itself, and that should be cheap.
Fix
Most of that cost was resolving each step's location. The server source-mapped every frame of the step's stack while the browser waited, although only the first usable frame is used, so the cost grew with stack depth (firefox stacks are about 40 frames per entry). This PR changes so it stops at the first frame that resolves and isn't filtered. Playwright
browser.traceresolves action locations the same way, so it gets the same change.Example
One test with 200 passing
expect.element(...).toBeVisible()calls withtraceView: true(median of 3 runs). The page is a single button, so the snapshot cost is small and the numbers mostly show the timeline collection:Per
expect.element(two trace entries, start and end), dividing the totals above by 200, with the stack parsing part measured separately on the server:The rest of the remaining trace view cost per assertion is the DOM snapshot and the two awaited round trips to the server.
📄 benchmark