I am developing BrowserPhone by twilio.js, version is 1.4.20.
When token expired, I am handling Twilio.Device.offline(), and regenerate token and re-setup Twilio.Device.
After 6 times re-setup, then, Twilio.js throw error.
*Failed* to construct 'AudioContext': The number of hardware contexts provided (6) is greater than or equal to the maximum bound (6).
How can I prevent this error?
I'm using these code.
Twilio.Device.offline((device) => {
if (navigator.onLine) {
Twilio.Device.destroy();
Twilio.Device.instance = null;
getToken(device._clientName);
}
const getToken = (identity) => {
$.ajax({
type: 'POST',
url: baseurl + '/token/get',
data: {'identity': identity}
})
.done((data) => {
data = JSON.parse(data);
Twilio.Device.setup(data.token, {
closeProtection: true
});
};