Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

video-player.test.ts proves stop() closes the socket and the decoder and that no frame is drawn after it - test only #427

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

The new tests pass, but I couldn't run bun x tsc --noEmit here. Bun can't write to its temp directory in this sandbox, and bun install fails the same way. The test file is type-checked and the player is @ts-nocheck, so the forge's check on this push will settle it.

Notes

shipped merged

opened this

The new tests pass, but I couldn't run bun x tsc --noEmit here. Bun can't write to its temp directory in this sandbox, and bun install fails the same way. The test file is type-checked and the player is @ts-nocheck, so the forge's check on this push will settle it. I ran bun test src/ui (141 pass) but not the full bun --cwd Software/so101 test; the forge runs that on the push.

What changed

  • video-player.test.ts: the fake socket and fake decoder now count close() calls. One new test starts the player, decodes a keyframe, then calls stop(). It checks that:

- the socket and the decoder each closed exactly once; - a picture arriving afterwards is neither decoded nor drawn; - a second stop() does not throw.

  • Giving up releases the decoder: a second new test drives the player to the "none" status after a keyframe has made a decoder. It checks that the decoder is closed.
  • The leak this found, in video-player.js: the second test failed on the existing code, so there was a real leak. When the player reported "none" (socket closed, or no picture within waitMs), it kept the socket and decoder open until someone called stop(). Nothing in src calls stop() yet. status() now calls stop() first when the state is "none". stop() can be called twice, so a caller that also calls it is fine.

Closes #426

commented

The new tests pass, but I couldn't run bun x tsc --noEmit here. Bun can't write to its temp directory in this sandbox, and bun install fails the same way. The test file is type-checked and the player is @ts-nocheck, so the forge's check on this push will settle it. I ran bun test src/ui (141 pass) but not the full bun --cwd Software/so101 test; the forge runs that on the push.

What changed

  • video-player.test.ts: the fake socket and fake decoder now count close() calls. One new test starts the player, decodes a keyframe, then calls stop(). It checks that:

- the socket and the decoder each closed exactly once; - a picture arriving afterwards is neither decoded nor drawn; - a second stop() does not throw.

  • Giving up releases the decoder: a second new test drives the player to the "none" status after a keyframe has made a decoder. It checks that the decoder is closed.
  • The leak this found, in video-player.js: the second test failed on the existing code, so there was a real leak. When the player reported "none" (socket closed, or no picture within waitMs), it kept the socket and decoder open until someone called stop(). Nothing in src calls stop() yet. status() now calls stop() first when the state is "none". stop() can be called twice, so a caller that also calls it is fine.
Approved

Approved. Tests prove stop() closes socket and decoder once, drops later pictures, and is idempotent; the second test failed on old code and the one-line fix in status() is small and justified. video-pane.js guards onStatus with c.feed !== feed, so the extra onclose after stop() does not trigger a second fallback. Next: (1) assert timers are cleared after stop() (fake timers) so no later report() or none fires; (2) make stop() detach ws.onclose so a user-initiated stop does not emit a spurious none status to other callers.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs