Repository navigation
A batch in a game that's already open links up to the game at once, not at its first marker - #1126
Conversation
…atch's reader connects at once On a game left open between batches (#725) the events pipe only noticed the previous batch's reader had gone at its next write, so the next batch's reader waited until the game's first marker (9-25 s in #1075's retest). While idle, the server now asks ConnectNamedPipe whether its reader has gone (ERROR_NO_DATA) and listens again. Nothing is held back at that point, so no line is lost or sent twice. batch_end used the stale "connected" to leave a reused game open after its batch; it now forgets the batch's end once BATCH_COMPLETE has been written to a reader, so the faster notice doesn't make the game quit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent review (head e6ebcbb)Verdict: no bugs found, no changes pushed. Ready to merge. Batch-end paths
How the end of the batch is ordered: the schedule echoes
|
Release note: none
Follow-up to #1075.
What changes
In a game left open between batches (#725), Studio's events-pipe reader for the next batch could only connect when the game sent that batch's first marker, 9-30 s after Start Capture Batch (#1075's retest). The hook's pipe server (
goldsrc-hooks/src/events.rs, its own thread) only noticed the previous batch's reader had gone when a write failed. Until then the game's "Studio connected" flag stayed stale.Now, on each 500 ms idle timeout, the server asks the pipe whether its reader has gone and, if so, lets it go and listens again, so the next reader gets in within about half a second.
ConnectNamedPipeon an instance that's already connected returns at once, withERROR_PIPE_CONNECTEDwhile the reader is there andERROR_NO_DATAonce it has closed its end. I measured this in an i686 test.PeekNamedPipereturnsERROR_ACCESS_DENIEDon the outbound server end, so it can't be used.batch_end(A capture batch outlives DoD Studio closing, and Studio catches up when it reopens #545) needed a change too: it quits the game 5 s afterBATCH_COMPLETEwhen no reader is connected. Until now a reused game survived only because "connected" stayed stale after Studio's reader stopped at the end of the batch. With the faster check, the game would have quit after every batch. Now the batch end is forgotten once the pipe has actually writtenBATCH_COMPLETEto a reader (batch_end::studio_saw_end). That is what "Studio had its say" means. A Studio that closed mid-batch never gets that line, so the game still quits by itself as before.batch.rsHELD_BEAT,native/src/obs/pipe_tail.rs).Decisions
none. The live test showed the footer's "Starting the game…" wait is not caused by the pipe. "Capturing clip 1 of 1" needs the game's NEXT_CLIP, which comes when the demo has loaded, ~30 s after Start in a reused game, before and after this fix. The old reader got every queued marker on connect, so it never lagged behind. What's fixed: Studio's reader is connected within a second, and the hook's "Studio connected" flag is accurate within half a second. That flag decides whether a held batch gives up on a closed Studio (Render and clean up clips while a capture batch is still running, so a long batch never fills the drive #861) and whether review-lock refusals are sent. Players won't see a change. The ~30 s demo load in a reused game is a separate question, not looked at here.ConnectNamedPipe'sERROR_NO_DATAinstead of a zero-byte write. A zero-byte write can reach the reader as a 0-byte read, which looks like EOF.ERROR_NO_DATA. Any other result keeps the old behaviour, where a failed write notices it.Test done
events::tests::readers_get_everything_once_and_the_next_one_gets_in_at_once): a reader gets the hello, then the backlog in order. It drops while the server is idle, and the next reader gets in within 1.5 s (measured well under that). That reader gets each new line exactly once, and "connected" clears within 2 s of it leaving. With the check disabled, the test fails: "All pipe instances are busy" after 2 s.batch_end's test now also coversstudio_saw_end.cargo fmt --checkis clean. Clippy-D warnings(1.98.1) is clean on the workspace (host) and on goldsrc-hooks i686. Hooks i686: 943 passed. Workspace tests (excluding hooks and web-analyzer) all pass, native 944.obs::63/63), and so did the full rerun.wsod25_grp5_h1_m00cat.dem(D:, folder with a space), highlight 4 (14:17, 3 kills). I added a temporary activity-log line for every marker Studio received, not committed.The 10 markers are DEMO_START, NEXT_CLIP, SPEED_FLUSH, AUDIO_SYNC, START_RECORD, CUSTOM_CMD1_BEFORE, STOP_RECORD, CUSTOM_CMD2_AFTER, FAST_FORWARD and BATCH_COMPLETE. Before, from #1075's retest with the same setup on POST, reused-game batches connected 14 s, 29 s, 30 s and 14 s after Start, each at the batch's first marker. After every batch the game was still open 15 s later, well past
batch_end's 5 s grace, with the same PID throughout (54188 POST, 41396 PRE). So thestudio_saw_endchange keeps a reused game open as before.🤖 Generated with Claude Code