fix(audio): handle NotAllowedError in skipCheck:true scenarios

In scenarios where the join audio flow skips echo test, NotAllowedError
(and any other errors) are all being mashed together under a generic
MEDIA_ERROR object.

Properly handle specific errors in audio-manager so they're correctly
render in the audio modal help screen.
This commit is contained in:
prlanzarin 2024-04-09 15:17:18 -03:00
parent a3a1245078
commit 027d5ad288
3 changed files with 53 additions and 40 deletions

View File

@ -200,22 +200,23 @@ const AudioModal = (props) => {
}, [autoplayBlocked]);
const handleJoinMicrophoneError = (err) => {
const { type } = err;
const { type, errCode, errMessage } = err;
switch (type) {
case 'MEDIA_ERROR':
setContent('help');
setErrCode(0);
setErrMessage(type);
setErrCode(errCode);
setErrMessage(errMessage);
setDisableActions(false);
break;
case 'CONNECTION_ERROR':
default:
setErrCode(0);
setErrCode(errCode);
setErrMessage(type);
setDisableActions(false);
break;
}
}
};
const handleGoToLocalEcho = () => {
// Simplified echo test: this will return the AudioSettings with:
@ -401,7 +402,7 @@ const AudioModal = (props) => {
: 0;
setContent('help');
setErrCode(code);
setErrMessage(error?.name || 'GUMFailure');
setErrMessage(error?.name || 'NotAllowedError');
setDisableActions(false);
};

View File

@ -1,7 +1,9 @@
const MIC_ERROR = {
UNKNOWN: 0,
NO_SSL: 9,
MAC_OS_BLOCK: 8,
NO_PERMISSION: 7,
DEVICE_NOT_FOUND: 6,
};
export default { MIC_ERROR };

View File

@ -23,6 +23,7 @@ import {
} from '/imports/api/audio/client/bridge/service';
import MediaStreamUtils from '/imports/utils/media-stream-utils';
import { makeVar } from '@apollo/client';
import AudioErrors from '/imports/ui/services/audio-manager/error-codes';
const STATS = window.meetingClientSettings.public.stats;
const MEDIA = window.meetingClientSettings.public.media;
@ -351,49 +352,58 @@ class AudioManager {
}
joinAudio(callOptions, callStateCallback) {
return this.bridge.joinAudio(callOptions, callStateCallback.bind(this)).catch((error) => {
const { name } = error;
return this.bridge
.joinAudio(callOptions, callStateCallback.bind(this))
.catch((error) => {
const { name, message } = error;
const errorPayload = {
type: 'MEDIA_ERROR',
errMessage: message || 'MEDIA_ERROR',
errCode: AudioErrors.MIC_ERROR.UNKNOWN,
};
if (!name) {
throw error;
}
switch (name) {
case 'NotAllowedError':
logger.error(
{
logCode: 'audiomanager_error_getting_device',
switch (name) {
case 'NotAllowedError':
errorPayload.errCode = AudioErrors.MIC_ERROR.NO_PERMISSION;
logger.error(
{
logCode: 'audiomanager_error_getting_device',
extraInfo: {
errorName: error.name,
errorMessage: error.message,
},
},
`Error getting microphone - {${error.name}: ${error.message}}`
);
break;
case 'NotFoundError':
errorPayload.errCode = AudioErrors.MIC_ERROR.DEVICE_NOT_FOUND;
logger.error(
{
logCode: 'audiomanager_error_device_not_found',
extraInfo: {
errorName: error.name,
errorMessage: error.message,
},
},
`Error getting microphone - {${error.name}: ${error.message}}`
);
break;
default:
logger.error({
logCode: 'audiomanager_error_unknown',
extraInfo: {
errorName: error.name,
errorMessage: error.message,
},
},
`Error getting microphone - {${error.name}: ${error.message}}`
);
break;
case 'NotFoundError':
logger.error(
{
logCode: 'audiomanager_error_device_not_found',
extraInfo: {
errorName: error.name,
errorMessage: error.message,
},
},
`Error getting microphone - {${error.name}: ${error.message}}`
);
break;
default:
break;
}
}, `Error getting microphone - {${name}: ${message}}`);
break;
}
this.isConnecting = false;
this.isWaitingPermissions = false;
throw {
type: 'MEDIA_ERROR',
};
throw errorPayload;
});
}