Repository navigation
feat(sessions): stop paused sessions and empty lobbies after an opt-in timeout - #592
Open
andrewdunndev wants to merge 2 commits into
Open
andrewdunndev wants to merge 2 commits into
andrewdunndev wants to merge 2 commits into
Conversation
A Moonlight client that disconnects without quitting the app, such as a device going to sleep or a dropped link, leaves its session paused. Wolf keeps that session and its app container until someone stops them by hand. WOLF_PAUSED_SESSION_TIMEOUT_MS (default 0, off) stops a session once it has stayed paused for that many milliseconds. A Pause records an epoch for the session and arms one deferred check; Resume or Stop clears it. The check fires StopStreamEvent only if the epoch still matches, so a resumed session is never stopped by an earlier Pause. A Pause for a session that is no longer running, such as the client disconnecting after a Stop, arms nothing.
A lobby created with stop_when_everyone_leaves set to false keeps its app container running after the last session leaves, including when that session was only paused by a sleeping client. WOLF_EMPTY_LOBBY_TIMEOUT_MS (default 0, off) fires StopLobbyEvent once a lobby has stayed empty for that many milliseconds after a session left it. Each leave records a new epoch, so only the check armed by the latest leave can stop the lobby, and only if it is still empty.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refiled from #581, which I closed unreviewed only because of the three-open-PR limit. The branch applies cleanly to current beta (ac2461f); the body is the same apart from small wording fixes.
Problem
A Moonlight client that vanishes without a clean quit (a device that sleeps, a dropped link) ends in an ENet disconnect.
PauseStreamEvent(control/control.cpp:180-185,:222-224), which stops the pipelines but not the session.stop_when_everyone_leavesfalse does the same once its last session has left (sessions/lobbies.cpp:61-64).I found no peer timeout or idle path in
src/.Change
Two env vars, both default 0 (off). Unset or 0 creates no handler, atom or thread.
WOLF_PAUSED_SESSION_TIMEOUT_MSstops a session and its app container once it has stayed paused that long.StopStreamEventonly if its epoch is still current, so a Resume after an earlier Pause is never undone.WOLF_EMPTY_LOBBY_TIMEOUT_MSfiresStopLobbyEventonce a lobby has had no joined session for that long after a leave.Both:
WOLF_WAYLAND_SOCKET_WAIT_TIMEOUT_MSdoes.configuration.adocrows.Limits:
Tests
tests/testSessions.cpp, tag[Sessions], no GPU, Docker or peer. 3 test cases; 390 lines added, 232 of them tests.Rebuilt on beta ac2461f with both commits applied and run with Wolf's Catch2 suite: 43 of 43 test cases pass (1143 assertions), and clang-format 18 is clean. The existing "Lobbies APIs" case is excluded because my runner has no Wayland compositor (it fails the same way without this series).
Checked once that the tests catch a regression: with Resume changed so it no longer cancels, exactly the two Resume sections failed ("Resume before the timeout cancels the Stop", "Pausing again after a Resume restarts the timeout"). "Lobbies APIs" also failed, for the compositor reason above.
Real hardware
Two hosts, one AMD host and one NVIDIA host, each as server with Moonlight on the other.
kill -STOP, so there was no clean disconnect.On stock stable the frozen session and its container were still up after 10 min.
Empty lobby, AMD host: a persistent Steam lobby joined by a Moonlight session, then left through the API.
Related
stable,rest/endpoints.hpp). No overlapping hunks. Its Pause arms this timer and the ENet Resume clears it.control.cpp.wait_for_pinghas no timeout: sessions whose client never pings leak two threads (andwait_for_ping=falseis ignored) #550 is the setup-phasewait_for_pingleak. It is a different path and is not addressed.We have a small test bench (one AMD host with a discrete and an integrated GPU, one NVIDIA host, scripted Moonlight clients) and are glad to run A/B tests or take on side quests the community would find useful. The main limit is GPU age: our GPUs are a generation or two old.