twilio / twilio-video.js

Twilio’s Programmable Video JavaScript SDK
https://www.twilio.com/docs/video/javascript
Other
571 stars 217 forks source link

Freshly added video track (screen capture) does not behaves properly on getStats on remote participant #127

Closed mpszczolinski closed 4 years ago

mpszczolinski commented 7 years ago

I've added correct screen capture screen to localParticipant tracks. It shows properly on remote participant, but when using "room.getStats().then(...)" the properties of this track are all null (like dimensions, packetsSend etc.) I've verified and it works correctly when track are added before joining room. So the problem is only when track is added dynamically, like this:

  1. userA joins room with audio+video
  2. userB joins room with audio+video
  3. room.getStats() works 100% ok
  4. userA adds track with screen capture stream (on Chrome 58.0.3029.110 (64-bit))
  5. the room.getStats() has data for new added stream, but it's properties are null/undefined

    • [x] 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.
    • [x] I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
    • [x] I verified that the Quickstart application works in my environment.
getUserScreen(['window', 'screen', 'tab'], 'id-to-chrome-extension')
  .then(function(stream) {
    const screenLocalTrack = new Twilio.Video.LocalVideoTrack(stream.getVideoTracks()[0]);
    var addedTrack = vm.twilio.room.localParticipant.addTrack(screenLocalTrack); // vm.twilio.room is a reference to twilio's 'room'
});

Expected behavior: When I add video track dynamically (after joining room) - the getStats().then(...) has correct statistic data of all (also freshly added) tracks.

Actual behavior: the freshly added video track has statistic data properties set to null/undefined

Software versions:

manjeshbhargav commented 7 years ago

@mpszczolinski ,

Thanks for bringing this to our attention. We will try and reproduce this on our end, and get back to you with an update shortly.

Thanks,

Manjesh Malavalli Video JavaScript SDK Team

markandrus commented 7 years ago

Hi @mpszczolinski,

We think this is fixed as of twilio-video.js@1.2.2. Can you please re-test and let us know if it fixed your issue?

Thanks, Mark

mpszczolinski commented 7 years ago

issue fixed, but it caused another issue.

When I stop screensharing, so a video stream (from laptop camera) is being re-added to tracks, its stats are frozen (no longer updates).

So what I am doing:

  1. tracks contains video(camera) track
  2. screensharing started
  3. remove video(camera) track [using localParticipant.removeTrack() ]
  4. add screensharing track [using localParticipant.addTrack(screenLocalTrack) ] -- stats works fine --
  5. stop screensharing, removed screensharing track [using localParticipant.removeTrack(event.currentTarget) ]
  6. re-add video(camera) track [using localParticipant.addTracks(removedVideoTracks)] -- at this point video(camera) stats are frozen --
mpszczolinski commented 7 years ago

ok, so I fixed it by creating new localVideoTrack [ Video.createLocalVideoTrack() ] and adding it to tracks (rather the readding previously removed track).

GENERAL CONCLUSION: My general conclusion is that when track is removed from tracks, but kept in memory, and then reattached to tracks - it behaves differently than new created tracks. There may be some bug/issue in code.

best regards Guys! :)

markandrus commented 6 years ago

Just an update here: in general this should be much-improved in twilio-video.js 2.x due to some changes around how we manage the underlying MediaStreamTracks.