Skip to content

fix(sender): keep captureActive when the first frame beats startCapture - #222

Merged
swellweb merged 1 commit into
swellweb:maint-3.6from
kenshinice-ai:fix/sender-first-frame-status
Nov 12, 2026
Merged

swellweb merged 1 commit into
swellweb:maint-3.6from
kenshinice-ai:fix/sender-first-frame-status

Conversation

@kenshinice-ai

Copy link
Copy Markdown

What

When the first encoded frame arrives while startCapture() is still suspended, the session status ends up as captureStartedWaitingFirstFrame for the whole stream. The picture is on the receiver, but the sender keeps saying it is waiting for it.

Why

handleFirstEncodedFrame() sets sessionAckSent and captureActive. After startCapture() returns, the status was set to captureStartedWaitingFirstFrame unconditionally, which overwrote captureActive. handleFirstEncodedFrame() runs only once per capture, so nothing set it back.

startFirstFrameWatchdog() already guards this case with guard !sessionAckSent. This change gives the status line the same guard. It is one condition and a comment; there is no other change in behaviour.

Seen

On an iMac18,3 (macOS 13.7.8) receiver with a MacBook Pro sender: after a picture-preset change (5K 48 → 60 → standard → 60), the status stayed at "waiting for the first frame" in 3 of 4 changes, and once after a plain replug. Each time the stream was running and the receiver was decoding. The log showed the first encoded frame 175–375 ms after pipeline started, inside the startCapture() suspension.

Checked

  • Built the TBDisplaySender scheme from maint-3.6 plus this commit (Debug, Xcode on macOS 27): build succeeds, no new warnings.
  • In our downstream build, a test drives a session through the engine's own setters in both orders (first frame before and after startCapture() returns). With the old line the status ends at captureStartedWaitingFirstFrame; with the guard it ends at captureActive. That test uses our test hooks, so it is not part of this PR.

🤖 Generated with Claude Code

startCapture() is async, and the first encoded frame can arrive while it is
suspended. handleFirstEncodedFrame then sets captureActive and
sessionAckSent. When startCapture returned, the status was set to
captureStartedWaitingFirstFrame unconditionally, overwriting captureActive.
handleFirstEncodedFrame runs only once per capture, so the status then read
"waiting for the first frame" for the whole stream, although the picture was
on the receiver.

The watchdog already guards this case (startFirstFrameWatchdog returns when
sessionAckSent is true); the status now gets the same guard.

Seen on an iMac18,3 receiver: after a picture-preset change or a replug the
stream was up, but the status kept saying it was waiting for the picture
(3 of 4 preset changes). The first frame was logged 175-375 ms after
"pipeline started".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kenshinice-ai added a commit to kenshinice-ai/pwe-imac-display that referenced this pull request Oct 27, 2026
kenshinice-ai added a commit to kenshinice-ai/pwe-imac-display that referenced this pull request Oct 27, 2026
@swellweb
swellweb merged commit 1355381 into swellweb:maint-3.6 Nov 12, 2026
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.

2 participants