Skip to content

feat(pet): export ClipView so the settings grid plays clips on Windows - #16

Merged
houko merged 1 commit into
mainfrom
feat/windows-settings-clips
Nov 22, 2026
Merged

houko merged 1 commit into
mainfrom
feat/windows-settings-clips

Conversation

@houko

@houko houko commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

On Windows, NSGo's video backend refuses VP9-with-alpha WebM (nsgo-dev/nsgo#862), so every card in the settings window's pet grid was an empty box. The engine already plays its pet through its own libvpx player there, but the app could not reach it.

  • Add pet.ClipView{Pack, Clip, Class, Style, TestID}, a node that loops one of a pack's clips as the pet plays it: a repeating, muted core.Video on macOS and Linux (unchanged from what the grid showed), and on Windows the engine's own player, which reads the clip again when it ends and whose decoder goroutine stops when the view unmounts. A clip ID the pack lacks shows an empty view.
  • petGrid uses it for each pet's idle clip; idleClip moves to the app's tests, its only remaining user.
  • Document it in ARCHITECTURE.md, the English and Chinese embedding docs and the Unreleased changelog.

CPU on Windows: the 宠物 page decodes all eleven idle clips at once while it is shown (the page unmounts, and its decoders stop, when the user switches to 通用 or closes the window). From BenchmarkDecodeFrame (about 2 ms per 640x360 frame on an M4 Pro) and the clips' sizes and frame rates, that is roughly 15% of one such core, more on slower machines. There is no cheap reduction that keeps the previews animated, so this PR leaves it as is.

Tests

  • TestWindowsClipViewLoops: in the Windows environment, a ClipView shows the engine's image and keeps showing frames past the clip's frame count, so it restarts; its decoder goroutine is gone after unmount. Needs libvpx; skips without it. Mutation-checked: it fails with the restart removed and with the player's cleanup removed.
  • TestClipViewIsAVideoElsewhere: on Linux, a repeating, muted core.Video of the WebM clip; a missing clip is an empty view.
  • TestWindowsSettingsSwitchPets now asserts each clip-<id> preview is the engine's image, not a video.
  • go tool nsgo test ., (cd pet && go test -count=1 ./...), (cd pet && go test -race -count=2 -run 'Windows|Clip' ./...), go tool nsgo check -target windows_x64,linux_x64 and GOOS=windows GOARCH=amd64 go -C pet vet ./... pass; gofmt is clean.

Screenshots

None: the change shows only on Windows, and this was built and tested from macOS, where the grid's previews are the same core.Video as before. The headless tests cover what the Windows grid mounts; a manual run on Windows is still needed to see the previews animate.

NSGo's Windows video refuses alpha WebM (nsgo-dev/nsgo#862), so every card in the settings' pet grid was an empty box there. pet.ClipView loops a pack's clip as the pet plays it: a repeating, muted core.Video on macOS and Linux, and on Windows the engine's own libvpx player, which reads the clip again as it ends and whose decoder stops with the view. The grid uses it for each pet's idle clip.
@houko
houko force-pushed the feat/windows-settings-clips branch from 6b20c72 to ef809da Compare November 22, 2026 15:05
@houko
houko merged commit df84b02 into main Nov 22, 2026
1 check passed
@houko
houko deleted the feat/windows-settings-clips branch November 22, 2026 15:06
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