Skip to content

fix(page): unify document load-delay invalidation - #2802

Merged
ldm0 merged 2 commits into
mainfrom
fix/stop-stylesheet-crash
Nov 15, 2026
Merged

ldm0 merged 2 commits into
mainfrom
fix/stop-stylesheet-crash

Conversation

@lanyue-llk

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

Copy link
Copy Markdown
Contributor

Page.stopLoading ends loading without replacing the current Document. Resource tasks queued before stop now settle their exact load-delay bindings as Invalidated, without asserting or reporting a fresh release.

The Document-owned blocker ledger has a shared Open → Invalidated → Retired lifetime across resource types. Invalidation removes blocking authority while retaining outstanding token/reason identities for idempotent late cleanup. Unknown tokens, mismatched reasons and tokens released before invalidation remain rejected; retirement clears the retained identities. Parser/DCL and Window load still have separate blocking rules.

Stylesheet, image, media and script completions use these shared settlement rules. Callers distinguish an actual release from an invalidated binding, and connected-style tasks report that distinction explicitly. The stylesheet-specific check for a suppressed Document load is removed.

Regression coverage includes all nine delay reasons, repeated invalidation and cleanup, forced initial-empty completion, Document retirement/replacement, and a real VM test asserting one style.onload and no window.onload after stop. Supplemental mutation checks against the core modules fail if invalidation erases token identities or settlement stops checking the reason.

Validation from the repository root:

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run --no-fail-fast — 23,158 passed, 20 skipped.

Network request cancellation, including preventing late CSS responses from applying after stop, remains tracked in #2765.

Closes #2796.
Replaces part of #759.

@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 58037d4

No blocking findings

  • Root cause: fixed. stop_loading_without_load_event (frame_owner_model/records.rs:867-883) clears every blocker and sets load = Suppressed on a Document that stays current. For a main Document, only this path sets Suppressed; records.rs:918 is limited to child documents, and main_document_task_owner_is_current excludes those. So load_was_stopped() used in store.rs:2809-2816 means "Page.stopLoading cleared this token". Any other failed release on a non-stopped Document still reaches the assert at stylesheet_page_tasks.rs:116, so this is narrower than deleting the assert. After the stop, acquire_load_delay rejects a Complete document, and accept_current_main_style_load_event (store.rs:2757-2781) creates token-less bindings, which settle as true. A stale token from before the stop is the only case the new branch handles.
  • All three paths in the issue are covered. On v1.1.23, the /htmllink (streaming HTML with a slow <link>) and /xmlpart (streaming application/xml with the injected viewer <style>) repros each abort at the same stylesheet_page_tasks.rs:117:9, just like /htmldone_link. All three go through settle_main_style_load_event, which this change handles. Only /htmldone_link was verified at runtime with the PR build; the other two are covered by code reading.
  • Load event: after the stop, begin_main_load_dispatch requires Ready, so Suppressed blocks it; the new test checks this. A later navigation creates a new Document record with Pending load. A style task left over from the stopped Document fails main_style_load_event_is_current and takes the ExactBindingRetiredWithDocument path, so it does not reach the new branch.
  • Other settle paths a stop can reach: image, media, stylesheet-subresource and async/deferred script releases have no release-mode assert!/expect on the result. The remaining checks (document_scripts.rs:190,288, document_write.rs:2010) are debug_assert!s on synchronous acquire→reject sequences, so a stop cannot interleave with them.
  • Test: it reproduces the exact sequence (task taken, stop, task applied) and asserts that no window load fires. The negative control described in the body is plausible.
  • Cost: the extra lookup runs only on the path that used to panic, so the numbers are plausible.
  • Body: picture pending. CI: Nextest, CDP smoke and both Build release jobs are still queued; the completed checks pass.

Non-blocking, not caused by this PR: the issue's Chromium expectation also says the stylesheet request ends with Network.loadingFailed net::ERR_ABORTED. Page.stopLoading does not cancel subresource fetches today, so after this fix the stylesheet still arrives and is applied. That gap predates this PR and is not needed to fix the crash, but closing #2796 leaves that part of its Expected section unaddressed. Consider leaving a follow-up note.

