Skip to content

[KS] Flakes: media-native playback timing, session-relaunch scroll restore (#444) - #447

Merged
sethwebster merged 2 commits into
seth/kitchen-sink-gatefrom
seth/ks-444-flakes
Oct 13, 2026
Merged

sethwebster merged 2 commits into
seth/kitchen-sink-gatefrom
seth/ks-444-flakes

Conversation

@sethwebster

Copy link
Copy Markdown
Collaborator

Refs #444

Root causes

  • media-native: after playing to the end, play() issues an async seek to 0 and the test read status.currentTime synchronously. Under load the seek hasn't landed yet, so it still read 3.0 (media.native.mm:116). The other playback checks waited on fixed wall-clock drains (Drain(0.4), Drain(0.6)), which race a late playback start. The player itself behaves correctly: its time observer reports the jump.
  • session-relaunch: the problem is in the Kitchen Sink note view (useRestoredScroll), not in Spark's restore. When scroll-1-160 arrived after the details ScrollView mounted but before it was sized, the target-change effect ignored it because nothing had been reported yet. The first sizing then reported 0 and overwrote 160, so the saved session held 0. Trace from a failing launch: render:0, target:0, render:160, target:160 (pending null, reported null), sized, report:0.

Fixes

  • tests/media.native.mm: wait on the player's own clock and events. The playback rate is checked on the item's timebase (== 2, a new check). Time is waited past 1.6. Restart is shown by a reported status below 0.5 after play(), with no ended status. Looping is shown by a reported jump back below 1, with no ended, and still playing.
  • NoteView.tsx: an offset set before the first report becomes the pending restore offset, the same as a saved one.
  • session-relaunch.yaml: also asserts that the note reports 160 before quitting, so this race fails at the step that causes it.

Verification (this session)

  • Reproduced on the base: the old test binary failed 26/30 while the other *-native tests ran in parallel (all at line 116). It also failed once in each of the two load runs below.
  • Fixed vitest run tests/media-native.test.ts: 20/20 while the full suite ran in parallel. Another 20/20 while ks-lock native bun run rebuild:macos ran, though only the first 14 runs overlapped the build. The fixed binary also passed 20/20 under the native-test load.
  • session-relaunch under --backend driver, before the fix: failed 1/10 and 6/15, always with scroll 0. With the launch-1 assertion added it failed 1/8, at that new step. After the fix: 12/12 with instrumentation, then 10/10 clean.
  • bun run typecheck: pass. bun run e2e:lint: 0 problems. bun run test: 1965 passed, 2 failed, both known: the node-runtime asdf shim, and the motion-native frames check (display asleep). media-native passed within the suite.

Under load the restart seek lands after play() returns, so the status still read 3s; the timed drains also raced late playback starts. Wait on the player's time and reported events instead, and check the playback rate on the item's timebase.
A scroll offset set after the details view mounted but before it was sized was ignored, and the first report (0) overwrote it, so the saved session sometimes held 0. Treat it as pending like a restored offset, and assert the note reports it before the app quits.
@sethwebster
sethwebster merged commit bc15fee into seth/kitchen-sink-gate Oct 13, 2026
2 checks passed
@sethwebster
sethwebster deleted the seth/ks-444-flakes branch October 13, 2026 03:47
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