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(audio-mute): fix sometimes out-of-sync remote audio mute #3797

Merged

Conversation

chburket
Copy link
Contributor

@chburket chburket commented Aug 28, 2024

COMPLETES

https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-555818

This pull request addresses

Fixes a BEMS case defect where remote audio mute can get out of sync with local audio mute.

BEMS space: webexteams://im?space=c4706ce0-56e0-11ef-81df-a39e6dd40a42

Steps to recreate bug:

  1. start a meeting as host, unmuted
  2. uncheck "allow participants to unmute"
  3. mute
  4. unmute
  5. mute (problem: sdk's representation of server remote audio is still unmuted)
  6. unmute (because sdk thinks remote is already unmuted, we do not try to change it)

The server remote audio is still muted (notice the muted icon in the participant list)
With the fix, the server remote audio is unmuted as expected.

by making the following changes

First, I needed to revert a fix from months ago. This fix was causing the locus diff update from step 5 to be skipped because the modifiedBy value was the same as the local user. We did not skip the update in step 3 because modifiedBy was undefined. I met with Rajesh Kadikar about this and he indicated that the modifiedBy should contain the current user in this scenario, and that we should not be skipping locus updates, even it they were modified by the current user.

Second, I needed to find a new way to fix what was reverted. I added console.logs in various places in the flow and found that if you unmute and mute quickly, _LocalMicrophoneStream.setUserMuted(true) happens before we receive the locus diff from the unmute. When the locus diff eventually comes in, handleServerRemoteMuteUpdate() unmutes the local stream to match the remote mute state, which should not be done. So I added an if around the local stream update to only execute it when muting, not unmuting.

While testing this PR, I found a few problems around host mute/unmute (unrelated to this change) and opened these Jiras:

https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-559101
https://jira-eng-gpk2.cisco.com/jira/browse/SPARK-559095

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios where tested

Manually tested the scenario in the BEMS Jira (SPARK-555818).
Manually tested the scenario in a related BEMS Jira.
Manually tested the scenario from the reverted PR/Jira.
Manually tested host unmuting a user when in a moderated meeting.

Updated unit tests.

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly

@chburket chburket marked this pull request as ready for review August 28, 2024 13:37
@chburket chburket requested review from a team as code owners August 28, 2024 13:37
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3797.d3m3l2kee0btzx.amplifyapp.com

@chburket chburket added the validated If the pull request is validated for automation. label Aug 28, 2024
@chburket chburket marked this pull request as draft August 28, 2024 14:15
@chburket chburket force-pushed the SPARK-555818-out-of-sync-remote-audio-mute branch from 7929174 to 7eac0be Compare September 3, 2024 19:24
Comment on lines -431 to -435
// there is no need to trigger user update if no one muted user
if (changedSelf.selfIdentity === changedSelf.modifiedBy) {
return false;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted because this was causing the BEMS bug

Copy link
Collaborator

Choose a reason for hiding this comment

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

note to self, ask about this if not resolved lower. edit: resolved in next file

Comment on lines 382 to 386

// never want to unmute the local stream from a server remote mute update
if (muted) {
this.muteLocalStream(meeting, muted, 'remotelyMuted');
}
Copy link
Contributor Author

@chburket chburket Sep 3, 2024

Choose a reason for hiding this comment

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

New way to fix the bug that was fixed by the code I reverted. This is not called when the the meeting is in moderated mode and the host unmutes a user, so it did not affect that.

Comment on lines -360 to -364
it('should return false when selfIdentity and modifiedBy are the same', function() {
assert.equal(SelfUtils.mutedByOthersChanged(
{ remoteMuted: false },
{ remoteMuted: true, selfIdentity: 'user1', modifiedBy: 'user1' }
), false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this

@chburket chburket marked this pull request as ready for review September 3, 2024 20:40
Comment on lines -431 to -435
// there is no need to trigger user update if no one muted user
if (changedSelf.selfIdentity === changedSelf.modifiedBy) {
return false;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

note to self, ask about this if not resolved lower. edit: resolved in next file

@@ -379,7 +379,11 @@ export class MuteState {
}
if (muted !== undefined) {
this.state.server.remoteMute = muted;
this.muteLocalStream(meeting, muted, 'remotelyMuted');

// never want to unmute the local stream from a server remote mute update
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -113,6 +113,30 @@ describe('plugin-meetings', () => {
assert.isTrue(audio.isRemotelyMuted());
});

it('does not locally unmute on a server unmute', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice test


// never want to unmute the local stream from a server remote mute update
if (muted) {
this.muteLocalStream(meeting, muted, 'remotelyMuted');
Copy link
Collaborator

Choose a reason for hiding this comment

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

this logic makes sense and is a lot cleaner

@chburket chburket enabled auto-merge (squash) September 4, 2024 16:57
@chburket chburket merged commit d354100 into webex:next Sep 4, 2024
11 checks passed
@chburket chburket deleted the SPARK-555818-out-of-sync-remote-audio-mute branch September 4, 2024 17:15
pagour98 pushed a commit to pagour98/webex-js-sdk that referenced this pull request Sep 27, 2024
pagour98 pushed a commit to pagour98/webex-js-sdk that referenced this pull request Sep 27, 2024
marcin-bazyl added a commit to marcin-bazyl/webex-js-sdk that referenced this pull request Nov 20, 2024
marcin-bazyl added a commit to marcin-bazyl/webex-js-sdk that referenced this pull request Nov 20, 2024
marcin-bazyl added a commit to marcin-bazyl/webex-js-sdk that referenced this pull request Dec 20, 2024
marcin-bazyl added a commit to marcin-bazyl/webex-js-sdk that referenced this pull request Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants