Repository navigation
fix(gui-extensions): wait for painted frame before screenshot capture - #52704
thevladimirzh wants to merge 1 commit into
Conversation
…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.
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
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:
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. |
Issue for this PR
Fixes #52407
Type of change
What does this PR do?
case "screenshot"callsPage.getLayoutMetricsand immediately follows it withPage.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.createBrowserPagealready has apainted()helper (doublerequestAnimationFrameraced 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 typecheckinpackages/gui-extensions— clean.bun testinpackages/gui-extensions— 94 pass, 1 skip, 0 fail.Screenshots / recordings
Not a UI change: the captured image and the tool interface are unchanged, only when the capture starts.
Checklist