Skip to content

Fix NDI feed stagnation when capture pipeline is idle (#92)#94

Merged
emosaru merged 1 commit into
mainfrom
fix/issue-92-ndi-feed-stagnation
May 17, 2026
Merged

Fix NDI feed stagnation when capture pipeline is idle (#92)#94
emosaru merged 1 commit into
mainfrom
fix/issue-92-ndi-feed-stagnation

Conversation

@emosaru
Copy link
Copy Markdown
Contributor

@emosaru emosaru commented May 17, 2026

Summary

  • Fixes NDI feed often stagnates and doesn't reach OBS with low ndi_frame_rate #92 — NDI feed stagnates during user inactivity, OBS declares the source dead.
  • The hidden broadcast window's capture loop is driven by the main window's RequestAnimationFrame, which stops firing when the user is idle. With no fresh snapshots, the send thread had nothing to transmit and the NDI receiver timed out.
  • Cache the last successfully sent frame and re-transmit it on the send thread's TryTake timeout (~250 ms) so the feed continues emitting frames whenever the capture pipeline goes silent. When state changes resume, fresh frames replace the cache and flow normally.

Implementation notes

  • Extracted SendVideoFrame(...) helper from ProcessOneFrame so both the live and heartbeat paths share one code path.
  • Cache stores the post-processed pixel buffer (un-premultiplied, drop-shadow composited, scaled) so the heartbeat resend doesn't redo work.
  • Cached buffer released in Dispose.

Test plan

  • Build with dotnet build (verified clean, 0 warnings)
  • Run EmoTracker with EnableBackgroundNdi on, connect OBS as an NDI receiver, leave idle for 5+ minutes — feed should stay alive (previously went silent within ~1 minute)
  • Make item changes — fresh frames still flow normally
  • Close window — verify no exceptions during cleanup

🤖 Generated with Claude Code

The hidden broadcast window's capture loop is driven by the main window's
RequestAnimationFrame, which stops firing during periods of user inactivity.
Without fresh snapshots, the send thread had nothing to transmit and OBS
would declare the NDI source dead after a few seconds.

Cache the last successfully sent frame and re-transmit it on the send
thread's TryTake timeout so the feed continues emitting frames (~4 Hz)
whenever the capture pipeline goes silent. When state changes resume,
fresh frames replace the cache and flow normally.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@emosaru emosaru requested a review from a team May 17, 2026 22:11
@emosaru emosaru merged commit 5291240 into main May 17, 2026
3 checks passed
@emosaru emosaru deleted the fix/issue-92-ndi-feed-stagnation branch May 17, 2026 22:46
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.

NDI feed often stagnates and doesn't reach OBS with low ndi_frame_rate

1 participant