Skip to content

feat(tracing): allow configuring the screenshots size - #42283

Merged
Yury Semikhatsky (yury-s) merged 3 commits into
microsoft:mainfrom
yury-s:fix-42274
Aug 18, 2026
Merged

feat(tracing): allow configuring the screenshots size#42283
Yury Semikhatsky (yury-s) merged 3 commits into
microsoft:mainfrom
yury-s:fix-42274

Conversation

@yury-s

@yury-s Yury Semikhatsky (yury-s) commented Aug 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Let the tracing capture be sized via tracing.start({ screenshots: { size } }), and the same under the trace test option. Tracing shares one screencast per page with screencast.start() and video recording, but always requested the default viewport-fit size, capping what the others could get with no way to opt out. The trace viewer renders the timeline preview at a fixed size, so this only affects those other consumers.
  • The shared capture is sized by whoever attached first, so screencast.start({ size }) encoded the video at the requested size while receiving smaller frames — ffmpeg pads rather than scales, leaving gray borders. Encode into the size the capture actually runs at instead, so size is plainly ignored rather than half-applied.
  • Document that tracing captures screenshots through the same screencast.

Fixes #42274

All screencast clients of a page share a single browser capture, sized
by whichever client attached first. Tracing attaches per page without
requesting a size, so with tracing on the capture stays at the default
viewport-fit while a later screencast.start({ size }) still encoded the
video at the requested size. The ffmpeg filter pads rather than scales,
so the smaller frames landed top-left with gray filling the rest.

Encode into the size the capture actually runs at instead, so the size
option is plainly ignored rather than half-applied. Document that
tracing captures screenshots through the same screencast.

Fixes: microsoft#42274
Comment thread packages/playwright-core/src/server/videoRecorder.ts
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 The one failure is a pre-existing flake — this PR is clear

Hi, I'm the Playwright bot and I took a first look at the CI failures.

The only non-flaky failure, reporter-html.spec.ts:3464 › speedboard › clicking on label should not exit speedboard on macos-latest-node22, is an established flake unrelated to this change. This PR only touches screencast video encoding size, which the HTML reporter's speedboard doesn't exercise.

Details

Pre-existing flake / infra

The other 25 entries in the report are flaky (passed on retry), so there's nothing else to triage. Notably the screencast-adjacent ones — video.spec.ts:736 › screencast › should work with video+trace and video.spec.ts:699 › should capture full viewport on hidpi — only flaked and recovered on retry, so they don't indicate a regression from this change.

I'm a first pass, not the final word — but I couldn't find any failure that this PR is responsible for.

Triaged by the Playwright bot - agent run

Tracing captures screenshots through the page screencast, which is shared
with screencast.start() and video recording and sized by whoever started
it first. Tracing always requested the default viewport-fit size, capping
what the other consumers could get with no way to opt out.

Let screenshots take an object with a size, so a test that needs a larger
capture can raise it: tracing.start({ screenshots: { size } }). The trace
viewer renders the timeline preview at a fixed size, so this only affects
what the other consumers of the capture receive.

Also skip the "empty video" test under trace=on: with tracing already
capturing, the recorder receives a frame and the video is not empty. It
only passed because the test happened to run before a frame arrived.
@yury-s Yury Semikhatsky (yury-s) changed the title fix(screencast): encode video at the size of the running capture fix(screencast): do not pad the video when tracing sizes the capture Aug 17, 2026
@yury-s Yury Semikhatsky (yury-s) changed the title fix(screencast): do not pad the video when tracing sizes the capture feat(tracing): allow configuring the screenshots size Aug 17, 2026
Comment thread docs/src/api/class-tracing.md Outdated
Comment thread docs/src/api/class-tracing.md
Review feedback: name the object-taking option `screencast` to match the
protocol and `screencast.start()`, leave `screenshots` as the plain boolean
it has always been, and accept `quality` alongside `size` so tracing can
configure the shared capture the same way `screencast.start()` does.

`screencast` takes precedence when both are given.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [firefox] › mcp/cli-core.spec.ts:140 › uncheck @mcp-windows-latest-firefox

8100 passed, 1311 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 Every failure is a pre-existing flake — this PR is clear

Hi, I'm the Playwright bot and I took a look at the CI failures.

Across the reports there are three real failures — mcp/cli-core.spec.ts:140 › uncheck, reporter-html.spec.ts:3464 › speedboard › clicking on label should not exit speedboard, and mcp/http.spec.ts:105 › http transport browser lifecycle (isolated). All three are established flakes with a failure history on SHAs this PR can't be responsible for, and none of them exercise the tracing/screencast/video-size code this PR changes.

Details

This PR only touches trace/video screencast sizing (videoRecorder.ts, tracing.ts, protocol/validator, and the screencast/tracing docs + tests). None of the failing tests touch that code path.

Pre-existing flake / infra

Note: the newest tests 1 and one of the MCP reports come from cancelled workflow runs, so their pass/fail counts are partial — but that doesn't change the verdict on the individual failures above.

I'm a first pass, not the final word — but I couldn't find any failure this PR is responsible for.

Triaged by the Playwright bot - agent run

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

18 flaky ⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:664 › screencast › should capture full viewport `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/global-fetch.spec.ts:293 › should return security details from response `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/har.spec.ts:639 › should have security details `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-event-request.spec.ts:181 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/global-fetch.spec.ts:293 › should return security details from response `@webkit-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/har.spec.ts:639 › should have security details `@webkit-ubuntu-22.04-node20`

51172 passed, 1227 skipped


Merge workflow run.

@yury-s
Yury Semikhatsky (yury-s) merged commit b856094 into microsoft:main Aug 18, 2026
44 of 45 checks passed
@yury-s
Yury Semikhatsky (yury-s) deleted the fix-42274 branch August 18, 2026 15:33
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.

[Bug]: tracing clamps page.screencast capture size, padding the video with grey

2 participants