LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-vega
createdAtNov 6, 2026, 10:09 PM
updatedAtNov 6, 2026, 11:36 PM
githubUrlhttps://github.com/neomjs/neo/issues/20486
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 6, 2026, 11:36 PM

GraphScene's e2e reads its labels before the resized frame draws

neo-opus-vega
neo-opus-vega commented on Nov 6, 2026, 10:09 PM

Context

test/playwright/e2e/rendering/GraphScene.spec.mjs:117 failed on hosted dev push run 42285892908 at 5f57baeadf, e2e-engine shard 7. A rerun of the shard passed.

expect(drawn.labels.drawn.length, 'the frame places some of them').toBeGreaterThan(0)
Received: 0

The trace records the test's only stats read:

read frames canvas labels.count uploaded.labels labels.drawn
1 1 [2000, 1288] 20 20 0

The buffer already had the CSS size times 2, but only one frame had drawn.

The Problem

Every test in this spec starts from sizedSceneDrawn. It waits for frames > 0, the demo's node count, and canvas equal to the CSS size times the ratio, and its JSDoc says that means "the demo scene drawn into a buffer of the canvas's CSS size". That doesn't hold.

GraphScene#updateSize resizes the buffer synchronously and only requests the frame. A read that lands between the size message and the next animation slot sees the new buffer beside the previous frame's drawing. Here the previous frame was the boot frame, drawn before any size message, and it placed no labels. On a fast runner the slot fires before the read; on a contended one it does not.

#19444 (PR #19445) moved these tests onto the sized buffer for this same boot race. The size is set before the frame that uses it, though, so the race survived. The labels assertions added by #20286 are the first to depend on what is drawn at that size.

The Architectural Reality

  • src/canvas/GraphScene.mjs:1404 updateSize() sets canvasSize, the buffer and the viewport at once, and owes the frame through requestFrame() (:1339).
  • requestFrame() holds animationId until render() (:1262) clears it as it starts. render() places the labels (drawLabels) and counts frames.
  • getStats() (:935) reads canvas from the live buffer, and frames and labels.drawn from the last frame. Nothing in it says whether a frame is owed.
  • examples/component/graphScene/MainContainer.mjs:148 spreads getStats() onto the stats line the spec reads. The first test's "boot frames settle" loop (two reads agreeing on frames) waits out late boot frames, whether owed or still in transit.

The Fix

  1. GraphScene#getStats() reports owed: a frame was requested and has not drawn yet. Until it draws, frames and labels.drawn describe the last frame, not the current state. The engine already tracks this in animationId, so the change exposes it and adds no bookkeeping.
  2. sizedSceneDrawn also waits for !owed, so the read it returns is of a frame drawn at the sized buffer.
  3. The first test's settle loop stays. Deleting it failed 1 of 3 local runs: after the read with no frame owed (frames 2), a third frame landed in the idle second with the buffer, camera and labels unchanged. Boot can still reach the renderer after its first sized frame, and owed cannot see a message that is still in transit.

Contract Ledger Matrix

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
Neo.canvas.GraphScene#getStats().owed animationId, set by requestFrame() and cleared by render() true from a frame request until that frame starts a paused scene or a lost context owes nothing, since requestFrame() requests nothing getStats JSDoc a unit arm: true after a request, false once the frame runs

Decision Record impact

none.

Acceptance Criteria

  • getStats().owed is true after requestFrame() and false once the owed frame runs, asserted in test/playwright/unit/canvas/GraphScene.spec.mjs.
  • sizedSceneDrawn waits for !owed, and its JSDoc says what the returned read shows.
  • The first test's "boot frames settle" loop is gone. Withdrawn 2026-11-06 (The Fix, item 3): the loop also waits out boot messages still in transit, which owed cannot see. Its comment now says so.
  • The e2e spec passes locally through the off-socket engine tier with --repeat-each=3.

Out of Scope

  • Whether the boot frame should place labels before the first size message. That is a one-frame state in the default 300×150 buffer.
  • Other GraphScene CI notes with a different shape.

Avoided Traps

  • Waiting for frames to advance once the size matches. When the size message lands before the boot frame's slot, that frame already draws at the size and no other frame is owed, so the wait would hang.
  • Waiting for labels.drawn.length > 0 in the helper. The "places some of them" assertion would become its own precondition, and a scene that never draws labels would fail as a timeout with the wrong message.
  • Two reads that agree on frames. Both can land before the slot on a contended runner. That narrows the race but never closes it.

Related

#19444 / PR #19445 (the sized-buffer wait) · #20286 (the labels assertions) · run 42285892908

Live latest-open + closed sweep: I checked the latest 20 open issues at 2026-11-06T21:08Z and closed searches for "GraphScene labels" and "GraphScene stats frame flaky". The hits were #19444, #20286 and #20312, and I read their Out of Scope and Avoided Traps sections. #19444 excludes engine changes to the restore path's buffer sizing, which this leaves untouched. No equivalent and no prior exclusion found. A2A claim sweep (30 messages, all read states): no claim on this spec. Grace's defect note names me as owner. MC sweep: the only prior fix is #19445's sized-buffer wait (Ada, 2026-10-07). There is no decision about the stats' frame state. Own-assignment sweep: none overlapping. Ownership: self-assigned. I wrote GraphScene's labels and their assertions, and Grace's defect note named me as owner. It isn't marked good first issue because it is a CI flake on the release path, fixed now.

Origin Session ID: 928dfeec-33e1-40d5-967c-1081353a09af

Retrieval Hint: "GraphScene stats owed frame sized buffer labels drawn boot frame e2e flake"

Authored by Vega (Opus 5.5, Claude Code) 🌿

tobiu referenced in commit c6935bc - "feat(canvas): GraphScene's stats say when a frame is owed, and its e2e waits for none (#20486) (#20488) on Nov 6, 2026, 11:36 PM
tobiu closed this issue on Nov 6, 2026, 11:36 PM