Repository navigation
Description
Found by the c2-shapes lens of the adversarial audit of #58. Counterexample to #65's claim that the direct applier leaves the container indistinguishable from the staged path and declines (returns false) only for native-<list> trees.
Stack-introduced, specifically by 7600bfbaf — verified in a git worktree at base 6079a6804, where grep -c applyLynxFirstScreenDirect packages/lynx/src/core/host-driver.ts returns 0 and main-thread.ts:1901 renders the first screen through prepareLynxHostBatch only.
Root cause
applyLynxFirstScreenDirect walks the rendered tree with a recursive visit closure (packages/lynx/src/core/host-driver.ts:2936-3013, self-call at :3007), consuming one stack frame per host tree level.
The staged path it replaced consumes none — prepareLynxHostBatch/apply iterate a flat command array, so its depth capacity is effectively unbounded (measured ≥ 60,000 levels on both base and head).
The direct applier is therefore the first stack-bound stage in the first-screen pipeline, and it binds before renderLynxFirstScreen's own recursion does.
Measured, HEAD vs base, identical file and warm-up, 2/2 runs each side
HEAD levels=98 (host depth 3920) -> painted
HEAD levels=100 (host depth 4000) -> RangeError: Maximum call stack size exceeded
HEAD levels=105 (host depth 4200) -> RangeError: Maximum call stack size exceeded
BASE levels=100 (host depth 4000) -> painted
BASE levels=105 (host depth 4200) -> painted
BASE levels=110 (host depth 4400) -> RangeError
Isolated repro naming the throwing frame, 3/3 runs identical:
renderLynxFirstScreen OK: hostCount=5000 (nesting depth 5000)
applyLynxFirstScreenDirect: RangeError: Maximum call stack size exceeded
at planLynxHostPropPatch (packages/lynx/src/core/host-props.ts:574:31)
at visit (packages/lynx/src/core/host-driver.ts:2955:7)
at visit (packages/lynx/src/core/host-driver.ts:3007:4)
container faulted=true
prepareLynxHostBatch().apply(): painted, capture roots=1, nodes=5000
The renderer produces the tree successfully; only the applier refuses it. Warmed same-process capacity: render reaches 5000, direct reaches 3968 — ~1030 levels the renderer can produce and the direct applier cannot paint.
The more serious half: a throw has no fallback
packages/lynx/src/main-thread.ts:1906 falls back to the staged path only when applyLynxFirstScreenDirect returns false (the native-<list> decline). A throw instead takes the catch at :1934, which calls retireFirstScreen(source, 'failed', 'failed') and rethrows.
So the first screen is retired rather than repainted through the staged path that would have succeeded on the identical tree:
renderLynxFirstScreen(levels=125) OK: hostCount=5000
firstScreenRoot.render THREW RangeError
first-screen snapshot after render: null
page children painted: 13 bytes of HTML
false falls back; a throw does not. That asymmetry turns any direct-applier fault into a dead first screen, regardless of cause.
Consumer impact, with an honest bound
firstScreenRoot.render(...) throws to the application, main.firstScreenSnapshot() is null, and the page stays empty. The fixture is a plain recursive component — the shape of a tree view or a nested comment thread — not a synthetic node tree.
Practical severity is bounded by depth: 4000 nested hosts is unrealistic for a mobile UI under V8's ~1 MB default stack. The direction is engine-independent (one frame per level versus zero), but the absolute crossover is not, and this could not be measured on the real Lynx main-thread engine. PrimJS's JS stack budget is typically far smaller than V8's, which would push the crossover proportionally lower — that is the open question, and it needs a device to answer.
Suggested direction
Either fix removes the regression, and they are independent:
- Make
visititerative (explicit work stack), restoring the staged path's unbounded depth. - Extend the fallback so a throw from
applyLynxFirstScreenDirectalso retries throughprepareLynxHostBatch, not just afalsereturn.
(2) is worth doing regardless of (1): it converts any future direct-applier fault from a dead first screen into a slower one.
Verification performed
Executed at HEAD 5d000b30e and in a base worktree, 2/2 runs per side on the ladder and 3/3 on the isolated repro, through the public API (firstScreenRoot.render). Attribution established by the applier's absence at base. Not independently re-run by me; no adversarial refuter has adjudicated it.
Related
- Direct first-screen applier skips the main-thread/background event collision check, silently dropping the main-thread handler #84 — the other stack-introduced CLAIM 2 regression (missing
assertNoMainThreadEventCollision) - applyLynxFirstScreenDirect paints first-screen trees the staged applier refuses #76 — the surface documentation; its own mechanisms 1 and 2 were refuted
Activity
Huxpro commentedon Aug 18, 2026
Disclosure: this finding has had no adversarial verification
Every other high-priority finding in this audit went through either a 2-of-3 refuter panel or a dedicated reachability attacker. This one did not — it came from the
c2-shapeslens in a close-out workflow I built with no verify phase, and it landed after the reachability audit had already been scoped to #81/#83/#84.That matters because of this audit's track record: 18 filed, 4 withdrawn, 1 substantially downgraded. Every failure had the same shape — a real, reproducible mechanism whose severity claim outran what an ordinary program can reach. #72 was withdrawn after I personally reproduced 200,001 iterations, because reproducing a probe confirms the fixture, not the claim.
What this finding does have
Stronger primary evidence than most of the withdrawn ones, which is why I still rank it second:
grep -c applyLynxFirstScreenDirectreturns 0 at base6079a6804, so the recursive walk cannot predate the stack.firstScreenRoot.render, not a hand-built node tree or a forged descriptor.visitathost-driver.ts:3007).What has not been tested
main-thread.ts:1906falls back only on afalsereturn, so any throw from the direct applier retires the first screen instead of retrying the staged path. That is a structural property visible in the source, independent of stack depth — but no probe has driven it from a non-depth fault.Point 3 is the cheapest thing to settle and probably the one worth acting on regardless of point 1: inject any fault into the direct walk and check whether the staged path is ever attempted.
I would rather flag this asymmetry than let the issue inherit confidence from the findings around it that were adversarially tested.
Generated by Claude Code
Merge pull request #93 from Huxpro/fix/lynx-first-screen-depth