Skip to content

Add three-way runtime accuracy capture and text-layout fixes#1

Open
rajatady wants to merge 14 commits into
mainfrom
codex/rendering-dom-parity
Open

Add three-way runtime accuracy capture and text-layout fixes#1
rajatady wants to merge 14 commits into
mainfrom
codex/rendering-dom-parity

Conversation

@rajatady
Copy link
Copy Markdown
Owner

Summary

  • add a three-way accuracy pipeline that captures browser oracle, browser Rendero/WASM, and native headless outputs together
  • fix several text-pipeline and layout-input bugs that were distorting wrapped text and block text containers
  • refresh generated benchmark artifacts so the branch has a reproducible parity snapshot

What changed

  • added native benchmark capture and triple comparison tooling in scripts/capture-native-truth.py, scripts/compare-runtime-triple.py, and scripts/run_accuracy_suite.sh
  • changed block text elements in the DOM shim so p/h1/h2/etc. stay frame-backed and pass text styling down to child text nodes instead of collapsing layout props onto a single text node
  • added text-size locking in wasm/native/ffi so explicit text sizes are distinguished from measured layout results
  • improved wrapped/min-content measurement behavior in the browser measurer, shared heuristic path, and Parley-backed text measurer
  • fixed default flex cross-axis stretching in the shim auto-layout translation so block text containers receive the expected available width
  • updated renderer font fallback resolution and refreshed benchmark outputs under accuracy/

Current measured baseline

  • Apple page accuracy: 44.86% (192/428)
  • Native accuracy: 7.94% (34/428)
  • WASM vs native accuracy: 10.42% (45/432)
  • Synthetic corpus accuracy: 83.41% (377/452)

Notes

  • this PR includes the benchmark artifacts needed to inspect the current browser/WASM/native parity state directly
  • local-only files were intentionally excluded: accuracy/serve.log, .codex/, accuracy/apple-native.ppm, and accuracy/apple-native.raw.json

rajatady and others added 14 commits March 29, 2026 16:39
…ut, ScrollView

Builds React Native's architecture layer by layer on top of the Rendero engine:
- rendero-ui.js: imperative host (UIManager equivalent) with TextInput support
- renderer.js: React reconciler with useState, tree diffing, event bubbling
- app.js: declarative components with htm for JSX-like syntax

Features: controlled TextInput (text/email/password/tel), ScrollView (camera-based),
component composition, screen navigation with state persistence, reconciler ops log.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ents

- esbuild build pipeline: src/App.jsx → app.js (JSX → h() calls)
- Yoga layout algorithm visualizer with 5 interactive examples
- Case-insensitive host component types (frame/Frame both work)
- Input overlay positioning synced with canvas coordinates
- Gallery component demonstrating .map() and composition
- ScrollView with wheel + touch scrolling
- Cursor changes on hover over interactive elements

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- add a pure-Rust native shell host with QuickJS runtime, bridge traits,
  engine dispatch, headless frame dumping, and Codex-branded app title
- add a native FFI crate and keep the Swift shell as a legacy/reference path
- introduce a DOM-shim app surface for React/Vue with browser and native
  entries, browser/native engine adapters, and a shared Rendero namespace
- formalize swappable runtime and platform seams with JSRuntime, NativeAPI,
  provider-based layout, and browser/native engine-runtime dispatch
- upgrade core layout to support provider-based Taffy layout, margins,
  justify-content, wrap, layout position, size constraints, and sizing modes
- thread the richer layout/style surface through WASM and native bindings
- fix browser Rendero startup by eliminating stale wasm/cache issues,
  adding panic reporting, and resolving text-node parenting crashes
- improve browser Rendero fidelity by fixing viewport resolution,
  background gradient propagation, text-backed element handling, and
  auto-layout/container sizing behavior
- add an automated verification workflow that builds DOM-shim bundles,
  rebuilds wasm into docs/pkg, serves with no-cache behavior, captures
  browser screenshots with Playwright, and dumps native headless frames
