Repository navigation
feat: decline a page that would cross Android's painted-element ceiling - #236
Conversation
Lynx on Android charges one JNI global reference per painted element and its table holds max=51200; the ART dump at the crash attributes the entries to Lynx's PaintingContext. Crossing it aborts the process with a SIGABRT that carries no JavaScript cause, so a page that paints too much dies without ever saying why, and every framework in the cross-framework native matrix DNFs at eager 10k for the same reason. The host driver now takes a paintedElementCeiling and projects what a mount would paint before painting any of it: - the first-screen direct applier accumulates the projection in the pre-walk that already runs before anything is created, and refuses over the line with a LynxFirstScreenRefusalError, so the page falls back to the command path rather than being half painted; - prepareLynxHostBatch walks the batch before its first command runs and rejects the commit, which leaves the tree the previous commit left and puts the reason on the wire. The projection is net rather than gross, so a commit that retires a run and mounts its replacement holds the survivors instead of the sum. A declared native-list row costs nothing: the platform materializes a cell through componentAtIndex when it is about to show it, so counting a deferred run would refuse the very <list> the diagnostic recommends. installLynxMainThread derives the default from SystemInfo.platform, which is the only place that knows which engine is running. Android gets the ceiling; iOS, Lynx-for-Web, and an engine that reports no platform get none, because only Android's reference table charges per painted element. An explicit number sets it on any platform and null turns it off. Refs #234 Part C, #193. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
|
Repo-wide Two notes on what the scoped tooling reports, so a reviewer running it does not read them as this diff's:
Generated by Claude Code |
Gate finding — bounced from this train: the projection refuses the very page its diagnostic recommendsHigh review on the merged train found the ceiling projection counts every plain Consequences, both directions:
The fix is a membership-aware projection: count a Your adversarial review caught three defects of exactly this class before the PR went up; this is the fourth, one layer deeper (batch-composed lists rather than command-shape carve-outs). Same standard: the guard re-enters the next train once the projection matches the painter. Everything else in the train merged. Generated by Claude Code |
The gate on the merged train found this guard refuses the one page shape its own diagnostic recommends. The projection counted every plain `create`, but the applier skips materialization for a create whose record is a direct native-list item with an unattached cell: the row exists logically and the platform builds it later, through `componentAtIndex`. Only `mount-template-run` with `deferred: true` announces that shape in the command itself. A native list composed the ordinary way is `create list`, `create list-item`, subtree `create`s and `insert`s, and no single one of those commands says the row will not paint. So a 46,000-row native-`<list>` page over the command path projected 46k+ painted elements and was refused with a diagnostic telling the author to use a native `<list>`. The other direction was an under-guard: `projected` starts from `ownedNodes.size`, the painted reality, so decrementing for a row that was never painted handed the batch headroom it never occupied. A commit retiring declared rows while creating real views could cross the real JNI table unrefused. The projection now mirrors the applier's own predicate rather than approximating it. Membership resolves transitively over the batch's create types and insert parentage joined with accepted records, because the list, the item and the subtree may all be created in the same commit; a pre-pass makes that readable before the first create is counted. A `destroy` decrements only for a host that has an element, and a `destroy-run` over a deferred run releases the attached cells rather than the declared count. The direct applier's pre-walk twin was audited and needed no change: its `insideList` flag is already sticky across the whole subtree under a `<list>`, so it never counted a deferred row. Red-verified: forcing every create to count breaks the native-list page test, and making `destroy` decrement unconditionally breaks the masked-growth test and only that one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019RsC3U39kUuLKajZANeTVy
Gate answered — the projection now mirrors the applier's predicate, and the twin needed no changePushed The false refusalThe projection counted every plain The fix mirrors One detail worth recording, because it decided the pre-pass's shape: the applier resolves membership against The under-guard
The twin: audited, no change neededThe direct applier's pre-walk was already membership-aware. Its There is one asymmetry, and it is benign: the pre-walk excludes everything under a Red-verified
The second probe is the one that matters: it breaks exactly one test, so the two new cases are independent rather than one assertion written twice. The existing eager-over-ceiling refusals stayed green under both probes, which is the third case the gate asked for — the guard still refuses what it should. The first new test puts the row subtree two levels deep under the list-item, so a projection that only checked a create's immediate parent would count it and fail. Validation
The changeset's last paragraph was rewritten: it claimed "a declared native-list row is not painted and is not counted", which was only true of the Generated by Claude Code |
LYNX_PAINTED_ELEMENT_CEILING is documented as the default an embedder derives their own paintedElementCeiling from, but lived only in a module the exports map never exposes; it is now re-exported from ./main-thread, the entry the option lives on. Also removes an unreachable null-return in projectedParent: batchParents stores number | null, so a stored null already returns through the staged check and has() can never add to it. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YHfFsy9CLaRovTFH8pTGyY
Summary
Issue #234 Part C: a page that would cross Android's painted-element ceiling is
declined in JavaScript, with a diagnostic, instead of painted into a process
abort that carries no JavaScript cause at all.
Lynx on Android charges one JNI global reference per painted element and its
table holds
max=51200; the ART dump at the crash attributes the entries toLynx's
PaintingContext. Crossing it is a SIGABRT with nothing above it in theJavaScript stack, which is why every framework in the cross-framework native
matrix DNFs at eager 10k for the same reason and none of them says why.
createLynxHostContainernow takes apaintedElementCeiling, and both pathsthat paint project what a mount would cost before painting any of it:
that already runs before anything is created, and refuses over the line with a
LynxFirstScreenRefusalError— the same class as the three refusals besideit, so the page falls back to the command path instead of being half painted;
prepareLynxHostBatchwalks the batch before its first command runs andrejects the commit, which leaves the tree the previous commit left and puts
the reason on the wire as a
rejectrather than afault.The projection is net rather than gross: a commit that retires a run and mounts
its replacement holds the survivors, not the sum, so a page that fits is not
refused. A declared native-list row costs nothing — the platform materializes a
cell through
componentAtIndexwhen it is about to show it — because counting adeferred run would refuse the very
<list>the diagnostic recommends.installLynxMainThreadderives the default fromSystemInfo.platform, which isthe only place that knows which engine is running: native Android reports
Androidand Lynx-for-Web reportswebthrough the same field, so one bundleserving both cannot carry the ceiling as a constant. Android gets
LYNX_PAINTED_ELEMENT_CEILING(45,000, leaving the platform's own bookkeepingthe remaining ~6,200); iOS, Lynx-for-Web, and an engine that reports no platform
get none. An explicit number sets it on any platform, and
nullturns it offfor an engine that lifted the limit.
Validation
pnpm typecheck— passes throughpackages/lynx/tsconfig.jsonandpackages/lynx/tsconfig.testing.json, the two projects this diff is in;the full ~80-project chain was still running when this was opened and its
result is reported in a comment below.
pnpm vitest run --project lynx— 49 files, 747 testspassing, up from 744 on the base.
pnpm format:fileson every changed file;pnpm syncclean.pnpm format:check(repo-wide) — not run; the scoped formatter covers thefour changed files.
pnpm test(full Vitest run) — not run locally; CI is the gate.Every guard was red-verified by breaking it and watching the matching test fail,
then restoring:
projected > ceilingprojected > ceilingdestroyno longer decrementsmount-templatebranch removedplatform === 'android'misspellednullopt-out ignoredRisk / follow-ups
Infinityand skips bothprojections entirely, so nothing changes off Android. On Android the commit
path pays one extra O(commands) pass per commit, before the pass that applies
them. It has to be a separate pass: the whole point is to refuse before the
first command runs.
all precede its destroys peaks above its own net total. No core composes one
today, and projecting the gross sum instead would refuse pages that fit.
max=51200less headroomfor the platform's own references. Part D's device gate is where a real number
can replace it.
not on a device. Part D is the device-side correctness gate.
Provenance
agent-authored)Generated by Claude Code