From a237946ba04f0656c6ca14f2ef224717b2b1c740 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Thu, 10 Dec 2020 12:39:39 -0600 Subject: [PATCH] Disable camera when quickly toggling the call lobby --- ts/services/calling.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 63815bc0cf88..67b60c092bae 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -181,6 +181,24 @@ export class CallingClass { window.log.info('CallingClass.startCallingLobby(): Starting lobby'); + // It's important that this function comes before any calls to + // `videoCapturer.enableCapture` or `videoCapturer.enableCaptureAndSend` because of + // a small RingRTC bug. + // + // If we tell RingRTC to start capturing video (with those methods or with + // `RingRTC.setPreferredDevice`, which also captures video) multiple times in quick + // succession, it will call the asynchronous `getUserMedia` twice. It'll save the + // results in the same variable, which means the first call can be overridden. + // Later, when we try to turn the camera off, we'll only disable the *second* result + // of `getUserMedia` and the camera will stay on. + // + // We get around this by `await`ing, making sure we're all done with `getUserMedia`, + // and then continuing. + // + // We should be able to move this below `this.connectGroupCall` once that RingRTC bug + // is fixed. See DESKTOP-1032. + await this.startDeviceReselectionTimer(); + switch (callMode) { case CallMode.Direct: this.uxActions.showCallLobby({ @@ -221,8 +239,6 @@ export class CallingClass { throw missingCaseError(callMode); } - await this.startDeviceReselectionTimer(); - if (isVideoCall) { this.enableLocalCamera(); }