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

Sometimes others don't receive video/screenshare #1997

Closed
psi-4ward opened this issue Apr 28, 2022 · 8 comments
Closed

Sometimes others don't receive video/screenshare #1997

psi-4ward opened this issue Apr 28, 2022 · 8 comments

Comments

@psi-4ward
Copy link
Contributor

Hey Mates,
sometimes other participants do not receive the video / screenshare.

  • No JS Errors
  • WebRTC shows outgoing (on sender) and incoming (receiver) tracks
  • Seems the presence messages gets not send in some cases.

We assume a timing problem of the appearance of the tracks in peerconnection and rtc. The tracks should first be in peerconnection cause of the add-source msg so the code in _updateRoomPresence should trigger the presenceChanged but why if (!localVideoTracks?.length) { ?
The ! does kill the logic, doesn't it?

@jallamsetty1 ;-)

@jallamsetty1
Copy link
Member

The tracks should first be in peerconnection cause of the add-source msg so the code in _updateRoomPresence should trigger the presenceChanged but why if (!localVideoTracks?.length) { ?

If the local track has already been added to the peerconnection, the presence will be sent if it needs to be updated - https://github.com/jitsi/lib-jitsi-meet/blob/master/JitsiConference.js#L3666
Can you pls add steps for reproduction ?

@psi-4ward
Copy link
Contributor Author

In L3666 we've iterated localTracks which is this.rtc.getLocalTracks(mediaType); and not jingleSession.peerconnection.getLocalTracks().

To reproduce the issue is hard cause it seems sometimes the precenceChanged is false but it should be true. My users report the issue most if (a smaller window) gets shared. To see the error we need to enable/disable/enable the sharing several times.

But no matter how:

        if (!localVideoTracks?.length) {
            videoMuteStatusChanged = this._setTrackMuteStatus(MediaType.VIDEO, undefined, true);
            videoTypeChanged = this._setNewVideoType();
        }

If not localVideoTracks.length do setTrackMuteStatus() ... Why to set some Track-State if theres no track?

@jallamsetty1
Copy link
Member

In L3666 we've iterated localTracks which is this.rtc.getLocalTracks(mediaType); and not jingleSession.peerconnection.getLocalTracks().

I can change that to use the local tracks from the jingle session but they are ideally in sync. Any source that gets removed from the peerconnection gets removed from the rtc local tracks as well. Are you seeing this issue on a custom client using the library or on a jitsi-meet client ?

To reproduce the issue is hard cause it seems sometimes the precenceChanged is false but it should be true. My users report the issue most if (a smaller window) gets shared. To see the error we need to enable/disable/enable the sharing several times.

But no matter how:

        if (!localVideoTracks?.length) {
            videoMuteStatusChanged = this._setTrackMuteStatus(MediaType.VIDEO, undefined, true);
            videoTypeChanged = this._setNewVideoType();
        }

If not localVideoTracks.length do setTrackMuteStatus() ... Why to set some Track-State if theres no track?

The track mute state needs to be updated in presence when a track is removed

videoMuteChanged = this.room.addVideoInfoToPresence(isMuted);

@smilingthax
Copy link

Part 1

The basic issue is that in a Conference occasionally when User A starts desktop sharing, but at User B the stream does not appear.
Looking at the JS logs and XMPP messaging, we know that User B does receive the source-add, but does not receive a presence update.
We can see APP.conference._room.participants[...sender-ep-id...]._tracks[0] .muted=true, .videoType='camera' (expected would be false / 'desktop').
When calling .setMute(false) at the JS console of User B the stream is shown.

In the XMPP messaging User A does not send <presence>, when the issue is hit (when the issue is not hit, a <presence> with <videomuted>false</videomuted> and `desktop is sent, and everything works correctly).

From our understanding, after SOURCE_ADD the presence should be sent here:
https://github.com/jitsi/lib-jitsi-meet/blob/master/JitsiConference.js#L3684
At User A we put a breakpoint into the function and could verify that presenceChanged is true in case everything works, but false when the <presence> is missing.
In that latter case we found localTracks.length = 0.

Part 2

We also made the following observations (btw, we're using an only slightly modified jitsi-meet frontend/client):

  1. We were not able to trigger the issue before 55131be#diff-b2f6195536d4c09eac93cd5482c9258cae0dc21129fca78a125fe545594eca30L36
  2. We'd expect(ed) the issue to be solved with 474b2ec#diff-b2f6195536d4c09eac93cd5482c9258cae0dc21129fca78a125fe545594eca30R3668 , but can still trigger it.

Comparing the code pre-/post commit 55131be we can see that

    const localAudioTracks = jingleSession.peerconnection.getLocalTracks(MediaType.AUDIO);		
    const localVideoTracks = jingleSession.peerconnection.getLocalTracks(MediaType.VIDEO);

was replaced with

    const localTracks = this.getLocalTracks();

which in 474b2ec was further changed to

    const localTracks = this.getLocalTracks();
    const localAudioTracks = jingleSession.peerconnection.getLocalTracks(MediaType.AUDIO);
    const localVideoTracks = jingleSession.peerconnection.getLocalTracks(MediaType.VIDEO);

We therefore know code pre-1. is working, but code post-1/pre-2. and post-2. is not, although pre-1. and post-2. are closer together in that they both use jingleSession.peerconnection.getLocalTracks(...)– and not just getLocalTracks(), which seems to unexpectedly return .length = 0 in some cases (?!?) – but the logic of using them is still different in that pre-55131be9e66991a6cc9f3d910913607edbcb012e presenceChanged was (possibly) set in the if-branch if (localVideoTracks && localVideoTracks.length) { (for localVideoTracks[0] - same for audio) AND in the else part (for undefined).

It might be that 474b2ec tries to fix another issue (related to source-remove?), but at least it touches the same code areas...

Bottom line

We are not entirely sure why this.getLocalTracks() (i.e. this.rtc.getLocalTracks()) seems to be out-of-sync with jingleSession.peerconnection.getLocalTracks(...) at that particular point in time (during the callback of sendIq(...source-add..., callback, ...)), but it seems to happen more frequently with win11 (chrome) – and anecdotally, when sharing smaller windows (?). Also sharing the desktop with audio instead of without seems to significantly reduce (maybe even completely eliminate?) occurrences of the issue. This seems to point to some race condition / timing issue between the time the track gets added to this.getLocalTracks() and the invocation of the callback...

@jallamsetty1
Copy link
Member

@smilingthax Thanks for providing the details, is this happening on both p2p and jvb connections ?

@smilingthax
Copy link

We only use jvb connections, no p2p.

jallamsetty1 added a commit to jallamsetty1/lib-jitsi-meet that referenced this issue May 2, 2022
Removing and adding a track back to the conference doesn't generate new source signaling all the time so presence needs to be updated every single time.
Fixes https://community.jitsi.org/t/screen-share-doesnt-work-a-second-time-on-p2p/114024 and possibly jitsi#1997.
jallamsetty1 added a commit that referenced this issue May 2, 2022
Removing and adding a track back to the conference doesn't generate new source signaling all the time so presence needs to be updated every single time.
Fixes https://community.jitsi.org/t/screen-share-doesnt-work-a-second-time-on-p2p/114024 and possibly #1997.
@jallamsetty1
Copy link
Member

@psi-4ward, I have merged a possible fix. Can you let me know if this fixes your issue ? I have no way of reproducing this exact case but it fixes another related issue.

@psi-4ward
Copy link
Contributor Author

psi-4ward commented May 2, 2022

Looks good! Our qa engineer tested screenshare toggling about 50x with no issues so far.

Nice job @jallamsetty1 👍🏻

brajendrak00068 added a commit to SariskaIO/sariska-media-transport that referenced this issue Jun 20, 2022
* fix(SDP) Always modify the streamId part of msid when source-name signaling enabled.
Do this even if the browser provides a non '-' string for streamId since we rely on this to generate the source name.

* fix(multi-stream) Update the <ssrc, source-name> map for p2p as well.

* fix(conference) Disable p2p between eps running in different SDP modes.
Disable p2p between endpoints that are not running in the same SDP mode. The source-add/source-remove handlers assume the mids to follow the same pattern on both self and peer but the mids generated in plan-b mode are different from unified plan mode. Fixes jitsi/jitsi-meet#11100.

* fix(SDP) fix unit test for LocalSdpMunger.

* chore(deps): bump minimist from 1.2.5 to 1.2.6

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(multi-stream) fix p2p issues with secondary video sources.

* fix(multi-stream) add new m-line when remote adds a second video source in p2p.
A new m-line needs to be added in the remote description when a new secondary video source is signaled by the peer.

* fix(TPC) Suppress lower layers only for screenshare tracks.
With multi-stream support enabled, an extra check for videoType for local track is needed to dtermine if the lower layers need to be suppressed.

* fix(TPC) Mark the direction inactive on inactive media connection.
If a new secondary video source is added on the jvb connection while p2p is active, make sure the direction is set to inactive on the jvb connection, so that no media is being sent out on the jvb connection.

* squash: Address review comments.

* fix(BreakoutRooms) fix checking for isBreakoutRoom early

* Plumbing for e2e pings. (#1973)

* Plumbing for e2e pings.
* linter fixes
* Re-use existing event instead of introducing a new one.

* fix(presence) Parse peer presence in legacy format correctly.
When source-name signaling is enabled, get correct peermedia info when the peer sends presence in the legacy format. This fixes an issue where Jigasi users cannot be heard by endpoints that have source-name signaling enabled.

* ref(face-expressions) refactor face landmarks namings (#1977)

* fix(presence): send presence update when a local track is removed.
When a screenshare track is removed in the legacy mode, presence needs to be sent with the muted state and videoType so the remote gets updated.

* fix(presence) Only apply default videoType on video tracks

* fix: p2p reject reason (#1840)

* fix(BridgeChannel): re-send constraints and videoType message after every re-connect.
This fixes an issue where the receiver constraints and video type messages are sent on the bridge channel only the first time the ws conn gets re-established.

* fix(video-quality) Update frame heights in content-modify for p2p. (#1983)

* fix(video-quality) Update frame heights in content-modify for p2p.
When the user changes the preferred video quality settings from the UI, update the frame height values in content-modify for p2p connection when source-name signaling is enabled.

* fix(multi-stream) Send presence for desktop track before signaling when it is the first track to be added to the conference.
Also do not suppress renegotiation for desktop track on p2p since the browser doesn't fire negotiation needed event.

* squash: fix build

* squash: fix linter issues

* squash: add comment.

* fix: Cleanups JitsiConference on reservation and max user failures.  @damencho (#1986)

* Revert "fix: Cleans up rooms after failure to join."

This reverts commit f23372d.

* fix: Cleanups JitsiConference on reservation and max user failures.

* fix(multi-stream) Send the initial session-accept and then add the secondary video tracks when a session is re-created (#1987)

* new changes from origin master

* fix: Cleanups chat room on destroy.

Discovered it during investigation of
jitsi/jicofo#905

* chore(deps) bump async from 0.9.0 to 3.2.3

* fix(browser-support) Enable device selection in mobile Safari.
With https://bugs.webkit.org/show_bug.cgi?id=179363 being fixed, we should now be able to switch between devices in call.

* feat: Add an option to set bogus resolution constraints for getDisplayMedia. (#1991)

* feat: Add an option to set bogus resolution constraints for getDisplayMedia.

* fix(multi-stream) Inject multiple SIM groups on Firefox when multiple sources are added.

* JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED expose jitsiTrack as listener parameter (#1984)

* provide jitsiTrack as parameter of the listeners on JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED

* reorder params

* feat(ssrc-rewriting) Add a flag to signal support for ssrc re-writing to Jicofo.

* feat: add AV1 mime type (#1990)

With that, it's possible to set AV1 as preferred codec for p2p and try it on Chrome.

* fix(BrowserCapabilities) Fallback to plan-b for Electron clients that have chromium ver < 96.

* fix(RTC) Add AV1 to CodecMimeType unit test

* fix(multi-stream) Set the source name of replaced track before configuring it.
With just source-name enabled, set the source name of the replaced track before configuring the encodings, this fixes an issues where the sender constraints are not applied on the p2p connection because the source name is undefined.

* fix(presence) Send a presence update on every track replace operation.
Removing and adding a track back to the conference doesn't generate new source signaling all the time so presence needs to be updated every single time.
Fixes https://community.jitsi.org/t/screen-share-doesnt-work-a-second-time-on-p2p/114024 and possibly jitsi/lib-jitsi-meet#1997.

* fix(stats) Emit stats using source name as key (#1996)

This allows us to display resolution and framerate stats on separate tiles when multi-stream mode is enabled.

* feat: Adds a flag runInLiteMode useful for testing.

Enables lite mode which disables any media decoding.

* fix(rtc): fix local track removeTrack promise conference check (#1797)

* fix(rtc): fix local track removeTrack promise conference check

* ref: ignore if promise was successful or not

* fix(device-selection) Support multiple audio inputs in Firefox 101 (#1988)

* fix(multi-stream): Fix local SSRC cache to include multiple video streams. (#2006)

* fix(multi-stream): Fix local SSRC cache to include multiple video streams.
If multiple local video streams are found in the SDP, cache all of them instead of the first video SSRC. This fixes an issue where the resolution/fps stats for the screenshare track are not available.

* squash: new track inherits the source name of old track if it exists.

* fix(SDP): Reset sources to MSID map for plan-b clients.
When source-name signaling is enabbled on plan-b clients, the sources to MSID map needs to be cleared after every transformation since browser in plan-b mode produces a new set of SSRCs and trackID when a track is removed and new track is added to the peerconnection. This fixes an issue where the track index in the source-name gets incremented after a track replace operation.

* feat: Handles release number coming from backend.

Adds it to deploymentInfo.

* feat: Updates deployment info key for release and push to analytics.

* fix(device-change): enable on iOS Safari < 15.4

* fix(RTC): Add function declaration to JitsiTrack.
RN clients throw a function undefined error otherwise.

* Revert "fix(RTC): Add function declaration to JitsiTrack."

This reverts commit 7d3f13c.
This change was not needed.

* feat(RTC) drop no longer supported PC media constraints

They have been deprecated and their valued can no longer be changed from
the default after M103.

Ref: https://groups.google.com/u/0/g/discuss-webrtc/c/2l7jWgreYpw?pli=1

* fix(deployment-info) Prevent error when setting shard and region (#2017)

* fix(deployment-info) Prevent error when setting shard and region

* fix

* fix(docs) Added docs on how to define tokens (#2018)

* added docs on how to define tokens

* fixed typo

Co-authored-by: James Green <james.green@affinity-digtal.com>

* fix(types) remove setSuspendVideo declaration

related to 5966576

* fix(JitsiConference) log a warning instead of an error is p2p fails

In most cases it's not a real issue and it's still part of the logs,
throwing an unhandled exception at the global handler just prints an
ugly trackeback in the JS console which looks much worse than it really
is.

* fix(docs) improve documentation that jwt works on websocket

see https://community.jitsi.org/t/lib-jitsi-meet-jwt-support-with-websockets/79806

* fix(presense) don't lose prev presenceChanged value

* fix(TPC) Stop munging remote desc for imploding the SIM groups.
Jicofo by default now strips the simulcast SSRCs and sends only the primary SSRC and RTX to all the receiving endpoints in the call. Therefore remote SDP munging is not required on the clients anymore.

* fix(SignalingLayer): Skip checking for last presence if the client doesn't join muc.

* fix(SignalingLayer): Skip checking for last presence if the client doesn't join muc.
This fixes the broken wireless screensharing issue on spot clients.

* squash: change log message to a warning.

* fix(e2ee) keeps the initial key when decryption error

* fix(e2ee) adds promise to map when sending key onParticipantPropertyChanged

* ref(e2ee) change jsdoc return to correct promise

the editor will no longer complain about superfluous await when calling these functions

* ref(e2ee) make tests compatible with new karma/jasmine versions

it removed support for functions being simultaneous async and have done parameter in callback

* fix(ts) rebuild to fix types after jsdoc changes

* ref(e2ee) mark _decryptFrame function with correct jsdoc

the editor will no longer complain about superfluous await when calling

* fix(breakout-rooms) Change callstats confID for breakout rooms

* Add comment

* fix(SS): missing remote screenshare

Reusing(removing it and adding it again) an SSRC in the
remote SDP is leading to the issue where remote video is received but
not rendered. That's why we shouldn't remove the receive only SSRCs
from the SDP. This way the sender won't send any source-remove and
source-add for the same SSRCs.

* fix(SS):Don't send source-remove/add for FF

* sync with master

* fix(SDP): don't separate fmtp parameter with spaces (#2034)

* fix(SDP): don't separate fmtp parameter with spaces

* adjusted tests accordingly to not expect spaces anymore

* default to source name signaling

* default to source name signaling

Co-authored-by: Jaya Allamsetty <54324652+jallamsetty1@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Saúl Ibarra Corretgé <saghul@jitsi.org>
Co-authored-by: George Politis <gp@jitsi.org>
Co-authored-by: Avram Tudor <tudor.potecaru@8x8.com>
Co-authored-by: Jorge Oliveira <neweracracker@gmail.com>
Co-authored-by: Paul Tiedtke <PaulTiedtke@web.de>
Co-authored-by: Дамян Минков <damencho@jitsi.org>
Co-authored-by: brajendrak00068 <brajendra@Brajendras-MacBook-Air-M1.local>
Co-authored-by: bgrozev <boris@jitsi.org>
Co-authored-by: pangrr <rpang27@bloomberg.net>
Co-authored-by: Paweł Domas <pawel.domas@jitsi.org>
Co-authored-by: Daniel McAssey <DanielMcAssey@users.noreply.github.com>
Co-authored-by: Nicolas Thumann <me@n-thumann.de>
Co-authored-by: Hristo Terezov <hristo@jitsi.org>
Co-authored-by: Horatiu Muresan <39557534+horymury@users.noreply.github.com>
Co-authored-by: James Green <91469943+james-green-affinity@users.noreply.github.com>
Co-authored-by: James Green <james.green@affinity-digtal.com>
Co-authored-by: Tobias Schneider <Tobias.Schneider@Tobsch.org>
Co-authored-by: cinques <cinquestyle@gmail.com>
Co-authored-by: titus.moldovan <titus.moldovan@8x8.com>
Co-authored-by: robertpin <robert.pin9@gmail.com>
Co-authored-by: Nils Ohlmeier <nils-ohlmeier@users.noreply.github.com>
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

No branches or pull requests

3 participants