Skip to content

feat(browser-engine): add serialized per-tab InputGuard with scroll-offset hit test and focused-frame walk - #444

Merged
Hona merged 5 commits into
devfrom
ws9/pr2-input-guard-dev
Nov 21, 2026
Merged

Hona merged 5 commits into
devfrom
ws9/pr2-input-guard-dev

Conversation

@Hona

@Hona Hona commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Addresses ALL READER-12 Round-1 & Round-2 blockers + should-fixes (notes/review-rd294.md) AND READER-10 Critical #3 + drag/point should-fixes (notes/review-rd-tools.md), cleanly merged with origin/dev (#451 Reach::WholeTab + #496 Critical #7).

HOLD FOR READER-12 AND READER-10 VERDICTS BEFORE MERGE. ENGINE_REVISION is already 6 on dev (#447, published is 156.0.26-5), so no revision bump needed.

Official Comparison & Round-Trip Parity (edacc8686a8b89ed5aae75b2833fd99fcd8da7f9, chromium.ts:1812-1856, 2486-2584)

  • Exact official conditions & probe count: Official runs dispatchInput unconditionally on every "agent" call (zero clean-tab shortcut):
    • Pointer/drag ("x" in params: mouseMoved, mousePressed, mouseReleased, mouseWheel, dragEnter, dragOver, drop):
      • Official: frameTrees (1 RT) -> Hit1 (1 RT) -> Describe (1 RT) -> Hit2 (1 RT) -> Dispatch (1 RT) = 5 RTs per pointer event = 15 RTs per click.
      • Ours: Metrics1 (1 RT, Page.getLayoutMetrics) -> Hit1 (1 RT, DOM.getNodeForLocation) -> Describe (1 RT, DOM.describeNode) -> Verify2 (1 RT, batched Page.getLayoutMetrics + DOM.getNodeForLocation) -> Dispatch (1 RT) = 5 RTs per pointer event = 15 RTs per click (exact 1:1 with official; EngineCdpLedger continuously tracks frame trees via events so Metrics1 replaces frameTrees at zero extra RTs; broken un-scrolled HitTestSaved removed from exec/input.rs).
    • Keyboard (Input.dispatchKeyEvent, Input.insertText): 0 CDP probe RTs (synchronous browser.focused_frame() parent-chain walk + EngineCdpLedger), then 1 RT (Dispatch) — exact 1:1 with official chromium.ts:2547-2559.
  • Click latency in µs (proof/ws9/pr444-v2-proof.json, before = published 156.0.26-5, after = #444):
    • Clean page (no extensions): Before p50 = 28,725 µs (p95 = 41,874 µs, min = 17,122 µs, 15/15) -> After (updating live 15-RT measurement now).
    • Page with an extension <iframe>: Before REFUSED (0/5, whole-tab block) -> After clicks outside extension iframe succeed while clicks/releases on extension iframe are REFUSED.

READER-12 Round-2 Blockers (#1–#3) & Should-Fix (#4) Closed

  1. Round-2 Blocker perf(desktop): stop background streams from rebuilding idle sessions #1 (Removed active_press / paired mouseReleased skip, input_guard.rs): Every mouseReleased now runs the full 5-RT Metrics1 -> Hit1 -> Describe -> Verify2 -> Dispatch guard (identical to official chromium.ts:2576-2582). Sending mousePressed(10,10) then mouseReleased(over ext/cross-origin iframe) or a mousedown-moved iframe is refused.
  2. Round-2 Blocker Guard Settings scrolling and time page switches (t1436) #2 (is_ambiguous_focused_url, input_guard.rs:780-795): Matches about:blank and about:srcdoc with strip_prefix + rest.is_empty() || rest.starts_with('?') || rest.starts_with('#') (closing about:blank#x, about:blank?q, about:srcdoc#x, about:srcdoc?q) plus empty, javascript:, data:, and blob:null/.
  3. Round-2 Blocker Drag timeline images out into other apps #3 (#451 Reach::WholeTab + READER-10 Critical Drag timeline images out into other apps #3 app-side fixes):
    • Merged origin/dev (#451 e0d00c676d + #496 ab9627c89).
    • Enforces Reach::WholeTab inherited-grant checks on HostMsg::TypedCdpCall (Input.*), HostMsg::CdpCall (Input.*), HostMsg::DropFiles, InputGuard (prepare_call, Hit1, Verify2 + per-hit-frame Reach::Frames), and CdpPending::InputGuard replies (refuse_reply(..., Some(&Reach::WholeTab)) in both on_dev_tools_method_result and on_dev_tools_message).
    • Preserves #496 (prompts.agent_input() clearing popup_credit + setting menu_suppressed).
  4. Round-2 Should-Fix OpenCode (Rune): switching between top and side tabs glides each tab under the page at full strength (t1435) #4 (Atomic DropFiles queue check, agent.rs, input_guard.rs): Added InputGuard::enqueue_group checking self.queue.len() + calls.len() > MAX_QUEUED upfront before enqueuing dragEnter/dragOver/drop so partial orphan drag steps can never be queued.

READER-12 Round-1 Blockers (#1–#5) & Should-Fix (#6–#8) (Verified Closed)

  • Fresh batched Page.getLayoutMetrics + DOM.getNodeForLocation in Verify2 (rejects scroll/offset shift >= 0.5 px); per-tab emulation_scale: Arc<AtomicU32> applied in Metrics1 & re-verified in Verify2; HostMsg::DropFiles routed through InputGuard with linked group_id + is_covered(); reset_all on renderer crash + abort_session on Target.detachedFromTarget + abort_msg_id on Guard 1b / >16 MiB reply + 5 s PROBE_TIMEOUT; explicit Input.* allow-list; Page.handleJavaScriptDialog refused while leave/covered dialog active; scoped exclusion_revision + frame_chain_rev (0 false refusals on background ad reloads); "fencedframe"/"portal" in is_frame_owner.

READER-10 Critical #3 App-Side Fixes Closed

  • PointResolver emulation scale + mobile visual-viewport offset (crates/browser-pane/src/client.rs, apps/desktop/src/surfaces/browser/rpc/exec/point.rs): Multiplies element center by tab.emulation_info().0 (scale) and subtracts cssVisualViewport.{offsetX,offsetY} when is_mobile (chromium.ts:2486-2499); adds start_with_scroll(..., false); releases objectId on send errors (point.rs:172, 270).
  • start_drag scroll order & drag cancel cleanup (apps/desktop/src/surfaces/browser/rpc/exec/input.rs): Removes broken un-scrolled HitTestSaved, reorders start_drag to match chromium.ts:1812-1815 (scroll to -> scroll from -> save from -> measure to without scroll), serializes drag/key steps through SendInput, gates ingest_drag_intercepted on self.intercepting_drags, and releases mouseReleased in cancel_cleanup if drag_pressed is true.
  • files.drop (exec/files.rs, agent.rs, input_guard.rs): Resolves drop point with emulation scale + mobile offset and enforces full InputGuard + Reach::WholeTab + per-hit-frame inherited-grant checks.

Verification

  • tools/cargo.ps1 check --locked --manifest-path apps/browser-engine/Cargo.toml: PASS (0 errors, 0 warnings).
  • tools/cargo.ps1 check --locked -p browser-pane -p opencode-desktop: PASS (0 errors, 0 warnings).
  • scripts/guardrails.ps1: 5/5 passed.
  • Live CEF 156 proof & µs click latency benchmark: proof/ws9/pr444-v2-proof.json (re-running now on 80794499).

@Hona
Hona merged commit aed93af into dev Nov 21, 2026
6 checks passed
@Hona
Hona deleted the ws9/pr2-input-guard-dev branch November 21, 2026 10:26
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

@Hona

Hona commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Final 15-RT Click Latency (µs) & Live Proof (\�ed93afe1e, \proof/ws9/pr444-v2-proof.json)

  • Clean page (no extensions, n=15): Before (\156.0.26-5) p50 = \29,148 µs* (\min = 17,247 µs, 15/15) -> After (feat(browser-engine): add serialized per-tab InputGuard with scroll-offset hit test and focused-frame walk #444, full 15-RT guard) p50 = \30,952 µs* (\min = 17,791 µs, 15/15) (+1,804 µs\ / +1.80 ms**).
  • Page with extension <iframe>\ (n=15 outside iframe): Before REFUSED (0/5, whole-tab block) -> After *p50 = \29,692 µs* (\min = 17,535 µs, 15/15 outside iframe); direct click on ext iframe REFUSED.
  • Live security & stability proofs:
    ound2_blocker1_mouseReleasedOverExtRefused: true, \�locker2_emulationScale05AttackRefused: true, \mouseReleasedAfterDomMutation: { ok: true, down: 1, up: 1 }, \�ackgroundAdReloadNoFalseRefusals: 8/8.
  • Follow-up nit (READER-10 \scroll\ \GetViewportCenter\ emulation scale): merged in fix(browser): apply emulation scale to scroll viewport center #520 (\13a48d1954).

Hona added a commit that referenced this pull request Nov 21, 2026
…the proofs (#565)

UP-095-TOOLS: 43 of 43 operations plus two-tab trace.isolation seen working outside in, on a dev build with #444 (proof/browser-tools/all-43). UP-095-3P-CONTRACT: hostile-plugin proof 12 of 12 (proof/browser-tools/pr5-contract). Two rows only; every other row equals origin/dev.
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