@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.00%
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 ✅ 118/118 groups passed; 1,784 scenarios
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ✅ HEAD/base failures 0/0; raw binary 0.00%

Package and image size

Metric Base HEAD Delta Delta %
Raw binary 154.51 MiB 154.51 MiB 0 B 0.00%
Stripped binary 106.92 MiB 106.92 MiB 0 B 0.00%
gzip binary 53.41 MiB 53.41 MiB +327 B +0.000584%
Rootfs 161.42 MiB 161.42 MiB 0 B 0.00%
gzip rootfs 62.51 MiB 62.51 MiB −140 B −0.000214%

Startup latency and PSS

Case Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta
Serve ready 26.96 ms 26.90 ms −0.07 ms 4.79 MiB 4.81 MiB +16.50 KiB
CDP first page 49.19 ms 50.07 ms +0.88 ms 4.91 MiB 4.79 MiB −117.50 KiB
CDP warm page 11.56 ms 11.73 ms +0.17 ms 52.80 MiB 53.23 MiB +442.50 KiB
CLI about:blank 13.70 ms 13.47 ms −0.23 ms 2.86 MiB 4.41 MiB +1.55 MiB
CLI local JS 26.39 ms 26.12 ms −0.27 ms 4.19 MiB 3.87 MiB −319.50 KiB

Concurrency matrix

Concurrency Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta HEAD failures Unstable B/H
1 24.09 ms 24.73 ms +0.64 ms 736.00 KiB 718.00 KiB −18.00 KiB 0 0/0
5 28.18 ms 28.75 ms +0.57 ms 21.96 MiB 11.97 MiB −9.99 MiB 0 0/0
10 28.50 ms 28.33 ms −0.17 ms 12.78 MiB 15.81 MiB +3.02 MiB 0 0/0
25 28.60 ms 28.79 ms +0.19 ms 12.72 MiB 12.78 MiB +53.00 KiB 0 0/0
100 28.02 ms 27.53 ms −0.48 ms 18.29 MiB 12.72 MiB −5.56 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 7m 3.70s
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 28.62 ms 28.86 ms
Chromium 8 8 47/47 261.58 ms 84.47 ms
Operation p50 Chromium Moli Delta Delta %
navigate 42.99 ms 5.72 ms −37.27 ms −86.69%
observe 0.79 ms 0.99 ms +0.20 ms +25.39%
fill 2.89 ms 3.63 ms +0.74 ms +25.68%
click 6.23 ms 3.91 ms −2.32 ms −37.28%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 70.13 MiB 67.23 MiB 0.79% 10.00% 1 ✅
Chromium 1313.72 MiB 325.84 MiB 1.03% 36.27% 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 24.71 ms 25.18 ms 628.00 KiB
Long-lived CDP session 13 0 18.60 ms 19.69 ms —
CDP smoke — ✅ 118/118 groups passed; 1,784 scenarios

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

Slowest group Scenarios Duration Status
dom-input 62 21.75 s ✅
dom-input 62 21.70 s ✅
fetch-resource-dispatch 72 20.75 s ✅
fetch-resource-dispatch 72 20.68 s ✅
scrollbar-visibility 22 19.96 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

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 58da945c9136 → HEAD 9385d1c01a82; benchmark order: head-first; workflow: success.

