Repository navigation
feat(pet): export ClipView so the settings grid plays clips on Windows - #16
Merged
Merged
Conversation
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
force-pushed
the
feat/windows-settings-clips
branch
from
November 22, 2026 15:05
6b20c72 to
ef809da
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
pet.ClipView{Pack, Clip, Class, Style, TestID}, a node that loops one of a pack's clips as the pet plays it: a repeating, mutedcore.Videoon 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.petGriduses it for each pet's idle clip;idleClipmoves to the app's tests, its only remaining user.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, mutedcore.Videoof the WebM clip; a missing clip is an empty view.TestWindowsSettingsSwitchPetsnow asserts eachclip-<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_x64andGOOS=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.Videoas before. The headless tests cover what the Windows grid mounts; a manual run on Windows is still needed to see the previews animate.