-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MediaStreamTracks are ended after returning from sleep #1447
Comments
Because this issue is a little hard to describe well I've recorded videos of it. The video shows the full behavior, starting with connecting two clients in the demo app, then putting the computer to sleep and waking it. I then walk through the two behaviors I see: one for clients which come back from sleep, and one when new clients connect to them and try to share tracks. |
Hello @a-type, Thank you for the detailed description and the video. I was able to repro this issue. On chrome I notice that track goes to the "ended" state very quickly after sleep. It stays in "live" state in both firefox and safari if the computer was quickly woken from the sleep. I have filed a bug for chrome. One workaround that comes to mind is to watch for RemoteVideoTrack going into "ended" state and then communicate to publisher using data channels that the track was "ended", and they need to unpublish and republish. Thanks, |
Good idea, thanks for narrowing it down. I'll see about coordinating that. |
Hey @a-type, We looked bit more into this, and I think SDK should be able to detect this case and should disconnect the publisher in this case. I have filed a bug (VIDEO-4794) to track this issue. In the meanwhile, I thought of a bit simpler workaround that could help in your scenario. On chrome we see that peer connection object goes to 'closed' state when the machine goes to sleep. You can detect such state change on publisher side and once detected Note: This workaround requires access to some internal state of the room:
Note: Peer connection can go into closed state for other reasons, but in all such cases Thanks, |
Oh, much easier! Thanks, I'll probably use that workaround and incorporate it into our extensions of the automated reconnection logic. |
or sensitive account information (API keys, credentials, etc.) when reporting this issue.
Code to reproduce the issue:
Expected behavior:
Actual behavior:
The room reconnects after sleep and track publications are re-established, but the underlying
MediaStreamTrack
objects for remote tracks havereadyState: 'ended'
and no media is transmitted from remote participants. Each participant sees their own media stream as active, but peers' media streams as empty (black video).room.state
isconnected
.Here is a full log from one of the peers. Included are some expression evaluations which indicate that the remote video publication has
isSubscribed: true, isTrackEnabled: true
, the track hasisEnabled: true
, and the MediaStreamTrack hasreadyState: ended
. However, when inspecting the corresponding local stream track (which the other peer client sees asreadyState: ended
), thereadyState
islive
(as seen on the last line).No error events are emitted. From a client perspective it appears as if the room reconnection was successful and all local tracks are published and streaming, but all peers receive empty tracks and the client cannot see or hear anyone else despite receiving their publications.
If new publications or new peers join, we see a new behavior - the peers are shown, and remote track publications are added, but they are never subscribed and
.track
staysnull
. When a new peer joins a client which was sleeping, the sleeping client's tracks are likewise unsubscribed and never subscribe. Both clients show their own local tracks as published and active.So, to summarize:
ended
state.Software versions:
If anyone can find a workaround or way to detect this bad state I'd be fine with that. The browser does not give any indication of power state changes that I'm aware of, and I can't use the page visibility API as I don't want to assume a failure if the user just switches tabs or minimizes the app.
I've tested reconnections in other scenarios, including loss of internet (via disabling the device or poor connection), and they don't reproduce this behavior. It seems consistently tied to cycling sleep. While this may seem like an edge case, our app has long-lived sessions and we regularly see users sleep their computers while a tab is open. In these cases users may return to the tab later and be confused when A/V is (silently) not working or may not even notice the problem until later.
The text was updated successfully, but these errors were encountered: