fix: Prevent microphone auto-disconnect during calls and restore the removed microphone connected condition (#2597)

- Closes: #2590
This commit is contained in:
Dermot Duffy
2026-07-22 16:12:31 -07:00
committed by GitHub
parent 8c36637092
commit 5a549c0326
14 changed files with 520 additions and 346 deletions
+17 -1
View File
@@ -89,7 +89,7 @@ export class CallManager {
// the call runs on the parent camera itself.
const callCameraID = targetID === parentID ? undefined : targetID;
const existingCall = this._call;
let existingCall = this._call;
if (
existingCall &&
existingCall.cameraID === parentID &&
@@ -120,6 +120,13 @@ export class CallManager {
return false;
}
// Re-read: another `start()` may have installed a session while the
// microphone connect was in flight. Acting on the reading from before the
// await would skip the supersede handling below, leaving that session's
// microphone marking and view state stranded with nothing able to undo
// them.
existingCall = this._call;
// Store the previous view so it can be restored later. A call superseding
// another inherits the earlier call's previous view -- the user never left
// the call. `queryResults` are dropped (re-fetched fresh on restore).
@@ -152,6 +159,10 @@ export class CallManager {
answered,
};
// The microphone's own idle timeout knows nothing about calls, so without
// this the tracks would be stopped mid-conversation.
this._api.getMicrophoneManager().startUsing();
this._api.getViewManager().setViewByParameters({
...(needsNavigation && {
params: { view: 'live', camera: parentID },
@@ -250,6 +261,7 @@ export class CallManager {
this._unansweredTimer.stop();
if (this._call) {
this._call = null;
this._api.getMicrophoneManager().stopUsing();
this._api.getConditionStateManager().setState({ call: 'idle' });
}
this._api
@@ -279,6 +291,10 @@ export class CallManager {
// and recurse.
this._call = null;
// The call no longer needs the microphone, so the normal
// `disconnect_seconds` countdown restarts from here.
this._api.getMicrophoneManager().stopUsing();
const viewManager = this._api.getViewManager();
// Navigate back only on an explicit end, and only when the call actually