Public 48-site run · informational

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 184 / 240 184 / 240 0 (0.00%)
Contract fill 76.67% 76.67% 0.00 pp (0.00%)
Sites with rows 38 / 48 38 / 48 0 (0.00%)
Sites meeting row contract 36 / 48 36 / 48 0 (0.00%)
Unexpected empty sites 10 10 0 (0.00%)
Partial-row sites 2 2 0 (0.00%)
Site outcomes extracted: 37; HTTP error + rows: 1; empty: 8; HTTP error + empty: 1; snapshot error + empty: 1 extracted: 36; HTTP error + rows: 2; empty: 8; navigation error + empty: 1; snapshot error + empty: 1 —
Observed duration 49.27 s 71.91 s +22.63 s (+45.93%)
Estimated CPU 44.08 s 45.03 s +0.94 s (+2.14%)
Peak PSS 267.22 MiB 243.12 MiB -24.09 MiB (-9.02%)
Peak RSS 271.34 MiB 246.91 MiB -24.44 MiB (-9.01%)
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 27 / 40 27 / 40 0
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" [1.545, 2.547, 3.048, 4.049, 5.052, 5.553, 7.054, 8.555, 9.557, 11.058, 12.559, 14.061, 15.062, 16.566, 18.069, 19.572, 20.573, 22.076, 23.578, 25.08, 26.085, 27.587, 29.089, 30.591, 31.592, 33.094, 34.596, 36.099, 37.1, 38.603, 40.105, 41.605, 42.606, 44.109, 45.611, 46.112, 47.113, 48.114]
    y-axis "CPU percent" 0 --> 200
    line [103.92, 111.68, 111.89, 107.76, 125.71, 141.88, 91.81, 122.08, 59.8, 139.86, 141.7, 135.99, 115.71, 37.91, 79.88, 135.84, 103.8, 111.79, 135.69, 137.84, 69.45, 95.86, 103.9, 77.95, 143.88, 101.89, 49.96, 71.85, 0, 27.98, 0, 31.98, 65.84, 15.97, 103.85, 153.73, 47.93, 135.67]
Loading
xychart-beta
    title "Base memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.044, 1.545, 2.547, 3.048, 4.049, 5.052, 5.553, 7.054, 8.555, 9.557, 11.058, 12.559, 14.061, 15.062, 16.566, 18.069, 19.572, 20.573, 22.076, 23.578, 25.08, 26.085, 27.587, 29.089, 30.591, 31.592, 33.094, 34.596, 36.099, 37.1, 38.603, 40.105, 41.605, 42.606, 44.109, 45.611, 46.112, 47.113, 48.114, 49.275]
    y-axis "Memory MiB" 0 --> 500
    line [13.88, 96.63, 114.96, 127.5, 127.77, 155.43, 130.95, 151.57, 168.51, 138.25, 142.92, 144.05, 140.02, 119.72, 131.24, 138.95, 149.57, 271.34, 186.66, 167.85, 175.46, 148.21, 156.26, 142.32, 150.41, 186.34, 235.55, 223.91, 234.94, 231.43, 232.57, 231.73, 229.02, 258.37, 136.17, 168.64, 151.86, 136.95, 165.3, 0]
    line [10, 92.54, 111.02, 123.58, 123.74, 151.37, 126.99, 147.48, 164.48, 134.12, 138.75, 139.48, 135.05, 115.51, 127.07, 134.54, 145.51, 267.22, 182.54, 163.77, 171.5, 143.95, 152.01, 138.19, 144.34, 182.07, 231.84, 219.68, 230.71, 227.22, 228.59, 227.79, 225.1, 254.6, 132.42, 165.08, 148.18, 133.56, 161.72, 0]
Loading

HEAD

xychart-beta
    title "HEAD CPU"
    x-axis "Elapsed seconds" [2.058, 3.56, 4.061, 5.063, 6.064, 8.067, 10.07, 12.072, 14.075, 16.078, 18.082, 20.085, 22.087, 24.089, 26.09, 28.092, 30.095, 32.098, 33.6, 34.101, 36.104, 38.108, 40.111, 42.112, 44.114, 46.116, 48.118, 50.12, 52.123, 54.125, 56.128, 58.132, 60.137, 62.14, 64.143, 66.145, 68.147, 70.15]
    y-axis "CPU percent" 0 --> 200
    line [115.78, 133.74, 83.84, 151.63, 133.93, 141.68, 131.91, 133.91, 99.76, 87.96, 99.88, 101.93, 105.99, 119.8, 127.87, 107.85, 89.88, 43.93, 113.78, 103.85, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 1.99, 0, 9.99, 101.9, 109.87, 101.88]
