Skip to content

feat(browser): the owner sees the page as sharp as their screen, and quicker in their hands - #167

Merged
httpsphl merged 1 commit into
mainfrom
feat/browser-sharp
Oct 4, 2026
Merged

httpsphl merged 1 commit into
mainfrom
feat/browser-sharp

Conversation

@httpsphl

@httpsphl httpsphl commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Why

The owner found the bot's live page blurry when full screen, and slow. Both came from saving resources:

  • The page was drawn at 1 pixel per page pixel. On a scaled screen (125%, 150%) or a zoomed app, the picture was stretched.
  • Frames were capped at about 15 per second.

What

  • Sharp page. browser.resize takes an optional scale: the app's devicePixelRatio × 100. The page is drawn that sharp with deviceScaleFactor, up to 2×. Its size in CSS pixels does not change.
  • How the frames are made.
    • The screencast keeps the page's own pixels whatever the scale. I checked this with the real Edge and recorded it in spec 19.
    • So on a sharper screen, the screencast runs at 64 px and only says the page changed. The frame sent to the app is a Page.captureScreenshot (JPEG, quality 60, optimizeForSpeed).
    • The screencast frame is acknowledged only after that screenshot, so screenshots never pile up.
    • The picture kept while the browser rests is sharp too.
  • Frame rate. About 30 frames per second while the owner holds the browser, about 15 while they only watch the bot.
  • The bot's screenshots (browser_screenshot) stay the size of the page, so they cost the bot the same tokens. They are clipped where the page is scrolled to (Page.getLayoutMetrics → cssVisualViewport.pageX/pageY) and scaled back down (clip.scale).
  • Spec 19, 21.3, 21.7 and 21.8 are updated.

Checks

  • cargo fmt, clippy -D warnings, cargo test --workspace and pnpm check pass.
  • New real-Edge test in browser_panel.rs:
    • at scale 200 the page reports devicePixelRatio 2;
    • its frame is 2000×1400 for a 1000×700 page;
    • the bot's screenshot of a page scrolled to #end is 1000×700.
  • I looked at that screenshot once by hand: it showed the black bottom of the test page, so the clip follows the scroll.

Manual check on the real app

  1. On a scaled screen, open a bot's browser full screen. The text should be sharp.
  2. Take control and scroll. It should feel smoother.
  3. Ask the bot for a screenshot. It should still be page-sized.

…quicker in their hands

The bot's page was drawn at one pixel per page pixel and sent at ~15
frames a second, so on a scaled screen its text was blurry and scrolling
felt slow. The app now sends its devicePixelRatio with browser.resize,
and the page is drawn that sharp (deviceScaleFactor, up to 2x) for the
owner. The screencast keeps the page's own pixels whatever the scale
(checked with the real Edge, spec 19), so on a sharper screen its small
frames only say the page changed and the frame sent is a screenshot,
confirmed after it so they never pile up. Frames come ~30 a second while
the owner has the browser in their hands, ~15 while they watch the bot.
The bot's own screenshots stay the size of the page: clipped where the
page is scrolled to and scaled back down, so they cost the bot the same.
@httpsphl
httpsphl enabled auto-merge October 4, 2026 20:50
@httpsphl
httpsphl merged commit a3c53fe into main Oct 4, 2026
4 checks passed
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.

1 participant