Skip to content

fix: make screenshot capture safe and bounded - #37

Open
okhsunrog wants to merge 1 commit into
hypothesi:mainfrom
okhsunrog:agent/safe-viewport-screenshot-fallback
Open

fix: make screenshot capture safe and bounded#37
okhsunrog wants to merge 1 commit into
hypothesi:mainfrom
okhsunrog:agent/safe-viewport-screenshot-fallback

Conversation

@okhsunrog

Copy link
Copy Markdown

What changed

  • implement native Linux viewport screenshots with WebKitGTK's visible-region snapshot API
  • bound the html2canvas fallback to the visible viewport instead of allocating a full-document canvas
  • require explicit allowScreenCapture: true before invoking the interactive Screen Capture API fallback
  • add unit coverage and an E2E stress case with 10,000 offscreen DOM rows

Why

On Linux, native capture was deliberately disabled by an outdated glib-version constraint. The fallback rendered the entire document.documentElement, so long pages could exceed the bridge's JavaScript timeout. After that failure the server automatically called getDisplayMedia(), unexpectedly opening a KDE screen-sharing permission prompt.

Tauri 2.9 and WebKitGTK now use the same glib 0.18 dependency line, so native visible-region capture can be enabled without duplicate GTK stacks.

Validation

  • npm run build
  • npm test (152 passed, 1 platform skip)
  • npm run eslint
  • cargo fmt --check for plugin and test app
  • cargo clippy --manifest-path packages/tauri-plugin-mcp-bridge/Cargo.toml --all-targets -- -D warnings
  • manual Linux stress run: 10,091 DOM elements, 321,044 px document height, native PNG viewport captured in 89 ms

@okhsunrog
okhsunrog marked this pull request as ready for review July 20, 2026 11:42
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