Coder Social home page Coder Social logo

Comments (9)

nsmithdev avatar nsmithdev commented on June 16, 2024

I'm running the newest version of Chrome on windows 11 with the newest version twilio-video.js
The app is written in Angular.

from twilio-video.js.

BrandonChristensenCS avatar BrandonChristensenCS commented on June 16, 2024

We are having and identical issue to this.

from twilio-video.js.

nsmithdev avatar nsmithdev commented on June 16, 2024

It seems to be related to publishing all 3 at once because when I unpublish and re-publish just the data track by itself it seems to work fine most of the time.

from twilio-video.js.

dlippy avatar dlippy commented on June 16, 2024

Seeing the same issue. On initial page load it works fine but eventually as remote participants connect and disconnect to the room we don't reliably get the trackSubscribed for datatracks (or at least usually do not).

What we see is that in particpantConnected datatracks is always empty so assume that is intended. But after first loading the page we always get trackSubscribed for the datatrack (always last also). If the same user (or other users) then disconnects and reconnects to the room we still get trackSubscribed for all video tracks and audio tracks they are publishing (with our app it is two video and one audio) but never get it for the datatrack.

Refreshing the page fixes.

from twilio-video.js.

zmmcginnis avatar zmmcginnis commented on June 16, 2024

We are seeing this same issue as well.

from twilio-video.js.

nsmithdev avatar nsmithdev commented on June 16, 2024

I have a minimal reproduction with plain js. You have to have two pages with a deferent identity for each page and the server side to generate the JWT tokens.

<!DOCTYPE html>
<html>
<body>
    <script src="js/twilio-video.js"></script>
    <style>
        button {
            width: 200px;
        }
    </style>
    <div>
        <br />
        <br />
        <button onclick="publishAll()">Share All</button>
        <button onclick="unPublishAll()">Unshare All</button>
        <br />
        <br />
        <button onclick="publishData()">Share Data</button>
        <button onclick="unPublishData()">Unshare Data</button>
    </div>
    <script src="twilio-helpers.js"></script>
    <script>
        runSetup('person2').then(() => console.log('done'));
    </script>
</body>
</html>
// twilio-helpers.js
var req = new XMLHttpRequest();
var audioVideoTracks = [];
var dataTrack = new Twilio.Video.LocalDataTrack({name: 'data'})
var room = null;

async function runSetup(identity) {
    await initializeMedia();
    var token = await getTwillioToken(identity);
    console.log(token);
    room = await connectRoom(token);
    console.log(room);
    roomConnected(room);
}

async function initializeMedia() {
    const settings = {
        video: true,
        audio: true,
    }
    const media = await navigator.mediaDevices.getUserMedia(settings);
    console.log(media);
    userVideoTrack = new Twilio.Video.LocalVideoTrack(media.getVideoTracks()[0], { name: 'video', logLevel: 'warn' });
    console.log(userVideoTrack);
    userAudioTrack = new Twilio.Video.LocalVideoTrack(media.getAudioTracks()[0], { name: 'audio', logLevel: 'warn' });
    console.log(userAudioTrack);
    audioVideoTracks = [userVideoTrack, userAudioTrack];
}

function getTwillioToken(identity) {
    return new Promise((resolve, reject) => {
        const req = new XMLHttpRequest();
        req.onload = (e) => {
            const response = JSON.parse(req.responseText);
            resolve(response.token);
        };
        req.onerror = () => reject();
        req.open("GET", `/home/GetTwilioToken?id=${identity}`);
        req.send();
    });
}

async function connectRoom(token) {
    const options = {
        name: 'TheRoomName1',
        audio: true,
        video: true,
        tracks: [...audioVideoTracks, dataTrack],
    };
    return Twilio.Video.connect(token, options);
}

function roomConnected(room) {
    room.participants.forEach((p) => participantConnected('forEach', p));
    room.on('participantConnected', (p) => participantConnected('event', p));
    room.on('participantDisconnected', (p) => console.log('participantDisconnected', p));
    room.on('disconnected', (p) => console.log('participantDisconnected', room.participants, p));
}

function participantConnected(calledFrom, participant) {
    console.log('==============================');
    console.log('participantConnected', calledFrom, participant);
    participant.tracks.forEach((track) => console.log('trackSubscribed', 'forEach',track));
    participant.on('trackSubscribed', (track) => console.log('trackSubscribed', 'event', track));
    participant.on('trackUnsubscribed', (track) => console.log('trackUnsubscribed', 'event', track));
}

function publishAll() {
    console.log('Publish All CLick', '==================');
    room.localParticipant.publishTracks([...audioVideoTracks, dataTrack]);
}

function unPublishAll() {
    console.log('UnPublish All CLick', '================');
    room.localParticipant.unpublishTracks([...audioVideoTracks, dataTrack]);
}

function publishData() {
    console.log('Publish Data CLick', '================');
    room.localParticipant.publishTracks([dataTrack]);
}

function unPublishData() {
    console.log('UnPublish Data CLick', '==============');
    room.localParticipant.unpublishTracks([dataTrack]);
}

from twilio-video.js.

dlippy avatar dlippy commented on June 16, 2024

It seems to be related to publishing all 3 at once because when I unpublish and re-publish just the data track by itself it seems to work fine most of the time.

Delaying publish doesn't solve the issue for us. Our work around is currently to send a message indicating data track not received so that the participant can unpublish current data track and republish (and just keep doing this until it shows up).

from twilio-video.js.

dallinskinner avatar dallinskinner commented on June 16, 2024

I am having this same issue. When both participants connect the first time everything is fine but if one participant disconnects and reconnects the trackSubscribed event never fires for the data track. I receive a published event for the track but isSubscribed is false and the track property on the RemoteDataTrackPublication is always null.

I tried delaying the publish up to 10 seconds after the audio/video tracks but it does not affect anything. This makes it seem like it has something to do with the disconnect/connect more so than publishing all 3 tracks at the same time.

from twilio-video.js.

taitruong007 avatar taitruong007 commented on June 16, 2024

I am having this same issue. When both participants connect the first time everything is fine but if one participant disconnects and reconnects the trackSubscribed event never fires for the data track. I receive a published event for the track but isSubscribed is false and the track property on the RemoteDataTrackPublication is always null.

I tried delaying the publish up to 10 seconds after the audio/video tracks but it does not affect anything. This makes it seem like it has something to do with the disconnect/connect more so than publishing all 3 tracks at the same time.

Hi @dallinskinner .
May I know if the issue has been solved yet? 🙏
Recently, I noticed this issue when testing with Chrome (Version 124.0.6367.207 (Official Build) (arm64)), the issue did not happen when I tested with Safari (Version 15.3 (17612.4.9.1.5)) and Firefox (Version 126.0 (64-bit)).

from twilio-video.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.