Skip to content

feat: run on Windows with the app's own WebM decoder - #13

Merged
houko merged 4 commits into
mainfrom
feat/windows
Nov 22, 2026
Merged

houko merged 4 commits into
mainfrom
feat/windows

Conversation

@houko

@houko houko commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

The pet now runs on Windows x64. NSGo's Windows player refuses any clip that declares alpha (internal/platform/windows/video.go, VideoErrorAlphaUnsupported), so until now the pet's window stayed empty there.

  • clip.go: demuxes a WebM clip with github.com/at-wat/ebml-go v0.19.4 into its VP9 frames, each with the alpha picture from the block's additions (BlockAddID 1), and converts a decoded I420 picture plus the alpha stream's luma to premultiplied RGBA (BT.601/BT.709, limited/full range as libvpx reports).
  • vpx.go, vpx_windows.go, vpx_other.go: libvpx's VP9 decoder bound with github.com/ebitengine/purego (now a direct dependency), no cgo. On Windows it loads the bundled resources/windows/libvpx-1.dll with LoadLibraryExW restricted to the DLL's own folder and System32; elsewhere only the tests use it, against the system's libvpx.
  • clipplayer.go: on Windows each slot plays its clip in a core.Image through ImageSource.Pixels, decoding on a goroutine of its own into three reused buffers and showing each frame at its timestamp on the graph clock. It keeps the contract the pet relies on from core.Video: the load once the first picture is up (which drives the two-slot swap), progress every 33 ms, the end, pausing, restarting from the start, and the same style (Contain, mirroring, opacity). macOS and Linux keep core.Video unchanged.
  • resources/windows: libvpx 1.16.0 and the winpthreads DLL it links, unchanged from MSYS2's signed mingw64 packages (mingw-w64-x86_64-libvpx-1.16.0-1, mingw-w64-x86_64-libwinpthread-14.0.0.r92.g818fa6510-1), with their licenses and a NOTICE. tools/fetch-libvpx.sh fetches them again and checks their SHA-256.
  • nsgo.yaml builds windows_x64, and the release workflow gets a Windows row that makes the NSIS installer on Ubuntu, unsigned for now.

Tests

  • New: demuxing Big Blue Fish's clip (size, frame times, duration, every frame with alpha), demuxing every pet's clips, the YUV to RGBA conversion, decoding a real clip with libvpx, a Windows-environment run where the greeting loads and then an idle clip takes over in the other slot, switching pets through the context menu on Windows, and a decode benchmark.
  • go tool nsgo test . passes on macOS (libvpx from Homebrew): 18 passed.
  • On a Windows 11 x64 VM, go test passes with the bundled DLL (all but TestEveryClipShips, which needs the MOV clips the sparse checkout there left out). BenchmarkDecodeFrame: 1.74 ms per 640x360 frame with its alpha on an i5-14600KF.

Checked on Windows

The app built with go tool nsgo build -target windows_x64 ran in a logged-on but disconnected desktop session of the VM:

  • Clips play and follow each other (greeting, idles, events), as the app's log shows.
  • A click on the pet's body plays a click reaction, and the right-click menu opens with its items; choosing a pet in it switches pets.
  • CPU, from the process's cumulative CPU time over 20-second windows: Big Blue Fish (640x360 at 24 fps) 30 to 33% of one core, NSGo-chan 13 to 30% depending on the clip, Mochi about 7%. Decoding is about 4% of that for Big Blue Fish; most of the rest goes into handing each frame to the window as pixels.
  • Not checked: transparency over the desktop, the tray icon and dragging. The disconnected session takes no screen capture and no injected input; clicks and the menu were driven by posting window messages, which did not start a drag.
  • After switching to a pet of another window size at runtime, PrintWindow captures the window black, while the clips go on playing; from a fresh start every pet captures fine, and switching between pets of the same size does too. Whether the window really draws nothing after the resize needs a connected display to tell.

Screenshots

Captured with PrintWindow, which draws the window's transparent area black; the pet itself is what the window shows. Before this change the window showed nothing on Windows.

NSGo-chan Big Blue Fish PlayPets Daisy
NSGo-chan on Windows Big Blue Fish on Windows Daisy on Windows

houko and others added 4 commits November 22, 2026 23:44
NSGo's Windows player refuses video that declares alpha (internal/platform/windows/video.go), as whether Media Foundation keeps it was never checked, so the pet showed nothing there. On Windows each slot now plays its clip in clipPlayer: the WebM is demuxed with ebml-go, its VP9 color stream and the alpha stream in the blocks' additions are decoded with libvpx, bound through purego without cgo, and the frames are shown premultiplied in a core.Image through ImageSource.Pixels at their timestamps. The player gives the slot what core.Video gives it elsewhere: the load once the first picture is up, progress every 33 ms, the end, pausing and restarting from the start. macOS and Linux keep core.Video.

libvpx 1.16.0 and the winpthreads library it links ship unchanged from MSYS2's signed mingw64 packages in resources/windows, with their licenses; tools/fetch-libvpx.sh fetches them again by SHA-256. The decoder's tests run against the bundled DLL on Windows and the system's libvpx elsewhere, and are skipped without one.
nsgo.yaml builds windows_x64, and the release workflow gets a Windows row that makes the NSIS installer on Ubuntu, as NSGo's desktop builds need no cgo. The installer is not signed yet, for which SmartScreen warns. Only x64: the bundled libvpx is an x64 DLL.
…sh frame on Windows

A BlockMore that leaves out BlockAddID holds the alpha picture, as the element defaults to 1, so packs from muxers that skip default values no longer play opaque on Windows.

Replaying the clip the hidden slot already holds now waits for the Windows player's first new frame before showing the slot, instead of showing its stale frame while the clip is read and decoded again.
@houko
houko merged commit 5e8e4a8 into main Nov 22, 2026
4 checks passed
@houko
houko deleted the feat/windows branch November 22, 2026 14:56
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