Repository navigation
vision-demo: a late close no longer drops the robot's redialled stream - #433
Open
ericdelorefice wants to merge 1 commit into
Open
ericdelorefice wants to merge 1 commit into
ericdelorefice wants to merge 1 commit into
Conversation
The receiver removed a stream by (account, robot name) when its socket closed. A robot can redial before this end sees the previous connection go - a second media.stream, whose old socket closes only when its encoder thread next looks, or a link that dropped without a close - so the old socket's teardown could run after the new one's hello and take the live stream with it. The page then said "no stream yet" while frames kept arriving. Frames.closed now takes the stream and removes it only if it is still the one registered under its key, and a connection that registered nothing removes nothing (it used to fall back to the name "a duck"). test_receiver.py drives the real /frames route with FastAPI's test client. Assisted-by: Claude:claude-opus-5-5
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.
Problem
spaces/vision-demo/receiver.pyfiles each robot's stream under (account, robot name), and the/framesroute'sfinallyremoved that key when its socket closed. A redial into a Space that restarted already works, as the comment on the hello says. The case this fixes is a redial into a Space that is still up: if the robot has already reconnected when the old socket's teardown runs, the key belongs to the new connection, and the old teardown removes the live stream. Frames keep arriving into aStreamnothing can see, and the page says "no stream yet" until the robot happens to reconnect again.Two ways the old close can come second, from reading
mediad/src/stream.rs. I have no robot, so neither is observed:media.streamreplaces the first (pressing start streaming again, for example to change the rate).Streamer::startspawns the new pump straight away, while the old pump closes its socket only after its encoder thread next checksrunning, up to about one frame interval at the old rate (1 s at 1 fps). The new connection needs a handshake and onewhoami-v2call before its hello.The same
finallyfell back to the name "a duck" for a connection that never registered anything, so such a connection could remove a nameless robot's live stream.Reproduction
test_receiver.py(new) drives the real/framesroute with FastAPI's test client.whoamiis replaced so a made-up token resolves to an account, and the order is forced: the old connection says hello and sends a frame, a second connection for the same robot says hello, the old one closes, the new one sends a frame. On main the account is left with no stream:Change
Frames.closedtakes the stream and removes it only if it is still the one registered under its key, and the route calls it only when its connection registered a stream. +12/-3 inreceiver.py. Intended behaviour change: an old connection's close leaves a newer stream for the same robot in place. Each connection still removes its own stream when it ends.Testing
test_receiver.py, four tests, written likevetbook/test_traits.py:python test_receiver.pyor pytest. The test client needshttpx, which the Space does not install.cargo test.