Skip to content

trailview: an idle view waits for the meshes that count their calm frames - #3795

Merged
timohueser merged 2 commits into
developfrom
claude/trailview-idle-returning-meshes
Nov 21, 2026
Merged

timohueser merged 2 commits into
developfrom
claude/trailview-idle-returning-meshes

Conversation

@timohueser

@timohueser timohueser commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Mode: fix
Requirements: none
Public docs: no

The fault

On the phone tier with ground=plan, waitForIdle() can return before the road meshes near the eye draw. A gallery shot or a still then shows the road under the eye flat grey. This happens most often after a warm open, where the device cache holds the view.

The cause: after a frame in which a mesh cell rests on a page coarser than level 17, the plan's meshes draw again only after CALM (120) calm frames (meshLevel in plan/pieces.ts). On the phone the half-size terrain pool leaves pages out while it fills, so the first frames of a load rest, and the count starts over. At 30 fps the 120 frames take 4 s. With a warm cache, all other content settles in about 2.3 s. Terrain.working already keeps frames going while the meshes return (pieces.returning), but Terrain.idle did not wait for them. So the still view converged on its 16 jittered frames without the meshes. When the meshes came, the view started again and drew correctly, about a second later.

A frame trace of one failed load (warm cache, tier=phone): the still view converged at 2.8 s, waitForIdle() resolved at 3.9 s with the meshes' calm at 104 of 120, and the meshes drew after that.

The fix

Terrain.idle is false while pieces.returning is true. Frames already go on in that state, and the calm reaches CALM in a fixed number of frames, so waitForIdle() cannot hang on it. On the phone tier a warm load now waits up to 4 s for its meshes.

Measurements

M1 Pro, headless Chromium on Metal, 390 × 844 CSS pixels at DPR 2, the walk lat=46.8205 lon=8.403 heading=160 eye=1.6 ground=plan, data from the PC data server. One fresh browser per run; "warm" loads the view once, then again in the same page. The grain of the bottom 200 rows (standard deviation of red) is 9.4 with the road's asphalt and 1.2 for the flat grey road.

Build Runs Bad
develop, tier=phone, cold cache 8 0
develop, tier=phone, warm cache 6 6
develop, desktop then tier=phone 8 5
develop, desktop, warm cache 6 0
develop + this fix, tier=phone, warm cache 6 0
develop + this fix, desktop then tier=phone 4 0

Before the fix, a reset of the accumulation in a bad state gave the right picture (3 of 3): the content was there, only the still view was stale. The phone's terrainShare: 0.5 is the tier value that exposed it: with the full share (1) the load lasts longer than the count, and no run failed (3 of 3).

Checks

In builder/web: npx vitest run src/lib/trailview (491 tests), npm run check and npm run check:wgsl pass. No new unit test: a stub of Terrain.idle would only restate the getter. The existing test in plan/pieces.test.ts shows that returning ends after exactly CALM frames, so waitForIdle() cannot hang on it; the runs above are the evidence for the fix.

Left open

  • On a warm open the phone shows the near roads without their meshes for up to 4 s, because CALM counts frames and the phone draws 30 a second. Whether the rests of a filling pool should restart the count is a design question for the owner, not part of this fix.
  • nearReady() and eyeReady() do not wait for the returning meshes either. The planner opens TrailView on eyeReady(), so on the phone it can open on the flat grey road, and the meshes come about 1.7 s later.

Review: one round; the comment on Terrain.idle now names the rest that restarts the count, and a thin test went out.

Time spent measuring: about 35 minutes (the bisect by cache kind and tier value, the frame trace, the runs above).

🤖 Generated with Claude Code

…ames

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b8e903d3-4d01-49d9-a5ec-74606a90f942
Commits

Reviewing files that changed from the base of the PR and between c6bd745 and 171af0d.

Files selected for processing: 1

  • builder/web/src/lib/trailview/terrain/terrain.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@timohueser
timohueser marked this pull request as ready for review November 21, 2026 21:49
@timohueser
timohueser enabled auto-merge November 21, 2026 22:09
@timohueser
timohueser merged commit 67d4017 into develop Nov 21, 2026
24 checks passed
@timohueser
timohueser deleted the claude/trailview-idle-returning-meshes branch November 21, 2026 22:09
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