Skip to content

Commit

Permalink
fix: stop stats analyzer during reconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniow committed Nov 19, 2024
1 parent 9cc28e7 commit 28fcd1d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
12 changes: 12 additions & 0 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6062,6 +6062,8 @@ export default class Meeting extends StatelessWebexPlugin {
// so reset the timer as it's not needed anymore, we want to reconnect immediately
this.reconnectionManager.resetReconnectionTimer();

this.cleanUpBeforeReconnection();

this.reconnect({networkDisconnect: true});

this.uploadLogs({
Expand Down Expand Up @@ -6939,6 +6941,16 @@ export default class Meeting extends StatelessWebexPlugin {
}
}

private async cleanUpBeforeReconnection(): Promise<void> {
// when media fails, we want to upload a webrtc dump to see whats going on
// this function is async, but returns once the stats have been gathered
await this.forceSendStatsReport({callFrom: 'cleanUpBeforeReconnection'});

if (this.statsAnalyzer) {
await this.statsAnalyzer.stopAnalyzer();
}
}

/**
* Creates an instance of LocusMediaRequest for this meeting - it is needed for doing any calls
* to Locus /media API (these are used for sending Roap messages and updating audio/video mute status).
Expand Down
52 changes: 39 additions & 13 deletions packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ describe('plugin-meetings', () => {
}
);
assert.equal(newMeeting.correlationId, newMeeting.id);
assert.deepEqual(newMeeting.callStateForMetrics, {correlationId: newMeeting.id, sessionCorrelationId: ''});
assert.deepEqual(newMeeting.callStateForMetrics, {
correlationId: newMeeting.id,
sessionCorrelationId: '',
});
});

it('correlationId can be provided in callStateForMetrics', () => {
Expand Down Expand Up @@ -3793,12 +3796,12 @@ describe('plugin-meetings', () => {
id: 'fake locus from mocked join request',
locusUrl: 'fake locus url',
mediaId: 'fake media id',
})
});
sinon.stub(meeting.meetingRequest, 'joinMeeting').resolves({
headers: {
trackingid: 'fake tracking id',
}
})
},
});
await meeting.join({enableMultistream: isMultistream});
});

Expand Down Expand Up @@ -3991,7 +3994,10 @@ describe('plugin-meetings', () => {
assert.notCalled(
meeting.sendSlotManager.getSlot(MediaType.AudioMain).publishStream
);
assert.throws(meeting.publishStreams(localStreams), `Attempted to publish microphone stream with ended readyState, correlationId=${meeting.correlationId}`);
assert.throws(
meeting.publishStreams(localStreams),
`Attempted to publish microphone stream with ended readyState, correlationId=${meeting.correlationId}`
);
} else {
assert.calledOnceWithExactly(
meeting.sendSlotManager.getSlot(MediaType.AudioMain).publishStream,
Expand All @@ -4004,7 +4010,10 @@ describe('plugin-meetings', () => {
assert.notCalled(
meeting.sendSlotManager.getSlot(MediaType.VideoMain).publishStream
);
assert.throws(meeting.publishStreams(localStreams), `Attempted to publish camera stream with ended readyState, correlationId=${meeting.correlationId}`);
assert.throws(
meeting.publishStreams(localStreams),
`Attempted to publish camera stream with ended readyState, correlationId=${meeting.correlationId}`
);
} else {
assert.calledOnceWithExactly(
meeting.sendSlotManager.getSlot(MediaType.VideoMain).publishStream,
Expand All @@ -4017,7 +4026,10 @@ describe('plugin-meetings', () => {
assert.notCalled(
meeting.sendSlotManager.getSlot(MediaType.AudioSlides).publishStream
);
assert.throws(meeting.publishStreams(localStreams), `Attempted to publish screenShare audio stream with ended readyState, correlationId=${meeting.correlationId}`);
assert.throws(
meeting.publishStreams(localStreams),
`Attempted to publish screenShare audio stream with ended readyState, correlationId=${meeting.correlationId}`
);
} else {
assert.calledOnceWithExactly(
meeting.sendSlotManager.getSlot(MediaType.AudioSlides).publishStream,
Expand All @@ -4030,7 +4042,10 @@ describe('plugin-meetings', () => {
assert.notCalled(
meeting.sendSlotManager.getSlot(MediaType.VideoSlides).publishStream
);
assert.throws(meeting.publishStreams(localStreams), `Attempted to publish screenShare video stream with ended readyState, correlationId=${meeting.correlationId}`);
assert.throws(
meeting.publishStreams(localStreams),
`Attempted to publish screenShare video stream with ended readyState, correlationId=${meeting.correlationId}`
);
} else {
assert.calledOnceWithExactly(
meeting.sendSlotManager.getSlot(MediaType.VideoSlides).publishStream,
Expand Down Expand Up @@ -4325,14 +4340,14 @@ describe('plugin-meetings', () => {
const handleDeviceLoggingSpy = sinon.spy(Meeting, 'handleDeviceLogging');
await meeting.addMedia({audioEnabled: false});
//calling handleDeviceLogging with audioEnaled as true adn videoEnabled as false
assert.calledWith(handleDeviceLoggingSpy,false,true);
assert.calledWith(handleDeviceLoggingSpy, false, true);
});

it('addMedia() works correctly when video is disabled with no streams to publish', async () => {
const handleDeviceLoggingSpy = sinon.spy(Meeting, 'handleDeviceLogging');
await meeting.addMedia({videoEnabled: false});
//calling handleDeviceLogging audioEnabled as true videoEnabled as false
assert.calledWith(handleDeviceLoggingSpy,true,false);
assert.calledWith(handleDeviceLoggingSpy, true, false);
});

it('addMedia() works correctly when video is disabled with no streams to publish', async () => {
Expand Down Expand Up @@ -4401,12 +4416,11 @@ describe('plugin-meetings', () => {
assert.calledTwice(locusMediaRequestStub);
});


it('addMedia() works correctly when both shareAudio and shareVideo is disabled with no streams publish', async () => {
const handleDeviceLoggingSpy = sinon.spy(Meeting, 'handleDeviceLogging');
await meeting.addMedia({shareAudioEnabled: false, shareVideoEnabled: false});
//calling handleDeviceLogging with audioEnabled true and videoEnabled as true
assert.calledWith(handleDeviceLoggingSpy,true,true);
assert.calledWith(handleDeviceLoggingSpy, true, true);
});

describe('publishStreams()/unpublishStreams() calls', () => {
Expand Down Expand Up @@ -6967,7 +6981,10 @@ describe('plugin-meetings', () => {
assert.deepEqual(meeting.callStateForMetrics, {correlationId, sessionCorrelationId: ''});
meeting.setCorrelationId(uuid1);
assert.equal(meeting.correlationId, uuid1);
assert.deepEqual(meeting.callStateForMetrics, {correlationId: uuid1, sessionCorrelationId: ''});
assert.deepEqual(meeting.callStateForMetrics, {
correlationId: uuid1,
sessionCorrelationId: '',
});
});
});

Expand Down Expand Up @@ -8007,6 +8024,15 @@ describe('plugin-meetings', () => {
assert.notCalled(webex.internal.newMetrics.submitClientEvent);
checkBehavioralMetricSent(true);
});

it('stop stats analyzer during reconnection ', async () => {
meeting.hasMediaConnectionConnectedAtLeastOnce = true;
meeting.statsAnalyzer.stopAnalyzer = sinon.stub();

mockFailedEvent();

assert.calledOnce(meeting.statsAnalyzer.stopAnalyzer);
});
});

describe('should send correct metrics for ROAP_FAILURE event', () => {
Expand Down

0 comments on commit 28fcd1d

Please sign in to comment.