Skip to content
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

fix video track lost for migration on safari #419

Merged
merged 3 commits into from
Aug 30, 2022
Merged

Conversation

cnderrauber
Copy link
Contributor

In case of session migration, safari have chance not fire the stream.onremovetrack event, so the RemoteTrack are not cleared, will be set again by the same remote track then cause the track detach and not attached, then some video tracks are disappeared in ui

@changeset-bot
Copy link

changeset-bot bot commented Aug 29, 2022

🦋 Changeset detected

Latest commit: 73c9630

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -129,6 +129,9 @@ export default class RemoteTrackPublication extends TrackPublication {
setTrack(track?: RemoteTrack) {
const prevStatus = this.subscriptionStatus;
const prevTrack = this.track;
if (!!prevTrack === !!track) {
Copy link
Contributor

@lukasIO lukasIO Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the commit message sounds like you'd want to know if track and prevTrack are the same, but this check here would return always if track and prevTrack are either both set or both undefined.
I'm wondering if there's any part where we'd expect setTrack to work even if a previous (different) track had been set.

Copy link
Contributor Author

@cnderrauber cnderrauber Aug 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a case that old track not cleared and new track fired, then prevTrack and track are both set. That cause prevTrack detached and new track not attached, that's why safari lost video tracks on UI.
If !!prevTrack === !!track means they are either both set or both undefined, does the below code will subscribed not fired if they are both set.

    if (!!track !== !!prevTrack) {
      // when undefined status changes, there's a subscription changed event
      if (track) {
        this.emit(TrackEvent.Subscribed, track);
      } else if (prevTrack) {
        this.emit(TrackEvent.Unsubscribed, prevTrack);
      }
    }

I see @davidzhao add this code, any suggesstions about this?

@cnderrauber cnderrauber merged commit 84a96b2 into main Aug 30, 2022
@cnderrauber cnderrauber deleted the safari_migration branch August 30, 2022 06:28
@github-actions github-actions bot mentioned this pull request Aug 30, 2022
max-b pushed a commit to Invisv-Privacy/client-sdk-js that referenced this pull request Oct 4, 2022
* don't detach track when same mediatrack received

* changeset

* attempt

Co-authored-by: David Zhao <dz@livekit.io>
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.

3 participants