Preload media devices to avoid later delay
Co-authored-by: ayumi yu <ayumi@signal.org>
This commit is contained in:
parent
6d216a3eca
commit
59a4f237fd
5 changed files with 43 additions and 0 deletions
|
@ -2653,6 +2653,15 @@ async function ensureFilePermissions(onlyFiles?: Array<string>) {
|
||||||
getLogger().info(`Finish ensuring permissions in ${Date.now() - start}ms`);
|
getLogger().info(`Finish ensuring permissions in ${Date.now() - start}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipc.handle('get-media-access-status', async (_event, value) => {
|
||||||
|
// This function is not supported on Linux
|
||||||
|
if (!systemPreferences.getMediaAccessStatus) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return systemPreferences.getMediaAccessStatus(value);
|
||||||
|
});
|
||||||
|
|
||||||
ipc.handle('get-auto-launch', async () => {
|
ipc.handle('get-auto-launch', async () => {
|
||||||
return app.getLoginItemSettings(await getDefaultLoginItemSettings())
|
return app.getLoginItemSettings(await getDefaultLoginItemSettings())
|
||||||
.openAtLogin;
|
.openAtLogin;
|
||||||
|
|
|
@ -383,6 +383,10 @@ export class CallingClass {
|
||||||
});
|
});
|
||||||
|
|
||||||
void this.cleanExpiredGroupCallRingsAndLoop();
|
void this.cleanExpiredGroupCallRingsAndLoop();
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
drop(this.enumerateMediaDevices());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private attemptToGiveOurServiceIdToRingRtc(): void {
|
private attemptToGiveOurServiceIdToRingRtc(): void {
|
||||||
|
@ -2433,6 +2437,23 @@ export class CallingClass {
|
||||||
void this.cleanExpiredGroupCallRingsAndLoop();
|
void this.cleanExpiredGroupCallRingsAndLoop();
|
||||||
}, CLEAN_EXPIRED_GROUP_CALL_RINGS_INTERVAL);
|
}, CLEAN_EXPIRED_GROUP_CALL_RINGS_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MacOS: Preload devices to work around delay when first entering call lobby
|
||||||
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=1287628
|
||||||
|
private async enumerateMediaDevices(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const microphoneStatus = await window.IPC.getMediaAccessStatus(
|
||||||
|
'microphone'
|
||||||
|
);
|
||||||
|
if (microphoneStatus !== 'granted') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
drop(window.navigator.mediaDevices.enumerateDevices());
|
||||||
|
} catch (error) {
|
||||||
|
log.error('enumerateMediaDevices failed:', Errors.toLogFormat(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const calling = new CallingClass();
|
export const calling = new CallingClass();
|
||||||
|
|
|
@ -108,6 +108,9 @@ export type IPCEventsCallbacksType = {
|
||||||
deleteAllMyStories: () => Promise<void>;
|
deleteAllMyStories: () => Promise<void>;
|
||||||
editCustomColor: (colorId: string, customColor: CustomColorType) => void;
|
editCustomColor: (colorId: string, customColor: CustomColorType) => void;
|
||||||
getConversationsWithCustomColor: (x: string) => Array<ConversationType>;
|
getConversationsWithCustomColor: (x: string) => Array<ConversationType>;
|
||||||
|
getMediaAccessStatus: (
|
||||||
|
mediaType: 'screen' | 'microphone' | 'camera'
|
||||||
|
) => Promise<string | unknown>;
|
||||||
installStickerPack: (packId: string, key: string) => Promise<void>;
|
installStickerPack: (packId: string, key: string) => Promise<void>;
|
||||||
isFormattingFlagEnabled: () => boolean;
|
isFormattingFlagEnabled: () => boolean;
|
||||||
isPhoneNumberSharingEnabled: () => boolean;
|
isPhoneNumberSharingEnabled: () => boolean;
|
||||||
|
@ -609,6 +612,11 @@ export function createIPCEvents(
|
||||||
showWhatsNewModal();
|
showWhatsNewModal();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getMediaAccessStatus: async (
|
||||||
|
mediaType: 'screen' | 'microphone' | 'camera'
|
||||||
|
) => {
|
||||||
|
return window.IPC.getMediaAccessStatus(mediaType);
|
||||||
|
},
|
||||||
getMediaPermissions: window.IPC.getMediaPermissions,
|
getMediaPermissions: window.IPC.getMediaPermissions,
|
||||||
getMediaCameraPermissions: window.IPC.getMediaCameraPermissions,
|
getMediaCameraPermissions: window.IPC.getMediaCameraPermissions,
|
||||||
|
|
||||||
|
|
3
ts/window.d.ts
vendored
3
ts/window.d.ts
vendored
|
@ -66,6 +66,9 @@ export type IPCType = {
|
||||||
};
|
};
|
||||||
drawAttention: () => void;
|
drawAttention: () => void;
|
||||||
getAutoLaunch: () => Promise<boolean>;
|
getAutoLaunch: () => Promise<boolean>;
|
||||||
|
getMediaAccessStatus: (
|
||||||
|
mediaType: 'screen' | 'microphone' | 'camera'
|
||||||
|
) => Promise<string | undefined>;
|
||||||
getMediaCameraPermissions: () => Promise<boolean>;
|
getMediaCameraPermissions: () => Promise<boolean>;
|
||||||
getMediaPermissions: () => Promise<boolean>;
|
getMediaPermissions: () => Promise<boolean>;
|
||||||
logAppLoadedEvent?: (options: { processedCount?: number }) => void;
|
logAppLoadedEvent?: (options: { processedCount?: number }) => void;
|
||||||
|
|
|
@ -86,6 +86,8 @@ const IPC: IPCType = {
|
||||||
ipc.send('draw-attention');
|
ipc.send('draw-attention');
|
||||||
},
|
},
|
||||||
getAutoLaunch: () => ipc.invoke('get-auto-launch'),
|
getAutoLaunch: () => ipc.invoke('get-auto-launch'),
|
||||||
|
getMediaAccessStatus: mediaType =>
|
||||||
|
ipc.invoke('get-media-access-status', mediaType),
|
||||||
getMediaPermissions: () => ipc.invoke('settings:get:mediaPermissions'),
|
getMediaPermissions: () => ipc.invoke('settings:get:mediaPermissions'),
|
||||||
getMediaCameraPermissions: () =>
|
getMediaCameraPermissions: () =>
|
||||||
ipc.invoke('settings:get:mediaCameraPermissions'),
|
ipc.invoke('settings:get:mediaCameraPermissions'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue