Skip to content

fix(dashboard): handle null viewport in annotate screenshot#40569

Merged
yury-s merged 4 commits intomicrosoft:mainfrom
yury-s:fix-40565
May 1, 2026
Merged

fix(dashboard): handle null viewport in annotate screenshot#40569
yury-s merged 4 commits intomicrosoft:mainfrom
yury-s:fix-40565

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented May 1, 2026

Summary

  • Headed playwright-cli open --headed launches the browser with viewport: null, which makes page.viewportSize() return null. The dashboard's annotate screenshot then forwarded viewportWidth/Height of 0, and buildAnnotatedImage silently dropped the annotated PNG.
  • Fall back to window.innerWidth/innerHeight via page.evaluate() when viewportSize() is null.

Fixes #40565

yury-s added 3 commits May 1, 2026 11:25
Pages whose context was created with viewport: null (e.g. headed
playwright-cli open --headed) report viewportSize() as null, which made
the annotation modal receive viewportWidth/Height of 0 and silently drop
the annotated image. Fall back to window.innerWidth/innerHeight.

Fixes: microsoft#40565
documentElement.clientWidth/Height matches the layout viewport that
page.screenshot() captures, while window.innerWidth includes scrollbar
gutter and would skew annotation scaling.
@github-actions

This comment has been minimized.

On Firefox, document.documentElement.clientWidth/clientHeight reflect
the rendered content size (e.g. ~8px tall for an empty page), not the
live window size. That caused the annotate modal to receive a near-zero
viewportHeight, which short-circuited mouse handling so no annotation
could be drawn. window.innerWidth/innerHeight match the screenshot
dimensions on both engines.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Test results for "MCP"

1 failed
❌ [chrome] › mcp/autowait.spec.ts:19 › racy navigation destroys context @mcp-windows-latest-chrome

6875 passed, 1015 skipped


Merge workflow run.

@yury-s yury-s merged commit 9ec5d7f into microsoft:main May 1, 2026
16 of 17 checks passed
@yury-s yury-s deleted the fix-40565 branch May 1, 2026 21:02
@XFaramirX
Copy link
Copy Markdown

Thank you lads ! This feature is crazy thanks

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]: Playwright CLI cannot annotate on screen when launched with --headed

3 participants