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

"Track name is duplicated" error when unpublishing/publishing track during reconnection #1227

Open
8 tasks done
jsdream opened this issue Oct 14, 2020 · 8 comments
Open
8 tasks done
Assignees
Labels
bug filed A bug has been filed upstream for this issue

Comments

@jsdream
Copy link

jsdream commented Oct 14, 2020

  • I have verified that the issue occurs with the latest twilio-video.js release and is not marked as a known issue in the CHANGELOG.md.
  • I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
  • I verified that the Quickstart application works in my environment.
  • I am not sharing any Personally Identifiable Information (PII)
    or sensitive account information (API keys, credentials, etc.) when reporting this issue.

Expected behavior:

Unpublishing and then publishing local track while the connection is lost should not cause any issues upon reconnection.

Actual behavior:

In our case, if we unpublish an audio track and publish a new one with the same name while there is a reconnection, upon successful reconnection we'll get a "Track name is duplicated" error.

The main problem here seems to be is that we can't reliably know either track was actually unpublished in the Twilio backend or not, as there is no 'trackUnpublished' event for the local participant. These issues I think are related: #657 and #1007.

In our setup, in order to mute participants, we completely unpublish the audio track and then republish it when the participant unmutes. So if a participant mutes/unmutes while their connection is lost they will get a "Track name is duplicated" error after their connection eventually restored.

To summarize, I think the problem is the following: when calling localParticipant.unpublishTrack it always removes track locally without taking into account a response from the backend, and then calling localParticipant.publishTrack causes the "Track name is duplicated" error as the previous track was not really unpublished, although local state thinks so.

Also, the initial idea how to fix this was to disable the 'mute' button when Twilio room is in 'reconnecting' state, but this doesn't fix the problem completely as Twilio room does not transition to the 'reconnecting' state immediately after the connection is lost, thus leaving the room for the issue to occur.

Software versions:

  • Browser(s): Chrome 86.0.4240.75
  • Operating System: Windows 10
  • twilio-video.js: 2.7.2
  • Third-party libraries (e.g., Angular, React, etc.): Angular
@jsdream
Copy link
Author

jsdream commented Oct 14, 2020

Update:

It turns out that the track is actually being unpublished after the reconnection, it's just a race condition with the localParticipant.publishTrack call.

So, for now, we ended up with such workaround:

public async publishLocalTrackWithWorkaroundForTrackNameIsDuplicatedError (track: LocalTrack) {
    try {
        await this.currentCall.twilioRoom.localParticipant.publishTrack(track);
    }
    catch (err) {
        if (err && err.code === 53304) {
            await new Promise((resolve, reject) => {
                setTimeout(async () => {
                    try {
                        this.Logger.warn('Attempt to workaround "Track name is duplicated" error');
                        await this.currentCall.twilioRoom.localParticipant.publishTrack(track);
                        resolve();
                    }
                    catch (err) {
                        reject(err);
                    }
                }, 1000);
            });

        }
        else {
            throw err;
        }
    }
}

@darrenmhill
Copy link

Is anyone able to respond to this one please? This is regularly impacting a number of calls and is having a real business impact.

@makarandp0 makarandp0 self-assigned this Oct 19, 2020
@makarandp0
Copy link
Contributor

Thank you for reporting this issue and detailed explanation @jsdream. Yes this looks like a race condition that need to be handled by the SDK. I have filed an internal bug to rack this issue (JSDK-3032)

@darrenmhill - Does the workaround suggested by @jsdream not work in your case?

Thanks,
Makarand

@makarandp0 makarandp0 added the bug filed A bug has been filed upstream for this issue label Oct 19, 2020
@jsdream
Copy link
Author

jsdream commented Oct 20, 2020

Thanks for that @makarandp0!

Looking forward to the proper fix within the SDK.

@darrenmhill
Copy link

Thank you for reporting this issue and detailed explanation @jsdream. Yes this looks like a race condition that need to be handled by the SDK. I have filed an internal bug to rack this issue (JSDK-3032)

@darrenmhill - Does the workaround suggested by @jsdream not work in your case?

Thanks,
Makarand

We have this in place right now, but have not yet explicitly tested it under these conditions.

@darrenmhill
Copy link

Any update on this one please? I think the workaround is working ok, but ideally we'd like a native fix for this.

@grant-with
Copy link

This race condition causes some headaches for us, but we've worked around it by appending a random UUID to our track names and updating our track name checking logic to use trackName.startsWith('camera'), etc instead of doing a strict comparison.

That does mean that a user can briefly have 2 "camera" tracks at once, but this doesn't end up being a problem in practice.

@tmb
Copy link

tmb commented Mar 23, 2022

Is there an update here? We're running into this error with React Hot Reload during dev — workable but quite annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug filed A bug has been filed upstream for this issue
Projects
None yet
Development

No branches or pull requests

5 participants