Repository navigation
fix(dump): keep media sources and sanitized range/color values in markdown - #2813
Conversation
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review of 1eae6db
Changes needed (1)
-
#2773 is fixed in the Markdown pass, not at its root cause (
moli-renderer-v8/src/runtime/page_dump/visibility.rs:241-254). Issue #2773 gives the root cause:style_engine/ua/html.css:255-256putssourcein the UAdisplay: nonelist. Chromium and the HTML rendering section have no such rule; Chrome reportsgetComputedStyle(source).display === "inline", while moli reportsnone. The PR keeps that rule and adds an exception keyed on the parent tag in the Markdown visibility pass. As a result:getComputedStyle(source).displaystill differs from Chrome, so scripts and CDP clients that read it still seenone.- Any other consumer that drops
display: nonenodes still loses media sources. - Every node in every Markdown dump now gets a tag compare, including pages with no media.
Smallest fix: delete
sourcefromhtml.css:256and drop bothvisibility.rshunks. Keep the new test rows; they should pass unchanged. A<source>inside adisplay: nonevideo stays suppressed through the existing parent rule (visibility.rs:255-257).<picture><source srcset>is safe because html2md already reads it through the<img>and tolerates visible sources (moli-html2md/tests/regressions.rs:509);resource_url_attributes("source")resolves onlysrc.<source>is a void element andvideo/audioare replaced media (layout_renderer/source_view.rs:606-607), so layout gains no visible box. Check one<picture>layout snapshot or test when making the change.
Checked, no issue:
- Range/color (#2774): the sanitized
input_value()is exported only whenvalueis present and non-empty (visibility.rs:173-175). That gives the issue'sVolume 100 Tint #ff0000 50exactly. Absent and emptyvaluekeep the previous output (thevalue=''row). Other input types and dirty controls take the same path as before. The extra attribute read only happens for range/color inputs. - With the current approach,
<source>inside adisplay: none<video>stays hidden through the parent-suppressed check.<track>is not in the UA hidden list and html2md does not consume it, so nothing changes. Leaving<picture>out is consistent because html2md does not read<source srcset>. - Tests: both new rows fail on main (fallback text;
150 #FF0000). - CI at this head: Format, Clippy, Node, Python and Windows checks pass. Nextest, CDP smoke and both release builds are still pending.
- Picture: pending.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review of 3745d4a
No blocking findings
Round 1 is addressed. source is gone from the UA display: none list (style_engine/ua/html.css:255-256), and both visibility.rs media-source hunks are dropped. Against 1eae6db, the only other change is one extra test row. This matches Chromium's UA sheet and the HTML rendering section, and it fixes getComputedStyle(source).display for every consumer, not only Markdown. It is the simplest fix for moli.
What I checked for code that depended on source being display: none:
- Accessibility:
moli-dom/src/accessibility/ax_projection.rs:317-334excludessourceby tag, not by style, so the AX tree is unchanged. - innerText:
video/audioignore their DOM children (native_bridge/element/content.rs:528-543), so their sources were never read. A stray<source>is empty and not an atomic inline, so it adds no text or separator. The result is the same as in Chrome. - Layout, hit testing and screenshots: media is replaced (
layout_renderer/source_view.rs:607,dom_presentation.rs:98), so a source inside it gets no box. A source in<picture>or a stray one becomes an empty inline. Whitespace collapsing works across inline boundaries, and an empty inline adds no line height, so<picture>\n <source>\n <img>keeps the same collapsed whitespace and line boxes as in Chrome. I found no Rust copy of the UA hidden list that would also need the change. - html2md:
sourceis not instructure.rs::is_block.media.rs:269-292is the only consumer ofsource, and it reads the children of video/audio. SoA<source>BstaysAB,<picture>exports only its<img>, and video sources are not emitted twice. Thevisibility.rsboundary logic treatsinlineas a non-boundary. - Hidden media: a source inside a
display: nonevideo stays suppressed through the parent rule (visibility.rs:244-246). The new row covers this. - Mock geometry (default CLI without
--layout): a<source>now counts as one 24 px mock flow step, like any other rendered element (geometry/mock/layout.rs:177). This is within the mock's stated approximation and does not affect Markdown output. - Range/color: unchanged since round 1 and still correct (
visibility.rs:171-175). - Tests: the
<video>/<audio>source row fails on main (fallback text), and the range/color rows fail on main (abc invalid,150 #FF0000). - CI at this head: Format, Node, Python and Windows pass. Nextest, Clippy, CDP smoke and both release builds are still pending.
- Body: has
Closes #2773, closes #2774and a correct title. The before/after picture matches the issue's expected output. The Cost table is plausible for a one-selector CSS change plus one attribute read.
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 Public 48-site run · informational
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 timelinesThese 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. Basexychart-beta
title "Base CPU"
x-axis "Elapsed seconds" [1.035, 1.536, 2.537, 3.54, 4.041, 5.543, 6.543, 8.045, 9.546, 10.547, 12.049, 13.55, 14.551, 16.054, 17.555, 18.557, 20.058, 21.562, 22.562, 24.064, 25.564, 26.565, 28.067, 29.57, 30.571, 32.073, 33.573, 34.573, 36.075, 37.577, 38.578, 40.08, 41.581, 42.581, 44.083, 45.583, 46.584, 47.588]
y-axis "CPU percent" 0 --> 200
line [15.99, 121.88, 107.8, 91.74, 113.79, 141.75, 102.04, 149.58, 65.93, 69.91, 89.95, 5.99, 5.99, 0, 141.91, 119.94, 53.9, 3.99, 83.95, 97.96, 101.94, 107.96, 117.93, 115.81, 77.9, 43.93, 56.01, 119.96, 57.93, 117.79, 99.88, 85.91, 3.99, 48, 109.9, 44.01, 121.8, 169.87]
xychart-beta
title "Base memory: RSS then PSS"
x-axis "Elapsed seconds" [0.035, 1.035, 1.536, 2.537, 3.54, 4.041, 5.543, 6.543, 8.045, 9.546, 10.547, 12.049, 13.55, 14.551, 16.054, 17.555, 18.557, 20.058, 21.562, 22.562, 24.064, 25.564, 26.565, 28.067, 29.57, 30.571, 32.073, 33.573, 34.573, 36.075, 37.577, 38.578, 40.08, 41.581, 42.581, 44.083, 45.583, 46.584, 47.588, 47.956]
y-axis "Memory MiB" 0 --> 500
line [13.54, 77.43, 101.23, 108.01, 110.95, 138.62, 144.34, 133.21, 154.92, 135.66, 144.04, 144.98, 120.27, 122.85, 123.71, 140.39, 140.07, 129.09, 122.37, 140.74, 144.36, 167.98, 181.37, 161.76, 150.44, 178.79, 134.13, 139.14, 144.91, 143.65, 200.78, 246.2, 182.21, 132.33, 144.61, 176.41, 142.99, 167.78, 166.93, 0]
line [10.27, 74.07, 97.83, 104.59, 107.53, 135.23, 140.85, 129.74, 151.46, 132.81, 140.53, 141.54, 116.8, 119.37, 120.24, 136.93, 136.66, 125.62, 118.79, 137.61, 140.14, 164.89, 177.94, 158.36, 147.02, 175.53, 130.78, 135.82, 141.47, 141.24, 197.44, 242.75, 178.75, 128.91, 142.19, 173, 139.54, 164.16, 163.4, 0]
HEADxychart-beta
title "HEAD CPU"
x-axis "Elapsed seconds" [1.038, 2.039, 2.539, 3.541, 4.541, 5.543, 7.045, 8.046, 9.047, 10.048, 11.549, 12.051, 12.551, 13.551, 14.553, 16.055, 17.057, 18.057, 19.058, 20.561, 21.562, 22.563, 23.565, 25.067, 26.068, 27.068, 28.07, 29.572, 30.573, 31.575, 32.575, 34.078, 35.078, 36.08, 37.081, 37.581, 38.581, 39.583]
y-axis "CPU percent" 0 --> 200
line [39.95, 104.01, 128.04, 117.77, 135.84, 131.62, 145.63, 125.89, 135.92, 127.95, 51.88, 1.99, 31.99, 77.98, 149.68, 15.99, 1.99, 43.96, 91.86, 105.89, 113.88, 103.88, 101.92, 111.83, 145.81, 105.93, 101.8, 95.9, 7.99, 67.88, 125.89, 11.98, 18.01, 101.76, 115.97, 157.95, 44, 111.77]
xychart-beta
title "HEAD memory: RSS then PSS"
x-axis "Elapsed seconds" [0.037, 1.038, 2.039, 2.539, 3.541, 4.541, 5.543, 7.045, 8.046, 9.047, 10.048, 11.549, 12.051, 12.551, 13.551, 14.553, 16.055, 17.057, 18.057, 19.058, 20.561, 21.562, 22.563, 23.565, 25.067, 26.068, 27.068, 28.07, 29.572, 30.573, 31.575, 32.575, 34.078, 35.078, 36.08, 37.081, 37.581, 38.581, 39.583, 40.443]
y-axis "Memory MiB" 0 --> 500
line [13.57, 88.16, 109.14, 114.63, 117.62, 153.89, 130.76, 152.85, 155.96, 155.4, 165.11, 120.18, 121.12, 123.63, 128.22, 144.2, 121.3, 126.07, 132.55, 149.18, 121.9, 188.98, 265.21, 190.39, 135.77, 142.56, 140.76, 135.69, 142.96, 131.44, 151.33, 210.48, 146.7, 133.77, 161.23, 176.07, 147.93, 134.72, 151.08, 0]
line [10.34, 84.83, 105.71, 110.32, 114.19, 150.58, 128.25, 149.48, 152.68, 151.97, 161.76, 116.69, 117.7, 120.23, 124.99, 141, 118.04, 122.82, 129.3, 145.88, 119.58, 185.74, 261.5, 187.19, 132.5, 139.53, 137.57, 132.48, 139.78, 128.24, 148.28, 207.29, 143.47, 130.54, 158.36, 173.44, 144.88, 131.52, 147.85, 0]
Deterministic fixture · required contractThe fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.
Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full 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. |
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 Common ancestor Session resilience
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
HEAD memory by 50-navigation quarter
Raw reports and per-navigation boundary samples: workflow run and full Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold. |
CI Regression ReportSource CI run · source state at render:
Release regression — ✅ HEAD/base failures 0/0; raw binary 0.00%Package and image size
Startup latency and PSS
Concurrency matrix
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
CDP smoke — ✅ 116/116 groups passed; 1,680 scenariosWorkers: 4 · cumulative group time: 473.60 s · failed groups: 0
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Frozen HTML · Linux · Diagnostics: All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable. |
3745d4a to
ac77917
Compare

**Track:** Web Fetch (Browser Eval). Replaces part of #1592.Closes #2773, closes #2774.
Replaces part of #1592.
Problem.
moli fetch URL --dump markdownhad two problems:--dump markdowndrops<video>/<audio><source>URLs and prints the fallback text instead #2773). It dropped every<video>/<audio><source>URL and printed the media element's fallback text ("Sorry, your browser doesn't support embedded videos.") instead.--dump markdownprints raw<input type=range|color>value attributes instead of the sanitized value #2774). It printed the rawvalueattribute of<input type=range|color>(150,#FF0000,abc) instead of the sanitized value the control actually holds..valuereturns100,#ff0000and50.Repros are the fixtures in the issues (
v.html,r.html).Reproduce (steps from #2773, #2774)
From #2773:
Expected
Chromium plays the media from its
<source>children (video.currentSrcis…/a.webm) and never shows the fallback text. moli-html2md produces exactly this for the same HTML in its own unit tests:Actual
All source URLs are lost and the fallback text is printed. In moli,
getComputedStyle(source).displayisnone; in Chrome it isinline.From #2774:
moli fetch http://127.0.0.1:8000/r.html --dump markdown moli fetch http://127.0.0.1:8000/r.html --eval "JSON.stringify([...document.querySelectorAll('input')].map(i=>i.value))"Expected
The Markdown reports the value each control actually holds after HTML value sanitization. That is what
.valuereturns in both Chrome and moli:["100","#ff0000","50"].Actual
The
--evaloutput on the same page is["100","#ff0000","50"]. Number and date inputs already use the sanitized value; only range and color do not.Change.
--dump markdowndrops<video>/<audio><source>URLs and prints the fallback text instead #2773.style_engine/ua/html.csslistedsourceamong thedisplay: noneelements. Chromium's UA sheet has no such rule;getComputedStyle(source).displayisinlinethere. The Markdown view suppresses everydisplay: nonenode, so html2md's media handling never saw the sources and fell back to the element's other children. Removingsourcefrom that list fixes the root cause and the computed style. A<source>is an empty element: it adds no text, and its media orpictureparent still decides what is rendered. A source inside a hidden<video>still disappears with its parent.--dump markdownprints raw<input type=range|color>value attributes instead of the sanitized value #2774.runtime/markdown_dump/visibility.rs: range and color inputs skipped the live (sanitized) value unless the user had edited them, so html2md read the raw attribute. They now export the sanitizedinput_value()whenever an authorvalueattribute is present and non-empty. An absent or emptyvaluekeeps the existing output, which thevalue=''test row covers.Verification.
The branch output matches the issue's expected text exactly.
pic.html):<source>inside adisplay:none<video>stays out of the Markdown;<source>inside a<p>adds no text (Body text);<picture><source srcset><img>still exports only the image;--layout --dump screenshotof the page is byte-identical to main's;getComputedStyle(source).displayis nowinline, and a stray source is an empty inline box (0 px wide).markdown_live_structure_and_visibility_have_exact_outputs(page_vm/tests/markdown_dump.rs) changes"abc invalid"to"50 #000000". It also gains avalue=150/#FF0000row, a<video>/<audio><source>row, and a row covering a hidden video's source, a stray source and a<picture>.cargo nextest run -p moli-renderer-v8 -E 'test(markdown) | test(picture) | test(source) | test(media) | test(ua_)': 1187 passed.cargo fmt --allclean;cargo clippy -p moli-renderer-v8 --all-targets --all-features -- -D warningsclean (workspace clippy not run locally).Cost. The UA-sheet change removes a selector from one rule, and the range/color change is one attribute read per such input in the existing Markdown pass. No layout or style work is added. The debug builds compared are main cbf4d01 and this branch (on a newer main), same profile,
/usr/bin/time -l, alternating runs, median of 7:--dump markdown--dump markdown--dump markdown--layout --dump screenshot