- add scripts and config for repeatable parity checks across React Web,
  React Rendero in browser, and the native Rendero host

Current verified state:
- React Web is the visual reference baseline
- React Rendero in browser now renders instead of blanking/crashing
- native Rendero renders through the new Rust host and headless dump path
- parity is improved but still incomplete; remaining gaps are scroll behavior,
  layout fidelity, spacing/padding, gradients, and native style bridging
- add docs/project/codex-current-state.md to preserve the current working state before integrating newer poc/rendering-dom history
- forward native DOM-shim style props for fontFamily, textAlign, stroke, rotation, shadow, and linearGradient
- add shared browser/native scroll synchronization and record scrolled-state verification artifacts
- fix native wheel scroll direction in the Rust host
- extend capture_dom_shim.py to verify both top-of-page and scrolled parity states
- keep the current system-font text renderer experiment staged as part of the snapshot
Documents what renders today (TestApp perfect, Apple partial), the single
blocking issue (style.js height resolution), 5 short-term fixes ordered by
impact, and a table of 7 bugs found and fixed during development.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…docs updates

- sync all file content changed on poc/rendering-dom after a8da30d into the
  codex integration branch, using direct file reconciliation instead of replaying
  the divergent upstream commit history
- pull in the Lightning CSS and Parley-based infrastructure by adding the new
  css and text crates plus the related workspace/Cargo wiring
- bring over the browser text measurement oracle work, viewport-aware layout
  updates, and the removal of earlier heuristic text-size overrides
- sync the latest renderer text changes, including system font resolution
  through fontdb and updated text measurement/rendering behavior
- update native shell, native FFI, wasm bindings, and DOM-shim files to match
  the current poc/rendering-dom runtime/layout/text pipeline
- sync the latest project documentation, including current-status, architecture
  notes, runtime docs, commands, renderer/core docs, and AGENTS/CLAUDE files
- sync verification and capture tooling, including layout/oracle scripts and
  corpus/accuracy artifacts used to compare browser truth against Rendero output
- pull in project assets, pkg output, native Swift reference shell updates, and
  demo data needed by the latest branch state

Integration notes:
- this commit preserves the codex branch history while aligning file content
  with the latest poc/rendering-dom worktree state
- upstream intent comes from these integrated changesets:
  - Add current-status.md — blocking issues, runnable path, bugs found
  - Add Lightning CSS, Parley text, layout oracle, merge codex rendering fixes
  - Browser text measurement oracle, viewport-aware layout, remove heuristic overrides
  - Wire system font resolution into renderer via fontdb
  - later docs refreshes for AGENTS/CLAUDE and architecture state

Result:
- the integration branch now matches poc/rendering-dom for the synced file set
- cargo check passes on the reconciled workspace
- this becomes the new baseline for continuing parity, layout, text, and native/browser work
…docs

- add a deterministic layered benchmark pipeline that captures browser oracle, shim normalization, engine command traces, engine model, and engine layout artifacts for the Apple demo and synthetic corpus
- add repeatable accuracy automation with run_accuracy_suite.sh, layout corpus capture, refreshed comparison outputs, and updated dashboard/summary artifacts
- improve the shared translation layer by carrying margin:auto through LayoutMargin auto-edge flags and by carrying parent-relative percentage sizing through the node model, wasm bridge, native bridge, and Taffy mapping instead of collapsing widths to the viewport
- extend the browser and native engine bridges to expose the richer layout contract, including sizePercent and the updated margin dispatch surface
- route native scrolling through the shared window/shim scroll path instead of directly mutating camera state in the host, and align the native desktop baseline to 1440x900 for apples-to-apples parity work
- refresh browser/native entry metadata so viewport and DPR information are synchronized from the host contract used by the parity pipeline
- update AGENTS and project documentation to match the current architecture: browser DOM as oracle, browser Rendero/WASM as a first-class parity surface, pure-Rust QuickJS native shell, current benchmark baselines, and the remaining tracked shortcuts/debts
- record current shortcuts separately in parity-shortcuts.md so temporary parity concessions are explicit and removable later