Loading
xychart-beta
    title "HEAD memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.056, 2.058, 3.56, 4.061, 5.063, 6.064, 8.067, 10.07, 12.072, 14.075, 16.078, 18.082, 20.085, 22.087, 24.089, 26.09, 28.092, 30.095, 32.098, 33.6, 34.101, 36.104, 38.108, 40.111, 42.112, 44.114, 46.116, 48.118, 50.12, 52.123, 54.125, 56.128, 58.132, 60.137, 62.14, 64.143, 66.145, 68.147, 70.15, 71.909]
    y-axis "Memory MiB" 0 --> 500
    line [13.91, 99.9, 117.61, 118.73, 144.2, 145.61, 138.05, 143.04, 134.24, 128.22, 122.67, 154.3, 148.84, 246.77, 129.18, 143.04, 137.53, 130.2, 137.77, 246.91, 244.66, 223.89, 231.21, 232.22, 230.93, 230.95, 230.91, 230.95, 230.94, 230.97, 230.36, 229.84, 229.86, 229.82, 229.82, 143.82, 160.89, 166.58, 150.38, 0]
    line [10.51, 96.26, 112.96, 114.97, 140.61, 141.95, 134.52, 139.39, 130.9, 124.39, 118.94, 150.57, 145.06, 242.43, 125.73, 139.68, 133.79, 126.48, 134.05, 243.12, 240.91, 220.12, 227.56, 228.57, 226.66, 226.68, 226.65, 226.69, 226.68, 226.72, 226.11, 225.59, 225.62, 225.56, 225.57, 139.56, 156.63, 162.37, 146.07, 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.87 s 19.86 s -0.01 s (-0.04%)
Estimated CPU 0.43 s 0.42 s -0.01 s (-2.54%)
Peak PSS 69.93 MiB 69.96 MiB +0.03 MiB (+0.05%)
Peak RSS 73.55 MiB 73.59 MiB +0.05 MiB (+0.06%)
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

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 58da945c91 → HEAD 9385d1c01a; benchmark order: head-first; workflow: success.

Session resilience

Metric Base HEAD
Attempted / planned 200 / 200 200 / 200
Direct observable pass 196 / 200 197 / 200
Failures / recovered 4 / 4 3 / 3
Recovery failures 0 0
Lifecycle order violations 0 0
Network order violations 0 0
Wall time 656.9 s 611.5 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 304.4 MiB 282.1 MiB -22.3 MiB
Periodic peak PSS 300.9 MiB 279.3 MiB -21.6 MiB
RSS · first 10 avg 174.0 MiB 175.7 MiB +1.8 MiB
RSS · last 10 avg 200.8 MiB 199.2 MiB -1.6 MiB
RSS · last − first window +26.8 MiB +23.4 MiB -3.4 MiB
RSS · warm slope / 100 nav +9.0 MiB +6.1 MiB -2.9 MiB
PSS · first 10 avg 170.4 MiB 172.6 MiB +2.3 MiB
PSS · last 10 avg 197.4 MiB 195.6 MiB -1.8 MiB
PSS · last − first window +27.1 MiB +23.0 MiB -4.1 MiB
PSS · warm slope / 100 nav +9.2 MiB +6.1 MiB -3.1 MiB
Peak file descriptors 66 66 0
Peak threads 33 33 0

HEAD memory by 50-navigation quarter

HEAD range Avg RSS Final RSS Peak RSS Avg PSS Final PSS Peak FD
1–50 183.2 MiB 153.5 MiB 219.2 MiB 179.7 MiB 150.1 MiB 56
51–100 187.8 MiB 222.6 MiB 222.6 MiB 184.5 MiB 219.2 MiB 61
101–150 188.8 MiB 158.6 MiB 225.4 MiB 185.4 MiB 155.1 MiB 57
151–200 193.3 MiB 216.0 MiB 236.6 MiB 189.8 MiB 212.5 MiB 56

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.

@lanyue-llk
lanyue-llk force-pushed the fix/stop-stylesheet-crash branch from 006072b to 9385d1c Compare November 13, 2026 13:39
@ldm0 ldm0 changed the title fix(page): settle stylesheet load tasks after Page.stopLoading fix(page): unify document load-delay invalidation Nov 15, 2026
@ldm0
ldm0 merged commit 39099d9 into main Nov 15, 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.

Page.stopLoading while a stylesheet is loading crashes moli serve (panic: a current connected style event must release its exact load-delay binding)

2 participants