From 54c36198d060bfaa8e88d4594066a44310a579c3 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Thu, 14 Feb 2019 13:00:51 -0800 Subject: [PATCH] fix(mobile/call-integration): cleanup if leave takes too long The conference disconnection process is asynchronous which means there's no guarantee that there will be CONFERENCE_LEFT event for the old conference, before the next conference is joined. Because of that we can end up with two simultaneous calls on the native side which is not always supported. End the call on CONFERENCE_WILL_LEAVE to fix this corner case. --- react/features/mobile/call-integration/middleware.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/react/features/mobile/call-integration/middleware.js b/react/features/mobile/call-integration/middleware.js index d26ecd50a..65c19cc8a 100644 --- a/react/features/mobile/call-integration/middleware.js +++ b/react/features/mobile/call-integration/middleware.js @@ -8,9 +8,10 @@ import { appNavigate } from '../../app'; import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../base/app'; import { CONFERENCE_FAILED, + CONFERENCE_JOINED, CONFERENCE_LEFT, CONFERENCE_WILL_JOIN, - CONFERENCE_JOINED, + CONFERENCE_WILL_LEAVE, SET_AUDIO_ONLY, getConferenceName, getCurrentConference @@ -63,7 +64,14 @@ CallIntegration && MiddlewareRegistry.register(store => next => action => { case CONFERENCE_JOINED: return _conferenceJoined(store, next, action); + // If a conference is being left in a graceful manner then + // the CONFERENCE_WILL_LEAVE fires as soon as the conference starts + // disconnecting. We need to destroy the call on the native side as soon + // as possible, because the disconnection process is asynchronous and + // Android not always supports two simultaneous calls at the same time + // (even though it should according to the spec). case CONFERENCE_LEFT: + case CONFERENCE_WILL_LEAVE: return _conferenceLeft(store, next, action); case CONFERENCE_WILL_JOIN: @@ -141,6 +149,7 @@ function _conferenceFailed(store, next, action) { const { callUUID } = action.conference; if (callUUID) { + delete action.conference.callUUID; CallIntegration.reportCallFailed(callUUID); } } @@ -192,6 +201,7 @@ function _conferenceLeft(store, next, action) { const { callUUID } = action.conference; if (callUUID) { + delete action.conference.callUUID; CallIntegration.endCall(callUUID); }