Repository navigation
perf(browser): reuse snapshot refs and screenshot metadata - #133598
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 6:42 PM ET / 22:42 UTC. ClawSweeper reviewWhat this changesThis PR removes repeated duplicate-reference bookkeeping in browser snapshot builders and reuses screenshot normalization metadata when returning labeled image annotations. Merge readinessThe performance refactor remains necessary and has no discrete correctness or security defect from the introduced hunks. It is a maintainer-authored, maintainer-labeled PR, so it should remain open for the browser owner’s normal landing decision after exact-head CI completes. Priority: P3 Review scores
Verification
How this fits togetherBrowser snapshot routes turn page accessibility data into targetable references for agent actions and produce normalized screenshots for media responses. The changed code constructs those references across CDP, Playwright, and Chrome MCP paths, then preserves annotation geometry when screenshots are resized. flowchart LR
A[Browser page] --> B[CDP Playwright and Chrome MCP snapshots]
B --> C[Reference metadata]
C --> D[Agent snapshot response]
A --> E[Screenshot capture]
E --> F[Image normalization]
F --> G[Annotation rescaling]
G --> H[Saved media response]
Decision needed
Why: The patch is clean in source review, but the maintainer label and MEMBER authorship require an explicit maintainer landing decision rather than automated cleanup. Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -102, Tests +3. Total -99 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the producer-local refactoring: retain backend-specific nth semantics, use the normalizer as the sole source-dimension owner, and land only after the exact-head build check is green. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR optimizes existing browser paths rather than reporting a user-facing defect. The submitted body describes after-fix Gateway and managed-Chrome runs, while source review independently confirms the affected owner paths. Is this the best way to solve the issue? Yes. Removing redundant bookkeeping at the snapshot and normalization owners is preferable to caching or compensating later in route consumers; the backend-specific reference semantics remain explicit in their respective owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7504a3b3c453. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…cked-delivery * origin/main: fix(ui): wait for restored draft before clearing (openclaw#133575) fix(deps): update fast-uri security patches (openclaw#133572) test: reduce workflow sanity fixture cleanup time (openclaw#133588) fix(media): normalize detected Matroska MIME (openclaw#133383) refactor(docker): retire ClawDock shell helpers (openclaw#133594) perf(browser): reuse snapshot refs and screenshot metadata (openclaw#133598) perf: load web chat history in larger, faster batches (openclaw#133565) fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths (openclaw#133584) test: isolate shared /tmp session-store paths in runner and health suites (openclaw#133568) fix(cron): avoid no-op schedule repair writes (openclaw#133552)
Browser snapshots currently keep parallel duplicate-ref arrays and maps, then clean them up after construction. Delta finalization parses the same formatter-owned lines twice. Labeled screenshot routes also probe source dimensions already read by normalization, and probe unchanged output again.
This PR removes that repeated preparation at the existing owners. Duplicate-group counts retain each backend’s omitted-versus-zero
nthcontract, including stored ARIA’s final-record lookup for overwritten input refs. Delta requests carry parsed refs and the truncator’s accepted source-line count into visibility filtering; ordinary capped requests still parse only retained lines. Screenshot normalization carries its private source dimensions to both annotation routes, and identical output buffers retain the original annotations without another metadata probe. No public SDK, config, schema, dependency, navigation authority or cache lifecycle changes.Three distinct mechanisms are proposed, with four snapshot backends sharing one grouping mechanism. The formatted production delta is +88/-191, net -103; four existing test mocks add the new private return field (+4 test/support lines). An iframe-assembly proposal was rejected because a malformed raw-role control changed output; it is excluded.
The snapshot proof passed 1,299 scenarios / 3,897 exact comparisons across complete copied owners. The native image proof passed 34 cases across complete routes and actual Rastermill/Photon processing, including exact bytes, EXIF orientation, budgets, annotation geometry and output identities. Twelve fresh serial timing children retained all 5,508 samples across 90 workloads in both process orders. Source/dependency bindings and process cleanup were checked; all preflight output projections matched.
Representative warm local results: unique ARIA ref construction 1.55–1.77× faster; complete 32-row Playwright delta snapshots 1.36–1.41×; uncapped delta finalization 1.45–1.53×; labeled unchanged screenshot preparation 2.73–3.36×. The heavily capped large delta control and real native resizing (about113 ms) were approximately neutral. These are local owner costs with explicit browser/transport/storage substitutions, not end-to-end browser or provider latency, and ablation gains must not be multiplied.
Negative controls are retained: ordinary unlabelled screenshot POST cost 10.708→12.215µs /10.979→12.029µs (+1.05–1.51µs). Empty-label cases were mixed, including a medium-image +10.14%/+0.52% cost. The canonical source-dimension owner is retained without fixture-specific tuning branches. No retained-memory or whole-turn speedup claim.
The integrated owners exactly match the measured candidates. All260 existing tests across15 files pass; after rebasing onto current main,267 tests across16 files (including the updated pinned-transport suite) pass, as do the full build and full changed-file checks (including production/test types, lint, dead exports and boundary checks). Independent complete-owner review and managed Codex review are clean. No user-visible shape or behavior change requires a docs/changelog update under the current release-only policy.
Live verification passed through29 normal CLI/Gateway calls against a task-owned authenticated development Gateway and signed managed Chrome. It proved duplicate-reference targeting and ordered clicks, unchanged/added-node deltas, ordinary raw and exact element screenshots, both labeled GET/POST normalization paths, scaled annotation geometry, overlay teardown and absence of the private metadata field from public responses. The960×640 element image and both1000×2000 labeled images were visually inspected; raw capture remains756×469 as permitted by its native-surface contract. All owned processes exited, both ports closed, and final source/build bindings matched.
Failed attempts remain recorded. Fresh-profile startup intermittently failed in the unchanged ownership check before the fixture; passive transport/event-loop observations and a local V8 profile do not yet establish its underlying cause. Ownership, SSRF, timeouts and retries were not changed. An early helper assertion incorrectly equated raw native capture size with an emulated CSS viewport; the revised proof follows the documented route contract and separately checks a supported exact element clip. These are after-only behavior checks, not browser startup/whole-turn speed measurements. Chrome-MCP, iframe navigation/reset and raw-CDP snapshot fallback are covered by canonical tests/copied-owner proofs, not claimed as live here.
Rebase note: all six measured production owners remain byte-identical on main7504a3b3 plus this change. The upstream transport fix preserves nested contextless worker/iframe sessions; its complete owner/dependency path was reviewed and added to the canonical test run. The recorded live fixture contains neither workers nor iframes. Build/live receipts retain their original343fe909-plus-candidate provenance; they are not relabeled as a new build.