Skip to content

fix(browser): keep omitted window bounds and add getWindowBounds - #2772

Merged
ldm0 merged 1 commit into
mainfrom
fix/window-bounds-partial
Nov 13, 2026
Merged

ldm0 merged 1 commit into
mainfrom
fix/window-bounds-partial

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR #2772 at a glance

**Track:** Trajectory Replay (Browser Eval). Replaces part of #731.

Closes #2767.
Replaces part of #731.

Problem

Browser.setWindowBounds with a partial rectangle (for example {width: 800} after {left: 10, top: 20, width: 900, height: 700}) erased left, top and height; Chromium keeps omitted fields. Browser.getWindowBounds returned -32601 UnknownMethod. Repro: Target.createTarget, Browser.getWindowForTarget, the two setWindowBounds calls above, then getWindowForTarget / getWindowBounds.

Reproduce (steps from #2767)
  1. Target.createTarget, then Browser.getWindowForTarget {targetId} to get windowId
  2. Browser.setWindowBounds {windowId, bounds: {left:10, top:20, width:900, height:700}}
  3. Browser.setWindowBounds {windowId, bounds: {width:800}}
  4. Browser.getWindowForTarget and Browser.getWindowBounds {windowId}

Expected (Chromium)

Both calls return {left:10, top:20, width:800, height:700, windowState:"normal"}. Fields omitted from setWindowBounds are kept.

Actual

  • getWindowForTarget returns {windowState:"normal", width:800}: left, top and height are erased.
  • getWindowBounds returns {"code":-32601,"message":"UnknownMethod"}.

Change

  • moli-protocol/src/domains/browser.rs: set_window_bounds only overwrites the fields present in the request (it previously assigned all four Options unconditionally). New get_window_bounds returns the stored bounds for a live window, sharing the existing liveness check (moved into window_is_live) and returning -32000 Browser window not found otherwise.
  • moli-protocol/src/domains/actions.rs: add BrowserAction::GetWindowBounds.
  • Test: rust_cdp_capability_browser_window_bounds_round_trip now also sets only width, reads the merged rect back through Browser.getWindowBounds, and checks the unknown-window error.

Verification

Repro over CDP against moli serve (before: released v1.1.23 binary; after: debug build of this branch):

# before (released v1.1.23; same code path as origin/main cbf4d0149f)
getWindowForTarget {"windowId": 1923710101, "bounds": {"windowState": "normal", "width": 800}}
getWindowBounds {"code": -32601, "message": "UnknownMethod"}
# after
getWindowForTarget {"windowId": 1923710101, "bounds": {"windowState": "normal", "left": 10, "top": 20, "width": 800, "height": 700}}
getWindowBounds {"bounds": {"windowState": "normal", "left": 10, "top": 20, "width": 800, "height": 700}}
  • cargo fmt --all: clean.
  • cargo clippy -p moli-protocol --all-targets --all-features -- -D warnings: passed.
  • cargo nextest run -p moli-protocol -E 'test(browser_window_bounds) | test(browser_owner) | test(command_dispatch)' --no-fail-fast: 80 passed.
  • Not run locally: workspace-wide clippy and the full workspace nextest (the renderer test binary does not link within this machine's 16 GiB); left to CI.

Cost

Debug builds of origin/main (f935014) and this branch, /usr/bin/time -l, median of 5 runs, two interleaved rounds (the host was shared, so absolute times vary between rounds):

main this PR
issue repro over CDP (moli serve) 0.226 / 0.257 s, 76.6 MB max RSS 0.254 / 0.254 s, 77.2 MB
ordinary page, moli fetch of a local 46 KB article 0.160 s, 88.7 MB 0.150 s, 89.3 MB

The change only touches the Browser.setWindowBounds / Browser.getWindowBounds handlers (an Option::or per field and a map lookup); no page, layout or navigation path is involved.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of a4d08fa

No blocking findings

  • Correctness: set_window_bounds now merges per field with Option::or (moli-protocol/src/domains/browser.rs:395-399), which matches Chromium's "unspecified fields unchanged" and fixes the root cause named in #2767. windowState was already updated only when present. Browser.getWindowBounds (browser.rs:334-352) uses the same liveness check as setWindowBounds, and an unknown or closed windowId returns -32000 Browser window not found, as Chrome does. BrowserAction::GetWindowBounds is parsed by the existing strum camelCase mapping. Playwright's headful resize sequence still works: session-scoped getWindowForTarget, then setWindowBounds {windowId, bounds:{width,height}}, then getWindowBounds. It also keeps left/top now.
  • Test: the extended rust_cdp_capability_browser_window_bounds_round_trip fails on main twice: on the merged-rect assertion and on UnknownMethod. It asserts only Chromium behavior.
  • Cost: only the two handlers change. The numbers in the body are plausible.
  • CI: Format, Clippy, Nextest, Build release and WebDriver smoke pass. Native PDF rendering and links fails, but the same job also fails on unrelated PR fix/rem-root-font-size, and this diff does not touch PDF code. The other jobs are pending.
  • Picture: pending.

Not counted (already on main, not caused by this PR): Chrome rejects setWindowBounds that combines a non-normal windowState with left/top/width/height. Chrome also rejects bounds-only resizes while the window is minimized, maximized or fullscreen ("restore it to normal state first"). moli accepts both and stores them. Worth tracking in a separate issue. #2777 (bounds not applied to the page) is also separate.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

CI note: the failing "Native PDF rendering and links" job is not caused by this PR. It is a regression on main (cbf4d0149f), where wrapped links get one PDF link annotation per glyph. It is filed with a reproduction as #2803: v1.1.23 produces 1 rect for the fixture, while a cbf4d0149f build produces 13. Any PR based on current main hits it.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

CI Regression Report

Source CI run · source state at render: in_progress · artifacts: 6/6

Check Status Signal
Release regression ✅ HEAD/base failures 0/0; raw binary +0.002703%
Frontend differential ✅ 1,020/1,020 cases matched; 0 issues
Agent episodes ✅ 8/8 Moli episodes passed; 0 failures
Runtime/CDP contracts ✅ 26 contract cases; 0 failures
CDP smoke ✅ 116/116 groups passed; 1,680 scenarios
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ✅ HEAD/base failures 0/0; raw binary +0.002703%

Package and image size

Metric Base HEAD Delta Delta %
Raw binary 154.13 MiB 154.13 MiB +4.27 KiB +0.002703%
Stripped binary 106.58 MiB 106.59 MiB +4.00 KiB +0.003665%
gzip binary 53.20 MiB 53.21 MiB +1.89 KiB +0.003461%
Rootfs 161.03 MiB 161.04 MiB +10.00 KiB +0.006065%
gzip rootfs 62.29 MiB 62.29 MiB +330 B +0.000505%

Startup latency and PSS

Case Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta
Serve ready 26.97 ms 26.85 ms −0.12 ms 5.40 MiB 3.47 MiB −1.92 MiB
CDP first page 48.51 ms 48.12 ms −0.39 ms 4.76 MiB 4.74 MiB −18.50 KiB
CDP warm page 11.87 ms 11.12 ms −0.76 ms 53.66 MiB 53.40 MiB −267.00 KiB
CLI about:blank 12.23 ms 12.54 ms +0.31 ms 4.80 MiB 5.27 MiB +482.50 KiB
CLI local JS 23.70 ms 26.21 ms +2.52 ms 4.55 MiB 3.53 MiB −1.02 MiB

Concurrency matrix

Concurrency Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta HEAD failures Unstable B/H
1 23.26 ms 24.47 ms +1.21 ms 711.00 KiB 697.00 KiB −14.00 KiB 0 0/0
5 27.36 ms 28.09 ms +0.73 ms 12.64 MiB 12.32 MiB −319.00 KiB 0 0/0
10 27.06 ms 27.92 ms +0.87 ms 13.58 MiB 13.14 MiB −450.00 KiB 0 0/0
25 26.72 ms 29.96 ms +3.25 ms 13.24 MiB 12.98 MiB −265.00 KiB 0 0/0
100 26.58 ms 27.68 ms +1.10 ms 14.34 MiB 13.33 MiB −1.01 MiB 0 0/0
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues
Match DOM mismatch Diagnostic mismatch Moli error Reference error Infrastructure error Mismatched frames Duration
1,020 0 0 0 0 0 0 8m 3.79s
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Fast contract Episodes Passed Assertions Ready p50 Episode p50
Moli 8 8 47/47 32.36 ms 58.63 ms
Chromium 8 8 47/47 646.46 ms 347.11 ms
Operation p50 Chromium Moli Delta Delta %
navigate 94.54 ms 8.52 ms −86.02 ms −90.99%
observe 3.71 ms 2.10 ms −1.61 ms −43.47%
fill 10.42 ms 3.91 ms −6.51 ms −62.50%
click 65.83 ms 5.13 ms −60.70 ms −92.21%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 70.36 MiB 66.39 MiB 0.88% 18.41% 1 ✅
Chromium 1307.52 MiB 433.16 MiB 1.16% 35.94% 13 ⚠️ PSS partial
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
Suite Cases Failures Median case p50 Median case p95 Median peak PSS p50
Synthetic fetch 13 0 26.14 ms 26.87 ms 762.00 KiB
Long-lived CDP session 13 0 18.28 ms 18.83 ms —
CDP smoke — ✅ 116/116 groups passed; 1,680 scenarios

Workers: 4 · cumulative group time: 448.15 s · failed groups: 0

Slowest group Scenarios Duration Status
dom-input 62 22.15 s ✅
dom-input 62 21.91 s ✅
fetch-resource-dispatch 72 21.75 s ✅
fetch-resource-dispatch 72 21.70 s ✅
scrollbar-visibility 22 20.51 s ✅
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Completed Successful Expected DNS failure Unexpected failures Panics Crashes Timeouts Empty output
545/545 544 1 0 0 0 0 0

Frozen HTML · Linux · --wait done · 45 seconds per page · no retries. Content quality is evaluated separately.

Diagnostics: webmainbench-results — every page's Markdown, stderr, and exit status. Source run and artifacts

All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Sequential Navigation Soak A/B

✅ HEAD completed the 200-navigation resilience and memory observation.

One browser process, one target, and one CDP session navigate CSDN → SegmentFault → Huaban → example.com repeatedly. This run issued 200 Page.navigate commands per binary.

Common ancestor 6c5776a12f → HEAD 8c4e086d22; benchmark order: head-first; workflow: success.

Session resilience

Metric Base HEAD
Attempted / planned 200 / 200 200 / 200
Direct observable pass 200 / 200 198 / 200
Failures / recovered 0 / 0 2 / 2
Recovery failures 0 0
Lifecycle order violations 0 0
Network order violations 0 0
Wall time 620.1 s 579.9 s

A public-page failure is reported separately from an unrecoverable session. The soak requires all navigation attempts, zero failed recovery, zero lifecycle/network ordering violations, and complete resource evidence.

Process-tree memory

Metric Base HEAD Δ
Boundary samples 200 200 0
Boundary RSS samples 200 200 0
Boundary PSS samples 200 200 0
Periodic peak RSS 248.2 MiB 249.9 MiB +1.6 MiB
Periodic peak PSS 246.0 MiB 245.7 MiB -0.3 MiB
RSS · first 10 avg 172.5 MiB 176.5 MiB +4.0 MiB
RSS · last 10 avg 161.8 MiB 195.3 MiB +33.6 MiB
RSS · last − first window -10.7 MiB +18.8 MiB +29.6 MiB
RSS · warm slope / 100 nav -0.8 MiB +7.4 MiB +8.3 MiB
PSS · first 10 avg 169.1 MiB 173.5 MiB +4.4 MiB
PSS · last 10 avg 158.2 MiB 192.1 MiB +33.9 MiB
PSS · last − first window -10.9 MiB +18.6 MiB +29.5 MiB
PSS · warm slope / 100 nav -1.6 MiB +7.2 MiB +8.7 MiB
Peak file descriptors 66 66 0
Peak threads 33 32 -1

HEAD memory by 50-navigation quarter

HEAD range Avg RSS Final RSS Peak RSS Avg PSS Final PSS Peak FD
1–50 178.8 MiB 160.9 MiB 221.5 MiB 175.5 MiB 158.0 MiB 58
51–100 182.5 MiB 127.9 MiB 225.0 MiB 179.2 MiB 124.9 MiB 57
101–150 181.9 MiB 167.1 MiB 227.2 MiB 178.9 MiB 164.1 MiB 58
151–200 192.0 MiB 206.8 MiB 228.5 MiB 188.2 MiB 203.7 MiB 58

Raw reports and per-navigation boundary samples: workflow run and full sequential-navigation-soak-results artifact.

Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Spider Bench A/B

✅ All benchmark browser service runs completed; results are informational.

Public HEAD: 189 / 240 rows; 39 / 48 sites produced rows; 9 unexpected empty sites.

✅ Deterministic fixture contract is clean.

Common ancestor 6c5776a12faa → HEAD 8c4e086d229e; benchmark order: head-first; workflow: success.

Public 48-site run · informational

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 189 / 240 189 / 240 0 (0.00%)
Contract fill 78.75% 78.75% 0.00 pp (0.00%)
Sites with rows 39 / 48 39 / 48 0 (0.00%)
Sites meeting row contract 37 / 48 37 / 48 0 (0.00%)
Unexpected empty sites 9 9 0 (0.00%)
Partial-row sites 2 2 0 (0.00%)
Site outcomes extracted: 38; HTTP error + rows: 1; empty: 8; snapshot error + empty: 1 extracted: 37; HTTP error + rows: 2; empty: 8; snapshot error + empty: 1 —
Observed duration 55.42 s 51.05 s -4.36 s (-7.87%)
Estimated CPU 40.56 s 39.69 s -0.88 s (-2.16%)
Peak PSS 245.12 MiB 262.71 MiB +17.59 MiB (+7.18%)
Peak RSS 248.66 MiB 264.76 MiB +16.11 MiB (+6.48%)
Peak threads 31 32 +1 (+3.23%)
Mismatched sites 0 0 0
Timeout with items 0 0 0
Category rows Base HEAD Δ
news 35 / 40 35 / 40 0
stocks 20 / 40 20 / 40 0
tech 35 / 40 35 / 40 0
sports 27 / 40 27 / 40 0
games 37 / 40 37 / 40 0
life 35 / 40 35 / 40 0

Public-site content, timing, and memory are noisy. This single A/B run reports evidence only; site outcome counts explain missing rows without treating them as a deterministic regression.

CPU and memory timelines

These are bounded 40-point views of the same complete process-tree samples used by the HTML report. CPU uses 100% per occupied logical core; memory lines are RSS first and PSS second when complete PSS samples are available.

Base

xychart-beta
    title "Base CPU"
    x-axis "Elapsed seconds" [1.039, 1.541, 3.042, 4.545, 5.546, 6.046, 7.548, 9.549, 11.051, 12.555, 14.056, 15.559, 17.063, 18.566, 20.069, 21.572, 23.073, 24.573, 26.075, 28.079, 29.581, 31.084, 32.585, 33.086, 34.087, 35.588, 37.089, 38.591, 40.093, 41.595, 43.097, 44.598, 46.6, 48.102, 49.604, 51.106, 52.607, 54.108]
    y-axis "CPU percent" 0 --> 200
    line [0, 1.99, 0, 2, 4, 0, 105.7, 138.06, 129.73, 161.68, 131.74, 105.8, 127.71, 29.94, 99.82, 85.82, 18, 0, 3.99, 3.99, 135.99, 109.72, 97.98, 113.74, 101.86, 77.92, 115.9, 115.83, 103.86, 77.97, 25.98, 133.79, 95.93, 9.99, 11.99, 133.88, 139.86, 129.95]
Loading
xychart-beta
    title "Base memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.039, 1.039, 1.541, 3.042, 4.545, 5.546, 6.046, 7.548, 9.549, 11.051, 12.555, 14.056, 15.559, 17.063, 18.566, 20.069, 21.572, 23.073, 24.573, 26.075, 28.079, 29.581, 31.084, 32.585, 33.086, 34.087, 35.588, 37.089, 38.591, 40.093, 41.595, 43.097, 44.598, 46.6, 48.102, 49.604, 51.106, 52.607, 54.108, 55.417]
    y-axis "Memory MiB" 0 --> 500
    line [14.11, 56.88, 57.08, 57.09, 57.11, 62.99, 62.99, 104.28, 127.93, 146.91, 141.75, 137.55, 152.96, 134.79, 127.66, 136.6, 145.97, 119, 123.87, 122.73, 121.77, 151.1, 139.94, 240.89, 248.66, 189.89, 133.73, 173.38, 149.39, 137.98, 129.24, 140.53, 212.99, 242.48, 149.96, 136.3, 150.14, 175, 138.29, 0]
    line [11.3, 53.87, 54.08, 54.08, 54.1, 59.99, 59.99, 101.28, 124.91, 143.84, 138.71, 133.73, 149.67, 131.76, 124.59, 133.64, 142.88, 115.91, 120.78, 119.65, 118.69, 148.01, 136.83, 237.85, 245.12, 186.78, 130.71, 172.83, 146.27, 134.85, 126.1, 137.38, 210.13, 241.17, 146.81, 133.15, 147.02, 171.85, 135.34, 0]
Loading

HEAD

xychart-beta
    title "HEAD CPU"
    x-axis "Elapsed seconds" [1.039, 1.54, 3.043, 4.545, 5.547, 7.051, 8.553, 10.055, 11.558, 13.061, 14.062, 15.565, 17.067, 18.569, 20.072, 21.575, 22.576, 24.077, 25.577, 27.079, 28.582, 29.083, 30.083, 31.085, 32.586, 34.089, 35.591, 37.092, 38.594, 39.596, 41.096, 42.598, 44.099, 45.601, 47.104, 48.105, 49.607, 50.107]
    y-axis "CPU percent" 0 --> 200
    line [0, 3.99, 97.83, 105.92, 131.74, 123.62, 97.85, 129.66, 87.85, 115.68, 59.97, 27.95, 0, 4, 69.81, 137.61, 2, 0, 99.89, 81.84, 107.8, 101.84, 123.88, 127.71, 119.92, 131.81, 121.77, 105.87, 23.96, 39.95, 2, 83.96, 11.98, 47.94, 113.83, 113.88, 137.84, 171.87]
Loading
xychart-beta
    title "HEAD memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.038, 1.039, 1.54, 3.043, 4.545, 5.547, 7.051, 8.553, 10.055, 11.558, 13.061, 14.062, 15.565, 17.067, 18.569, 20.072, 21.575, 22.576, 24.077, 25.577, 27.079, 28.582, 29.083, 30.083, 31.085, 32.586, 34.089, 35.591, 37.092, 38.594, 39.596, 41.096, 42.598, 44.099, 45.601, 47.104, 48.105, 49.607, 50.107, 51.054]
    y-axis "Memory MiB" 0 --> 500
    line [14.07, 57.22, 63.5, 113.11, 118.53, 129.18, 155.91, 134.6, 154.09, 141.86, 137.19, 135.48, 123.97, 124.22, 124.6, 139.83, 120.63, 118.04, 119.52, 150.78, 137.22, 203.93, 264.76, 179.93, 186.57, 169.1, 145.09, 154.34, 153.38, 131.68, 138.57, 139.32, 141.13, 142.73, 140.85, 163.73, 154.25, 158.47, 176.94, 0]
    line [11.17, 54.2, 60.48, 110.34, 115.85, 126.17, 152.82, 131.66, 151.27, 138.81, 134.04, 132.39, 120.88, 121.13, 121.51, 136.98, 117.53, 114.94, 116.43, 148.11, 134.15, 204.82, 262.71, 176.84, 183.53, 166.02, 142.04, 151.3, 150.32, 128.64, 135.52, 136.27, 138.08, 139.68, 138.82, 160.78, 151.21, 155.52, 173.93, 0]
Loading

Deterministic fixture · required contract

The fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 40 / 40 40 / 40 0 (0.00%)
Contract fill 100.00% 100.00% 0.00 pp (0.00%)
Sites with rows 8 / 15 8 / 15 0 (0.00%)
Sites meeting row contract 15 / 15 15 / 15 0 (0.00%)
Unexpected empty sites 0 0 0
Partial-row sites 0 0 0
Site outcomes extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 —
Observed duration 19.98 s 20.20 s +0.23 s (+1.13%)
Estimated CPU 0.47 s 0.47 s -0.00 s (-0.21%)
Peak PSS 70.38 MiB 70.32 MiB -0.06 MiB (-0.08%)
Peak RSS 73.49 MiB 73.84 MiB +0.34 MiB (+0.47%)
Peak threads 21 21 0 (0.00%)
Mismatched sites 0 0 0
Timeout with items 0 0 0

Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full spider-bench-results artifact.

The public-web A/B is informational. The exact HEAD fixture contract runs as a separate required CI check; timing and public-site content deltas remain non-blocking.

@lanyue-llk
lanyue-llk force-pushed the fix/window-bounds-partial branch from 8c4e086 to b5de91a Compare November 13, 2026 12:12
@ldm0
ldm0 merged commit b0645fd into main Nov 13, 2026
7 of 10 checks passed
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.

Partial Browser.setWindowBounds erases omitted fields; Browser.getWindowBounds is UnknownMethod

2 participants