Skip to content

fix(gui-extensions): wait for painted frame before screenshot capture - #52704

Closed
thevladimirzh wants to merge 1 commit into
anomalyco:devfrom
thevladimirzh:browser/painted-before-screenshot
Closed

thevladimirzh wants to merge 1 commit into
anomalyco:devfrom
thevladimirzh:browser/painted-before-screenshot

Conversation

@thevladimirzh

@thevladimirzh thevladimirzh commented Oct 2, 2026 •

Copy link
Copy Markdown

Issue for this PR

Fixes #52407

Type of change

  • Bug fix

What does this PR do?

case "screenshot" calls Page.getLayoutMetrics and immediately follows it with Page.captureScreenshot. After a client-side navigation the layout is already updated, but the compositor can still hold the previous frame, so the capture returns a stale image.

createBrowserPage already has a painted() helper (double requestAnimationFrame raced against a 150 ms timeout) at the bottom of this file — it is only used by the element-comment highlight path. This PR calls it before sizing the clip, so the capture waits for the next painted frame. Typical cost is one to two frames; the existing race caps the worst case at 150 ms, and this runs only after the visible-tab check above.

Honest caveat: I could not reproduce a stale frame in this environment across ~63 scenarios (isolated Electron harness, the shipped v2.0.20 app, and this branch). So this is defensive hardening that closes a timing window, not a fix for a demonstrated failure. The original report's symptom was in part page-side — see the triage comment in #52407 for details.

How did you verify your code works?

  • bun run typecheck in packages/gui-extensions — clean.
  • bun test in packages/gui-extensions — 94 pass, 1 skip, 0 fail.
  • The desktop app builds and launches from this branch.
  • No test coverage exists for the screenshot path today, so there was nothing to extend; happy to add one if there is a preferred harness.

Screenshots / recordings

Not a UI change: the captured image and the tool interface are unchanged, only when the capture starts.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ture

Page.getLayoutMetrics reports the updated layout immediately after a
client-side navigation, but Page.captureScreenshot can still read the
previous compositor frame. The file already has painted() (double rAF
raced against 150 ms) used by the element-comment highlight path;
calling it before sizing the clip makes the capture deterministic.
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Hey! Your PR title gui-extensions(browser): wait for painted frame before screenshot capture doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@thevladimirzh thevladimirzh changed the title gui-extensions(browser): wait for painted frame before screenshot capture fix(gui-extensions): wait for painted frame before screenshot capture Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

browser: screenshot returns stale frame after client-side navigation

1 participant