Skip to content

fix(resize-observer): deliver observations once per animation frame - #2818

Open
lanyue-llk wants to merge 7 commits into
fix/resize-observer-layoutfrom
fix/resize-observer-frame
Open

lanyue-llk wants to merge 7 commits into
fix/resize-observer-layoutfrom
fix/resize-observer-frame

Conversation

@lanyue-llk

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

Copy link
Copy Markdown
Contributor

PR #2818 at a glance

**Track:** Web Fetch (Browser Eval). Replaces part of #1593.

Part of #2795. Stacked on #2810: the base is fix/resize-observer-layout, so this diff contains only the delivery change.

Problem. ResizeObserver callbacks ran as host microtasks scheduled on every observe() and DOM mutation, not in a rendering update. This caused three problems:

  • A callback that changes its target's size re-queued itself inside the same microtask checkpoint. The feedback-loop fixture (an observer that toggles display on its target) ran ~15,000 callbacks in one frame until the watchdog terminated it, burning about 8 s of CPU per fetch.
  • There was no microtask checkpoint between observers: first's Promise.resolve().then(() => second.disconnect()) ran after second had already been called.
  • Delivery happened in the script's own microtask checkpoint, before queueMicrotask work queued by the same script.
Reproduce (steps from #2795)

Each page records into globals, and the client reads them after 1.6 s:

  1. Two observers on one 50×20 div. The first callback runs Promise.resolve().then(()=>{order.push('microtask'); second.disconnect()}).
  2. new ResizeObserver(()=>log.push('ro:mt='+mt)).observe(t); queueMicrotask(()=>mt=true).
  3. Divs a, b and c. Observer first watches a and observer second watches b; first's callback calls second.observe(c).
  4. <div id=node style="width:50px;height:20px">x</div>, with an observer callback that toggles node.style.display between '' and 'none', plus a rAF frame counter and an error listener.

Expected (Chromium; HTML "update the rendering" and the ResizeObserver spec)

  1. ["first","microtask"]
  2. ["ro:mt=true"]
  3. ["first","second:b","error","second:c"]
  4. One callback per frame and one error event per frame, with message "ResizeObserver loop completed with undelivered notifications." (trusted, not bubbling, cancelable, filename = the document URL; window.onerror is called). After 1 s: 144 callbacks, 144 errors and 145 frames.

Actual

  1. ["first","second","microtask"]
  2. ["ro:mt=false"]
  3. ["first","second:b,c"], with no error event
  4. Every delivery happens in frame 1. Between 186,807 and 214,157 callbacks run while the frame counter stays at 1, until "callback 'ResizeObserver callback' was terminated". The loop error never fires.

Change.

  • context_bootstrap/resize_observer_runtime.rs: queuing an observer no longer schedules a microtask. The first observer queued for a Window schedules one delivery for that Window's next animation frame. deliver_resize_observer_frame then gathers the observations of every queued observer first, and only after that calls each observer's callback, with a microtask checkpoint after each. An observer disconnected by an earlier callback or its microtasks is skipped. Changes made during a delivery are picked up at the next frame, so a feedback loop runs one delivery per frame, as with requestAnimationFrame.
  • host/timers.rs: the delivery is a small native timer task, ScheduledTimerCallback::ResizeObserverFrame, modelled on the existing ResourceTimingBufferFull task. It runs outside any JS call, which is required for the per-callback checkpoint; an internal JS-function timer suppresses that checkpoint.
  • window_host.rs: next_animation_frame is the rAF timestamp/delay computation, extracted unchanged, so RO delivery joins the same frame cadence and shared timestamp as requestAnimationFrame.
  • Each rAF callback is its own timer, due at most 1 ms after the frame timestamp, and timers with equal due times run in queue order. The RO delivery is therefore scheduled 2 ms after the frame's delay (1 ms would still invert a tiny fraction of same-frame pairs because of rounding and clock reads), so it runs after every requestAnimationFrame callback of that frame, as in the rendering update: observe(el); requestAnimationFrame(() => el.style.width = '200px') gives raf, ro. Limitation: an observe() or resize made inside a rAF callback is usually delivered one frame later (it joins the same frame when an RO delivery is already pending), because moli has no single end-of-frame step to hook into.
  • runtime/page_commands.rs + script_vm/rendering_update.rs: because delivery now waits for the frame timer, output read right after readiness could miss what an observer writes. CaptureScreenshot and PrintToPdf therefore first run a pending RO frame delivery once (run_pending_resize_observer_frame), through the same gather/broadcast/checkpoint path, as the frame Chromium produces for a screenshot would. Page exports do not: RenderMarkdown and SerializeDocument { options } (since refactor(html): serialize page exports without DOM copies #2836 the single path for page HTML, the JSON html field and MHTML) stay a pure projection of the live DOM and never run page script, as in Chromium, where Page.captureSnapshot does not run an animation frame. The flush is one round, top-level Window only; a feedback loop's next delivery is still paced by the frame timer. With nothing queued it does nothing, and it never creates a main world.
  • moli/src/app/readiness.rs + Page::run_pending_resize_observer_frame_async (RendererPageCommand::RunPendingResizeObserverFrame): CLI fetch runs the same one-round flush once, when readiness completes, for every --wait mode, before any dump or --eval. This is the one step that makes --dump html|json|markdown|semantic_tree[_text] and --eval include what observers wrote. The command does not refresh page state or follow a queued navigation. Runtime.evaluate and the export commands do not flush, so CDP clients let a frame pass themselves, as in Chromium; secondary_webapis_cover_file_file_list_and_resize_observer_basics now runs the pending frame after runGeometryProbe() before reading the page. The command is classified as a V8-entering command for nested dispatch.
  • A per-Window "frame task queued" flag replaces "queue was empty" as the scheduling test. An early flush therefore cannot start a second frame timer, and a feedback loop stays at one delivery per frame (frame:width:ms: 1:100:39, 2:0:50, 3:100:70, …).
  • Inside a debugger pause (nested Main dispatch, runtime/nested_main.rs), the flush is skipped (nested_main_dispatch_active()), so a screenshot taken while paused (CaptureScreenshot can be nested-dispatched) never runs page script; the frame timer delivers after resume. There is no nested-dispatch test nearby to extend; test(nested) | test(pause) | test(resize_observer) passes.
  • Not in this PR (planned for PR 2): the depth rule and the "ResizeObserver loop completed with undelivered notifications" error event.

Verification. Triage fixtures, debug builds, moli fetch URL --delay-ms 300 --eval 'JSON.stringify(OUT())':

fixture main this branch Chrome
microcheck (queueMicrotask after observe) ["ro:mt=false"] ["ro:mt=true"] ["ro:mt=true"]
microdisc (first's microtask disconnects second) ["first","second","microtask"] ["first","microtask"] ["first","microtask"]
reobserve [100] [100] —
feedback loop, first 12 deliveries as frame:width:ms all in frame 1, about 1 ms apart one per frame: 1:100:48, 3:0:75, 4:100:94, 5:0:112, … one per frame
  • New test resize_observer_delivers_at_the_frame_with_a_checkpoint_per_callback. It checks nothing is delivered in the script's microtask checkpoint, and that the first callback's microtask disconnects the second observer before it is called.
  • Dumps right after load (no --delay-ms), an observer that sets data-observed="yes" and writes ROTEXT, current head 17ba647: the text is present in --dump html|json|markdown|semantic_tree_text, in --layout --dump html, and in --eval 'o.textContent' at --wait-until domcontentloaded/load/done with and without --layout, all through the single readiness flush. Before the readiness flush and capture flushes (3a58b96) the dumps lacked it and ro2.html --layout was empty; now ROW-0 (h=200) … ROW-4 (h=200).
  • CDP Page.captureSnapshot (MHTML) on moli serve, called right after Page.navigate returns: the observer output is not yet in the snapshot. A second snapshot 200 ms later contains it, delivered by the frame timer. The export itself no longer drives deliveries.
  • A feedback-loop page (callback toggles display) with --dump html now shows 2 callbacks (frame timer plus the one readiness flush); the export adds none.
  • New fetch-level test cli_dumps_include_content_written_by_resize_observers (moli/tests/fetch_cli.rs) covers the html dump (plain and --layout), --eval at the three --wait-until modes with and without --layout, and --dump semantic_tree_text.
  • New test resize_observer_delivery_follows_the_frames_animation_callbacks (observe, then rAF → raf,ro). It fails as ro,raf without the extra delay.
  • Seven existing RO/observer tests that read results right after observe() now advance the timer task first with advance_timers_until_deadline_for_test. Their expected values are unchanged.
  • cargo nextest run -p moli-renderer-v8 -E 'test(resize_observer) | test(observer_callbacks) | test(ondemand_ro) | test(real_ro) | test(animation_frame) | test(intersection) | test(timer)': 159 passed.
  • cargo fmt --all clean; cargo clippy -p moli-renderer-v8 --all-targets --all-features -- -D warnings clean (workspace clippy not run locally).
  • Rebased onto main after refactor(html): serialize page exports without DOM copies #2836, then the export flush removed (head 17ba647 on fix(resize-observer): measure the first observation from a real layout #2810 head 14bb8f7): cargo fmt --all clean; cargo clippy -p moli-renderer-v8 -p moli-core -p moli --all-targets --all-features -- -D warnings clean; renderer filter above plus test(serialize) | test(nested) | test(pause) | test(lazy_main_world) | test(markdown): 524 passed; -p moli -E 'test(resize_observer) | test(cli_dump_html) | test(render_page_dump) | test(mhtml) | test(markdown)': 34 passed; -p moli-core --test web_apis: 163 passed. Repro: microcheck ["ro:mt=true"], microdisc ["first","microtask"].
  • Not run locally: the full workspace nextest (the renderer test binary does not link within local RAM); left to CI.

Cost. Pages without a ResizeObserver never schedule anything. A page with observers gets at most one native delivery task per Window per animation frame, and only while observations are queued. A feedback loop now costs one delivery per frame instead of spinning until the watchdog fires. Debug builds of main cbf4d01 and this branch, same profile, /usr/bin/time -l:

case main this branch
feedback loop (hidefb_nocap.html --delay-ms 1000 --timeout 10000), 3 runs 9.1-9.4 s wall, 7.8-8.1 s user CPU, ~120 MB; ~15,000 callbacks, then "callback ResizeObserver callback was terminated" 1.05 s wall, 0.24-0.30 s user CPU, 94 MB; 52-54 callbacks in 53-56 frames, no error
ordinary local article (no observer), median of 7 0.08 s / 88.3 MB 0.09 s / 88.4 MB
observer without feedback (ro1.html), median of 7 0.06 s / 90.4 MB 0.06 s / 83.3 MB
ro2.html --layout --delay-ms 500, median of 7 0.56 s / 88.1 MB 0.56 s / 93.9 MB (includes #2810's first layout)

Dump cost with the earlier pre-dump export flush (now removed from exports; kept for screenshot/PDF) (debug, alternating runs, median of 7): ordinary article --dump html 0.10 → 0.09 s; ordinary --layout --dump screenshot 0.99 → 0.99 s; observer page ro1.html 0.07 → 0.07 s. The feedback loop with --delay-ms 1000 is unchanged: 53 callbacks over 55 frames, 0.28-0.30 s user CPU.

After the readiness flush (debug): ordinary article --dump html 0.08 s and --eval 0.08 s (5-run medians). The feedback loop with --delay-ms 1000 gives 56 callbacks over 56 frames at 0.29 s user CPU.

@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 546cf70 (diffed against #2810's head 3397793)

Changes needed (1)

  1. ResizeObserver can run before requestAnimationFrame callbacks of the same frame. See resize_observer_runtime.rs:770-776 (schedule_resize_observer_frame) and host/timers.rs:690-696. The RO task and each rAF callback are separate timers. Each one's run_at is Instant::now() + ceil(target - now), and TimerScheduler (moli-time/src/timers.rs:42-48) orders them by run_at. ceil keeps the delay at 16 ms for any call made less than 1 ms after the frame's timestamp was fixed, so the timer queued first fires first.

    Failure scenario: a script runs ro.observe(el); requestAnimationFrame(() => { log.push('raf'); el.style.width = '200px'; });. This branch runs the RO task first: it logs ro with the old size, then raf, then a second RO delivery one frame later. The rendering-update order in the spec, which Chrome follows, is rAF then RO in the same frame: raf, then one ro already showing 200px.

    Related: finish_animation_frame_callback_batch clears the pending frame timestamp at the first rAF callback. So an observe() or resize inside a rAF callback is delivered a whole frame late, not in that frame. That means the PR body's "joins the same frame" holds only for timing. It does not hold for ordering.

    Smallest fix: make the RO task sort after every rAF callback queued for that frame. The simplest version is to schedule it at delay_ms + 1: ceil puts all same-frame rAF deadlines within 1 ms of each other, so this keeps it behind them. A more exact option is to run deliver_resize_observer_frame from the end of the frame's rAF batch whenever one is pending. Either way, add a test that logs raf,ro for observe-then-rAF.

Other focus points, checked with no finding:

  • Zero cost and idle. The timer is queued only by queue_resize_observer_delivery when the queue goes from empty to non-empty (resize_observer_runtime.rs:761-766). That happens only for observers with targets after an observe() or a DOM mutation. The queue is drained before any callback runs, so an idle page with an observer schedules nothing. Each mutation burst costs at most one 16 ms task per Window. There are no perpetual wakeups.
  • --wait domstable/networkidle. A queued delivery is a short timer, comparable to a single rAF, so it never trips the long-pending-timeout path. A true feedback loop keeps changing the DOM and is bounded by the fetch deadline at 60 Hz. Before this PR it spun until the watchdog fired, so this is strictly better.
  • Child frames. The queue slot, frame timestamp, timer owner and delivery context are all taken from the same current global, so each document keeps its own queue.
  • Tests. The 7 adjusted tests keep their expected values and only advance timers before asserting. The new test fails on the base, which logs first,second,microtask and delivers inside the script checkpoint.
  • Size. About 150 non-test lines, reusing the existing ResourceTimingBufferFull native-task pattern. That is proportional, and the native task is required for the per-callback checkpoint.
  • CI was still pending at review time (Build release, Clippy, Nextest, CDP smoke).
  • Picture: pending.

@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 95184fa (round 2, diff against #2810's fix/resize-observer-layout)

No blocking findings

The round-1 ordering problem is fixed for the normal cases. RO frame delivery, gather-then-broadcast with a checkpoint per callback, skipping disconnected observers and the native ResizeObserverFrame task all look right. Default path cost is unchanged because nothing is scheduled without a queued observer.

Non-blocking notes:

  1. resize_observer_runtime.rs schedule_resize_observer_frame (delay_ms + 1): the margin holds in exact arithmetic. DOM time is floored to 0.1 ms, so every same-frame rAF is due before T+1 and RO is due at T+1 or later. Two things can still put a rAF after RO, though:

    • FP rounding can turn an integer T - now into k + 1e-13, so ceil adds a whole ms to that rAF.
    • The gap between the SystemTime read in next_animation_frame and the later Instant::now() in schedule_after differs per call.

    A simulation of observe() followed by requestAnimationFrame at a random later point in the same frame gave about 1.5e-5 inversions per pair from rounding alone. The effect is one frame with the old ro,raf order. The new test can't hit this, because both calls land on the same 0.1 ms tick. The smallest hardening is delay_ms.saturating_add(2), or computing the delay from (T - now) rounded to the 0.1 ms grid before ceil. Your call.

  2. Body, "Limitation": the resize is not always a frame late. It is late only when the RO queue is empty at the time. If an RO frame task is already pending for this frame, for example from an earlier observe(), an observer queued in a rAF callback joins it and is delivered in the same frame. Suggest "usually delivered one frame later".

CI: Format, Node, Python and Windows pass; Nextest, Clippy, CDP smoke and the builds were still pending at review time. Picture matches the body (feedback loop, ordering fixtures, flow, cost). It doesn't show the new rAF-before-RO step or its test, which is fine.

@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 14bb8f7718 → HEAD 17ba647874; benchmark order: head-first; workflow: success.

Session resilience

Metric Base HEAD
Attempted / planned 200 / 200 200 / 200
Direct observable pass 200 / 200 200 / 200
Failures / recovered 0 / 0 0 / 0
Recovery failures 0 0
Lifecycle order violations 0 0
Network order violations 0 0
Wall time 509.4 s 524.0 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 241.1 MiB 235.9 MiB -5.2 MiB
Periodic peak PSS 238.1 MiB 231.9 MiB -6.2 MiB
RSS · first 10 avg 165.2 MiB 177.4 MiB +12.2 MiB
RSS · last 10 avg 180.8 MiB 139.6 MiB -41.2 MiB
RSS · last − first window +15.6 MiB -37.7 MiB -53.4 MiB
RSS · warm slope / 100 nav +4.6 MiB -25.9 MiB -30.6 MiB
PSS · first 10 avg 162.0 MiB 173.2 MiB +11.2 MiB
PSS · last 10 avg 177.6 MiB 135.8 MiB -41.8 MiB
PSS · last − first window +15.6 MiB -37.4 MiB -52.9 MiB
PSS · warm slope / 100 nav +4.7 MiB -26.3 MiB -31.0 MiB
Peak file descriptors 66 66 0
Peak threads 34 33 -1

HEAD memory by 50-navigation quarter

HEAD range Avg RSS Final RSS Peak RSS Avg PSS Final PSS Peak FD
1–50 179.6 MiB 158.6 MiB 222.0 MiB 175.8 MiB 155.6 MiB 58
51–100 178.8 MiB 223.6 MiB 223.6 MiB 175.1 MiB 219.6 MiB 59
101–150 171.8 MiB 128.1 MiB 223.9 MiB 167.6 MiB 124.1 MiB 58
151–200 149.1 MiB 102.4 MiB 192.9 MiB 145.2 MiB 99.3 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: 184 / 240 rows; 38 / 48 sites produced rows; 10 unexpected empty sites.

✅ Deterministic fixture contract is clean.

Common ancestor 14bb8f771816 → HEAD 17ba6478740d; benchmark order: head-first; workflow: success.

Public 48-site run · informational

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 189 / 240 184 / 240 -5 (-2.65%)
Contract fill 78.75% 76.67% -2.08 pp (-2.64%)
Sites with rows 39 / 48 38 / 48 -1 (-2.56%)
Sites meeting row contract 37 / 48 36 / 48 -1 (-2.70%)
Unexpected empty sites 9 10 +1 (+11.11%)
Partial-row sites 2 2 0 (0.00%)
Site outcomes extracted: 38; HTTP error + rows: 1; empty: 7; HTTP error + empty: 1; snapshot error + empty: 1 extracted: 36; HTTP error + rows: 2; empty: 8; HTTP error + empty: 1; snapshot error + empty: 1 —
Observed duration 67.49 s 78.72 s +11.23 s (+16.64%)
Estimated CPU 41.39 s 45.98 s +4.59 s (+11.09%)
Peak PSS 239.07 MiB 240.73 MiB +1.66 MiB (+0.70%)
Peak RSS 243.09 MiB 244.54 MiB +1.44 MiB (+0.59%)
Peak threads 31 31 0 (0.00%)
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 32 / 40 27 / 40 -5
games 32 / 40 32 / 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" [2.039, 4.042, 5.545, 7.547, 9.549, 11.552, 13.055, 14.056, 15.058, 17.06, 19.061, 20.562, 22.566, 24.568, 26.57, 28.072, 30.075, 32.077, 34.08, 35.583, 37.585, 38.086, 39.588, 41.589, 43.091, 45.094, 47.096, 49.098, 50.6, 52.602, 54.606, 56.609, 58.11, 60.113, 62.115, 64.118, 65.62, 67.121]
    y-axis "CPU percent" 0 --> 200
    line [105.84, 91.86, 143.68, 81.96, 67.94, 121.66, 1.99, 0, 0, 2, 0, 10, 9.99, 11.99, 10, 61.84, 79.79, 21.94, 33.95, 101.94, 99.76, 107.79, 109.81, 45.95, 125.89, 103.94, 11.99, 127.86, 109.72, 119.84, 37.89, 25.98, 2, 0, 127.83, 2, 31.96, 147.73]
Loading
xychart-beta
    title "Base memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.037, 2.039, 4.042, 5.545, 7.547, 9.549, 11.552, 13.055, 14.056, 15.058, 17.06, 19.061, 20.562, 22.566, 24.568, 26.57, 28.072, 30.075, 32.077, 34.08, 35.583, 37.585, 38.086, 39.588, 41.589, 43.091, 45.094, 47.096, 49.098, 50.6, 52.602, 54.606, 56.609, 58.11, 60.113, 62.115, 64.118, 65.62, 67.121, 67.492]
    y-axis "Memory MiB" 0 --> 500
    line [13.93, 108.63, 112.16, 131.72, 136.99, 125.83, 135.61, 136.49, 135.49, 135.49, 135.47, 135.58, 134.94, 134.96, 135.77, 135.12, 133.56, 146.04, 130.13, 127.4, 131.49, 231.86, 243.09, 191.85, 138.66, 132.81, 141.03, 133.83, 233, 225.46, 234.44, 234.58, 232.82, 232.99, 152, 163.23, 133.57, 135.43, 167.08, 0]
    line [10.61, 105.14, 108.81, 128.08, 134.77, 122.24, 132.12, 132.98, 131.98, 131.98, 131.89, 131.98, 131.34, 131.36, 132.17, 131.53, 129.96, 142.44, 126.53, 123.89, 127.88, 228.28, 239.07, 188.29, 134.88, 129.29, 137.54, 130.33, 229.57, 221.97, 230.96, 231.1, 229.33, 229.51, 148.52, 159.66, 129.91, 131.95, 163.74, 0]
Loading

HEAD

xychart-beta
    title "HEAD CPU"
    x-axis "Elapsed seconds" [2.039, 4.042, 4.542, 6.544, 9.047, 11.05, 13.053, 15.556, 17.558, 20.062, 22.065, 24.067, 26.572, 28.574, 30.577, 33.079, 35.08, 37.585, 39.587, 41.589, 44.093, 46.095, 48.598, 50.601, 52.604, 55.108, 57.111, 59.614, 61.117, 61.617, 63.619, 66.122, 68.124, 70.129, 72.632, 74.635, 75.636, 77.137]
    y-axis "CPU percent" 0 --> 200
    line [129.61, 85.8, 133.92, 139.86, 135.87, 49.93, 0, 9.99, 9.99, 0, 1.99, 0, 9.98, 7.98, 11.99, 2, 64.02, 5.97, 70.03, 103.77, 39.92, 103.96, 107.97, 103.92, 59.89, 111.78, 89.89, 77.91, 101.69, 137.79, 59.93, 39.96, 2, 43.86, 9.99, 141.82, 159.77, 99.9]
Loading
xychart-beta
    title "HEAD memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.036, 2.039, 4.042, 4.542, 6.544, 9.047, 11.05, 13.053, 15.556, 17.558, 20.062, 22.065, 24.067, 26.572, 28.574, 30.577, 33.079, 35.08, 37.585, 39.587, 41.589, 44.093, 46.095, 48.598, 50.601, 52.604, 55.108, 57.111, 59.614, 61.117, 61.617, 63.619, 66.122, 68.124, 70.129, 72.632, 74.635, 75.636, 77.137, 78.722]
    y-axis "Memory MiB" 0 --> 500
    line [13.62, 104.27, 115.06, 133.24, 143.22, 149.42, 146.62, 140.84, 136.78, 136.77, 136.5, 136.5, 136.54, 136.54, 136.56, 136.59, 136.59, 148.27, 124.81, 128.7, 122.8, 132.95, 134.55, 182.5, 205.3, 152.89, 163.23, 141.57, 177.19, 244.54, 219.03, 231.45, 235.47, 232.39, 237.26, 135.51, 161.9, 168.96, 159.61, 0]
    line [10.22, 100.67, 111.46, 129.56, 139.68, 146.44, 143.05, 137.27, 133.22, 133.22, 133, 132.88, 132.9, 132.93, 132.98, 132.97, 133.02, 142.69, 121.2, 125.1, 119.11, 129.26, 130.96, 178.89, 201.57, 149.18, 155.31, 137.93, 173.55, 240.73, 213.54, 227.15, 231.9, 228.86, 233.68, 131.93, 158.38, 165.39, 156.08, 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.94 s 19.88 s -0.06 s (-0.30%)
Estimated CPU 0.45 s 0.42 s -0.03 s (-6.42%)
Peak PSS 69.97 MiB 69.67 MiB -0.30 MiB (-0.43%)
Peak RSS 73.59 MiB 73.10 MiB -0.50 MiB (-0.67%)
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.

@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.003149%
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 ✅ 120/120 groups passed; 1,798 scenarios
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ✅ HEAD/base failures 0/0; raw binary +0.003149%

Package and image size

Metric Base HEAD Delta Delta %
Raw binary 154.58 MiB 154.59 MiB +4.98 KiB +0.003149%
Stripped binary 106.98 MiB 106.99 MiB +4.00 KiB +0.003651%
gzip binary 53.44 MiB 53.44 MiB +1.34 KiB +0.002443%
Rootfs 161.48 MiB 161.48 MiB 0 B 0.00%
gzip rootfs 62.54 MiB 62.55 MiB +6.40 KiB +0.009986%

Startup latency and PSS

Case Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta
Serve ready 26.87 ms 27.68 ms +0.82 ms 5.44 MiB 4.33 MiB −1.11 MiB
CDP first page 47.94 ms 57.16 ms +9.22 ms 5.08 MiB 3.00 MiB −2.08 MiB
CDP warm page 11.55 ms 13.17 ms +1.62 ms 53.44 MiB 52.15 MiB −1.29 MiB
CLI about:blank 12.70 ms 20.59 ms +7.89 ms 4.78 MiB 3.08 MiB −1.70 MiB
CLI local JS 25.76 ms 25.24 ms −0.52 ms 5.29 MiB 3.29 MiB −2.00 MiB

Concurrency matrix

Concurrency Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta HEAD failures Unstable B/H
1 23.10 ms 24.77 ms +1.68 ms 657.00 KiB 647.00 KiB −10.00 KiB 0 0/0
5 27.40 ms 26.62 ms −0.78 ms 12.05 MiB 29.26 MiB +17.21 MiB 0 0/0
10 27.12 ms 29.76 ms +2.65 ms 11.51 MiB 12.32 MiB +835.50 KiB 0 0/0
25 27.43 ms 29.47 ms +2.04 ms 15.77 MiB 12.87 MiB −2.90 MiB 0 0/0
100 28.68 ms 29.87 ms +1.19 ms 12.97 MiB 12.78 MiB −193.75 KiB 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 10m 2.15s
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 5.26 ms 104.43 ms
Chromium 8 8 47/47 468.97 ms 532.21 ms
Operation p50 Chromium Moli Delta Delta %
navigate 99.73 ms 13.65 ms −86.08 ms −86.31%
observe 3.76 ms 1.79 ms −1.98 ms −52.56%
fill 11.30 ms 4.84 ms −6.46 ms −57.19%
click 35.18 ms 5.35 ms −29.83 ms −84.79%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 69.83 MiB 68.01 MiB 0.97% 47.00% 1 ✅
Chromium 1183.51 MiB 400.48 MiB 1.45% 75.64% 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 29.51 ms 34.30 ms 461.00 KiB
Long-lived CDP session 13 0 21.26 ms 23.98 ms —
CDP smoke — ✅ 120/120 groups passed; 1,798 scenarios

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

Slowest group Scenarios Duration Status
dom-input 62 28.58 s ✅
dom-input 62 28.44 s ✅
scrollbar-visibility 22 28.07 s ✅
scrollbar-visibility 22 28.06 s ✅
fetch-resource-dispatch 72 26.77 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.

@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 878cacb (diff against #2810's fix/resize-observer-layout)

Changes needed (1)

  1. --eval and --dump semantic_tree[_text] still lose content written by a ResizeObserver; regression vs #2810. moli-renderer-v8/src/runtime/page_commands.rs:863-894 flushes the pending frame only for RenderPageDump, SerializeDocument, CaptureScreenshot and PrintToPdf. The fetch CLI reads the DOM through two other commands right after readiness: EvaluateExpression* (page_commands.rs:46-75, reached from moli/src/app.rs:205-218) and AccessibilityTreeNodes (moli/src/fetch_dump/semantic.rs:16-36). Neither gets the flush. Repro: <div id=t style='width:30px;height:10px'></div><p id=o></p><script>new ResizeObserver(()=>{o.textContent='ROTEXT'}).observe(t)</script> as a data: URL. Results from a debug build of this head, with v1.1.23 (microtask delivery, same as #2810) in brackets:

    • --eval 'o.textContent' (default --wait done): "" [ROTEXT]
    • same with --wait load, --wait domcontentloaded, or --layout: "" [ROTEXT]
    • --dump semantic_tree_text, with or without --layout: no ROTEXT [ROTEXT]
    • --dump html, --dump markdown, --eval … --dump html, --wait domstable, --wait networkidle, --delay-ms 50: ROTEXT, OK

    This also makes a single invocation inconsistent: --eval reports the pre-callback DOM, then --dump html shows the callback's output. Web Fetch runs depend on --eval. Smallest fix: run the one-round flush once, where fetch readiness completes (end of ReadinessPlan::wait_for_page, moli/src/app/readiness.rs:86, or one page command issued right after it in app.rs). Do not add it per command. That single call covers eval, the semantic tree and every dump. Putting the flush on EvaluateExpression instead would run a frame before every CDP Runtime.evaluate, which is not frame behavior. The capture-command flushes can stay for CDP clients. Add an --eval case and a semantic_tree_text case to cli_dumps_include_content_written_by_resize_observers.

Checked, no finding:

  • Bounded: deliver_resize_observer_frame drains the queue before it calls any callback. Gathering runs no JS. An observer re-queued by a callback lands in a fresh queue with its own frame timer, so the flush is exactly one round and cannot loop. Each callback goes through invoke_and_report, followed by a microtask checkpoint, and runs before render_page_dump or the serializer starts, so nothing re-enters them. A callback that throws is reported and the dump continues. with_current_main_world_scope never creates a main world.
  • Child frames: --with-frames --dump html with an RO inside an srcdoc iframe contains the child's output on this head, as on v1.1.23. --with-frames --dump markdown misses it on both (0/0), so that gap predates this PR. Acceptable as the disclosed limit.
  • Cost: with nothing queued, the flush is one handle/context scope and one empty-queue pop. The original frame timer then fires as a no-op. The before/after dump timings in the body are plausible.
  • CI: Format, Node, Python and Windows pass. Nextest, Clippy, Build and CDP smoke were still pending at review time.
  • Picture: matches the body's main change, ordering and cost. It does not show the pre-dump flush, which is fine.

@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.

Verification of fdacfc0 (follow-up to the round-3 review)

No blocking findings

The round-3 finding is fixed. One RO delivery round now runs where moli fetch readiness completes (moli/src/app/readiness.rs), so --eval and --dump semantic_tree[_text] include content written by observer callbacks, as on #2810 and v1.1.23. CDP Runtime.evaluate does not run a frame, and the capture-command flushes are skipped inside a debugger pause (nested_main_dispatch_active()).

I re-ran the reviewer's repro (<p id=o> filled with ROTEXT by a ResizeObserver) on a build of this head. --eval 'o.textContent' returns ROTEXT with --wait domcontentloaded, load and done, and also with --layout. semantic_tree_text and --dump html both contain ROTEXT. The delta since 878cacb (12 files, +117/−11) is limited to the readiness flush, the per-Window frame-task flag that prevents doubled timers, and the nested-dispatch guard.

@lanyue-llk
lanyue-llk force-pushed the fix/resize-observer-layout branch from 3397793 to c7fd35f Compare November 13, 2026 12:34
@lanyue-llk
lanyue-llk force-pushed the fix/resize-observer-frame branch from fdacfc0 to 9a87172 Compare November 13, 2026 12:56
@lanyue-llk
lanyue-llk force-pushed the fix/resize-observer-layout branch from c7fd35f to 14bb8f7 Compare November 13, 2026 14:00
@lanyue-llk
lanyue-llk force-pushed the fix/resize-observer-frame branch from 9a87172 to d880a4c Compare November 13, 2026 14:15

@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 d880a4c (own commits only: fix/resize-observer-layout...fix/resize-observer-frame)

Changes needed (1)

  1. Export commands now run page script, which breaks #2836's contract and duplicates the readiness flush. See moli-renderer-v8/src/runtime/page_commands.rs:864 (RenderMarkdown) and :870 (SerializeDocument).
    • Contract. #2836 makes page HTML, the JSON html field and MHTML one projection of the live DOM, with no JavaScript, no frame loads and no yielding. This PR puts author callbacks and microtask checkpoints in front of that projection, inside the same command. The serializer function is still pure, but the export command is not. SerializeDocument is also still listed under "read native document/agent state without entering a new V8 scope" (devtools/command/nested.rs:72), and that comment is no longer true. The new NESTED_MAIN_DISPATCH thread-local (runtime/nested_main.rs:26) exists only to work around this. The flush also runs through with_current_main_world_scope (script_vm/rendering_update.rs:83). That helper is documented as "not a browser task boundary" (script_vm/context_scope.rs:67), so a callback's task-end runtime follow-up, such as a queued navigation or child-frame sync, never has an owner. The PR body says the same about the sibling command.
    • Chromium. CDP Page.captureSnapshot (moli-protocol/src/domains/page/native.rs:109, domains/page/capture.rs:172) now delivers ResizeObserver callbacks. Chromium's MHTML capture does not run an animation frame. The PR itself says Runtime.evaluate does not flush because "CDP clients drive frames themselves", so the two CDP paths now disagree.
    • Redundant, and it breaks frame pacing. moli/src/app/readiness.rs:110 already runs the same one-round flush after readiness for every --wait mode, before any dump or --eval. A CLI dump therefore delivers twice with no frame in between: once at readiness and once at SerializeDocument/RenderMarkdown. On the #2795 feedback-loop fixture (a callback toggles display), moli fetch --dump html runs two callbacks back to back. The dumped display then depends on how many export commands ran, not on frames. Each CDP Page.captureSnapshot call also drives one extra delivery, so a polling client sets the loop's rate instead of the frame timer. The before/after table in the body ("this PR before this fix 3a58b96: missing") was measured before the readiness flush existed. It does not show that the export-command flush is still needed for the CLI.
    • Smallest fix. Remove run_pending_resize_observer_frame() from the RenderMarkdown and SerializeDocument arms. Keep the readiness flush (one explicit step, CLI only). Keep the CaptureScreenshot/PrintToPdf flush only if you want screenshot parity, since Chromium's screenshot does produce a frame. In moli-core/tests/web_apis.rs:1471, wait one frame after runGeometryProbe(), as a CDP client must in Chromium. For example, evaluate new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r))) with await, or call run_pending_resize_observer_frame_async(). Do not make the export do it.

Checked, no finding:

  • Pause and re-entrancy. The only nested consumer is claim_for_pause → dispatch_nested_main_page_command, and it sets the guard. RenderMarkdown/PrintToPdf/RunPendingResizeObserverFrame are V8-entering and are never nested-dispatched. DOM.getOuterHTML/OuterHtmlForDocument/OuterHtmlForNode and the Inspector shadow profiles are untouched.
  • Cost without observers. One V8 context entry and a private-slot pop per export command. It is a no-op when no main world exists.
  • CI. Clippy, Format, the harness tests and Windows pass. Nextest, the CDP smoke test and the release builds were still pending at review time.

@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.

Follow-up review of 17ba647

No blocking findings. Finding 1 from the previous review is resolved.

  • The RenderMarkdown and SerializeDocument arms in page_commands.rs are now byte-identical to the base (14bb8f7718). HTML, MHTML and Markdown exports no longer run any observer delivery. This matches #2836: an export is a projection of the live DOM and runs no JavaScript. CDP Page.captureSnapshot no longer drives deliveries either.
  • The CLI now delivers once, at readiness (readiness.rs:110). The extra back-to-back delivery before an export is gone.
  • The NESTED_MAIN_DISPATCH guard is still needed, and the reason given for it is correct. CaptureScreenshot is classified as PageAgent (devtools/command/nested.rs:75), so claim_for_pause can claim it and run it through dispatch_nested_main_page_command. Without the guard, the screenshot flush would run page script during a debugger pause. PrintToPdf and RunPendingResizeObserverFrame are V8-entering commands and are never dispatched while paused.
  • Keeping the flush before a screenshot or PDF matches Chromium, which produces a frame before capture.
  • In web_apis.rs:1484 the test now calls run_pending_resize_observer_frame_async() explicitly, which stands in for letting a frame pass. That is the right place for this step. The expectations are unchanged.
  • The doc comment in rendering_update.rs now matches the code. No new issues found in this delta.

CI was still running when I checked; Format and Node harness had 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.

1 participant