-
Notifications
You must be signed in to change notification settings - Fork 7.5k
fix(conference) fix processing device list while initial gUM is pending #16318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,71 +72,62 @@ export function addPendingDeviceRequest(request: Object) { | |
| */ | ||
| export function configureInitialDevices() { | ||
| return (dispatch: IStore['dispatch'], getState: IStore['getState']) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add a comment inside the function and also here https://github.com/jitsi/jitsi-meet/blob/master/react/features/conference/actions.web.ts#L56 that we expect getAvailableDevices() to be called before hand. Otherwise I can very well forget about this and remove it by mistake :) Otherwise kudos for finding this and changing it. I myself was doing a similar cleanup a year ago probably and there was a lot of |
||
| const deviceLabels = getDevicesFromURL(getState()); | ||
| let updateSettingsPromise; | ||
| const state = getState(); | ||
| const deviceLabels = getDevicesFromURL(state); | ||
|
|
||
| logger.debug(`(TIME) configureInitialDevices: deviceLabels=${ | ||
| Boolean(deviceLabels)}, performance.now=${window.performance.now()}`); | ||
|
|
||
| if (deviceLabels) { | ||
| updateSettingsPromise = dispatch(getAvailableDevices()).then(() => { | ||
| const state = getState(); | ||
|
|
||
| if (!areDeviceLabelsInitialized(state)) { | ||
| // The labels are not available if the A/V permissions are | ||
| // not yet granted. | ||
|
|
||
| Object.keys(deviceLabels).forEach(key => { | ||
| dispatch(addPendingDeviceRequest({ | ||
| type: 'devices', | ||
| name: 'setDevice', | ||
| device: { | ||
| kind: key.toLowerCase(), | ||
| label: deviceLabels[key as keyof typeof deviceLabels] | ||
| }, | ||
| // eslint-disable-next-line @typescript-eslint/no-empty-function | ||
| responseCallback() {} | ||
| })); | ||
| }); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| const newSettings: any = {}; | ||
| if (!areDeviceLabelsInitialized(state)) { | ||
| // The labels are not available if the A/V permissions are | ||
| // not yet granted. | ||
|
|
||
| Object.keys(deviceLabels).forEach(key => { | ||
| const label = deviceLabels[key as keyof typeof deviceLabels]; | ||
| dispatch(addPendingDeviceRequest({ | ||
| type: 'devices', | ||
| name: 'setDevice', | ||
| device: { | ||
| kind: key.toLowerCase(), | ||
| label: deviceLabels[key as keyof typeof deviceLabels] | ||
| }, | ||
| // eslint-disable-next-line @typescript-eslint/no-empty-function | ||
| responseCallback() {} | ||
| })); | ||
| }); | ||
|
|
||
| // @ts-ignore | ||
| const deviceId = getDeviceIdByLabel(state, label, key); | ||
| return; | ||
| } | ||
|
|
||
| if (deviceId) { | ||
| const settingsTranslationMap = DEVICE_TYPE_TO_SETTINGS_KEYS[ | ||
| key as keyof typeof DEVICE_TYPE_TO_SETTINGS_KEYS]; | ||
| const newSettings: any = {}; | ||
|
|
||
| newSettings[settingsTranslationMap.currentDeviceId] = deviceId; | ||
| newSettings[settingsTranslationMap.userSelectedDeviceId] = deviceId; | ||
| newSettings[settingsTranslationMap.userSelectedDeviceLabel] = label; | ||
| } | ||
| }); | ||
| Object.keys(deviceLabels).forEach(key => { | ||
| const label = deviceLabels[key as keyof typeof deviceLabels]; | ||
|
|
||
| // @ts-ignore | ||
| const deviceId = getDeviceIdByLabel(state, label, key); | ||
|
|
||
| dispatch(updateSettings(newSettings)); | ||
| if (deviceId) { | ||
| const settingsTranslationMap = DEVICE_TYPE_TO_SETTINGS_KEYS[ | ||
| key as keyof typeof DEVICE_TYPE_TO_SETTINGS_KEYS]; | ||
|
|
||
| newSettings[settingsTranslationMap.currentDeviceId] = deviceId; | ||
| newSettings[settingsTranslationMap.userSelectedDeviceId] = deviceId; | ||
| newSettings[settingsTranslationMap.userSelectedDeviceLabel] = label; | ||
| } | ||
| }); | ||
| } else { | ||
| updateSettingsPromise = Promise.resolve(); | ||
|
|
||
| dispatch(updateSettings(newSettings)); | ||
| } | ||
|
|
||
| return updateSettingsPromise | ||
| .then(() => { | ||
| const userSelectedAudioOutputDeviceId = getUserSelectedOutputDeviceId(getState()); | ||
| const userSelectedAudioOutputDeviceId = getUserSelectedOutputDeviceId(getState()); | ||
|
|
||
| logger.debug(`(TIME) configureInitialDevices -> setAudioOutputDeviceId: performance.now=${ | ||
| window.performance.now()}`); | ||
| logger.debug(`(TIME) configureInitialDevices -> setAudioOutputDeviceId: performance.now=${ | ||
| window.performance.now()}`); | ||
|
|
||
| return setAudioOutputDeviceId(userSelectedAudioOutputDeviceId, dispatch) | ||
| .catch(ex => logger.warn(`Failed to set audio output device. | ||
| Default audio output device will be used instead ${ex}`)); | ||
| }); | ||
| return setAudioOutputDeviceId(userSelectedAudioOutputDeviceId, dispatch) | ||
| .catch(ex => logger.warn(`Failed to set audio output device. | ||
| Default audio output device will be used instead ${ex}`)); | ||
| }; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well looking into the code the scenario explained above seems impossible to me.
_onDeviceListChangedseems to be attached as a listener by_initDeviceListonly when the passedsetDeviceListChangeHandleristrueand the only time this method is called with parametertrueis here https://github.com/jitsi/jitsi-meet/blob/master/conference.js#L591 . At this point the tracks are already created.Why do we need this change? Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw your commit comment and if the problem is that the tracks are not in Redux yet but they are created I think you should at least fix your comment above.
Also if this is the case I feel like there should be better solution!
Maybe call
_initDeviceList(true)only once the tracks are actually stored in redux instead of attaching it too early? WDYT? Or we still want to update the device list?The scenario you are describing if I understand correctly is the following:
In this case shouldn't we call the handler once more to go trough the checks and potentially modify the tracks once the local tracks are added into redux.
I see you are using the
gumPendingflags. I'm not sure if these flags are the best choice because the condition could be true also during a regular mute/unmute or replace track operation and if I understand correctly we are trying to fix something related only to the initial GUM creation, isn't it? Maybe you can use initialGUMPromise and maybe you can chain the checks for the track change related to the devices changed to the initialGUMPromise (speculating here, not sure exactly when do we resolve those).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also if the problem is that the tracks are not in redux yet maybe we should start putting tracks in redux earlier? When I was looking into the code now we add the into the store once we have connected, the conference have started and we have added the tracks to LJM. WDYT?