Current measured baseline in this snapshot:
- Apple page accuracy: 57.01% (244/428)
- Synthetic layout corpus: 83.85% (379/452)

Primary remaining gaps after this commit:
- root/document height propagation
- fixed/root offset behavior
- constrained text measurement in cards and feature copy
- live native/browser visual parity validation beyond headless capture
…ng layout

DELIBERATE EXCEPTION: On WASM, text measurement delegates to the browser's
canvas.measureText() via wasm-bindgen, because there is no API to extract
font bytes from the browser for Parley/Fontique. This is the ONLY place
where measurement differs between platforms. Font rendering will converge
to a single Parley pipeline once font loading is implemented.

On native: ParleyTextMeasurer (system fonts via Fontique)
On WASM: BrowserTextMeasurer (browser canvas.measureText)
Same TextMeasurer trait, same Taffy layout pipeline.

Lives in rendero-wasm (not rendero-text) because it depends on web-sys
and wasm-bindgen — platform-specific browser APIs that don't belong in
the platform-agnostic text crate.

Accuracy: 22% (Parley-only with wrong fonts) → 38.6% (browser measurer)
Height avg diff: 49px → 12px, width mismatches: 84 → 42

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per CSS spec, flex:<number> sets flex-basis to 0%, not auto.
- flex:'1' → grow=1, shrink=1, basis=0% (equal space distribution)
- flex:'none' → grow=0, shrink=0, basis=auto
- flex:'auto' → grow=1, shrink=1, basis=auto

This fixes feature cards in the Apple demo — 3 cards now divide
the row equally instead of sizing to content width.

Visible on native: "Why Apple" section now shows all 3 feature
columns (Apple Intelligence, Privacy, Environment).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Container size now comes from node.width/height directly, same as any node.
This decouples container sizing from item sizing in the Taffy layout path.

AutoLayout.primary_sizing/counter_sizing still exist on the struct for
backwards compat with legacy layout and CRDT ops, but the Taffy path
(which is the primary layout engine) no longer reads them. Item sizing
flows through node.horizontal_sizing/vertical_sizing independently.

This is the minimal fix for the container/item conflation identified
in the Figma AutoLayout model. A full struct rename to FlexLayout was
attempted but caused too many breakages — this targeted change achieves
the same decoupling with 1 file changed instead of 11.

Score unchanged at 38.6% — the feature card width inequality is caused
by min-content sizing (text width varies per card), not by container/item
conflation. This is correct CSS behavior that improves as text measurement
accuracy improves.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- normalize browser-engine capture into the same surface coordinate space as the browser oracle so fixed-position comparisons use the same origin
- translate browser Rendero fixed-position nodes relative to the viewport instead of the internal render surface
- stop reusing prior computed container sizes as new authored layout inputs in the Taffy path, write root layout size back, and add a bottom-up frame-height safeguard
- keep the BrowserTextMeasurer WASM path and refreshed browser text/layout artifacts in sync with the latest benchmark run
- refresh the Apple and synthetic accuracy artifacts plus corpus dashboard outputs to the current baseline
- update AGENTS and the project architecture/status docs to reflect the current 60.98% Apple and 83.19% synthetic baseline, the deliberate WASM/native text-measurer split, the fixed-position correction, and the remaining constrained-text/page-height gaps
- add native capture and browser/wasm/native triple comparison to the accuracy suite\n- record browser oracle, Rendero browser, and native headless artifacts in the benchmark output\n- split block text elements away from single text-node rendering so layout props stay on frames and text styles flow to child text nodes\n- add text size locking so explicit text sizes are distinguished from measured layout results across wasm, native shell, and ffi paths\n- improve shared text measurement handling for wrapped/min-content cases in wasm, core heuristics, and Parley-backed measurement\n- fix default flex cross-axis stretching in the shim auto-layout translation so block text containers receive the expected available width\n- refresh font fallback resolution and accuracy artifacts for the current text/layout debugging baseline
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