Skip to content

End a pending open when the session shuts down - #38

Open
adiberk wants to merge 1 commit into
bilipp:mainfrom
adiberk:open-after-shutdown
Open

adiberk wants to merge 1 commit into
bilipp:mainfrom
adiberk:open-after-shutdown

Conversation

@adiberk

@adiberk adiberk commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

What

PlayerSession.shutdown() now resumes a pending openContinuation with EngineError(code: .cancelled) before tearing down.

Why

shutdown() cancels the pump tasks, so the .openFailed event that would resume openContinuation is never delivered. If a session is replaced while its load is still waiting on the demuxer, that load never returns, and the caller keeps the whole session (demuxer, decoders, renderers) alive for good.

We hit this in a live-TV app: changing channel quickly, while the previous stream was still opening, leaked one suspended session per quick change.

Notes

  • Four lines, and only reachable when shutting down mid-open.
  • Built and used in our tvOS/iOS app against v0.2.2; I haven't run the full test suite here.

🤖 Generated with Claude Code

`shutdown()` cancels the pump tasks, so the `.openFailed` event that would
resume `openContinuation` is never delivered. A `load` still waiting on the
demuxer when its session is replaced (for example a quick channel change while
the previous stream is opening) then never returns, and the caller keeps the
whole session alive for good.

Resume the pending open with `EngineError(code: .cancelled)` at the start of
`shutdown()`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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