Toggling audio output too early leaves LocalAudioOutputProvider's state out-of-sync #964
Open
5 tasks done
Labels
Bug
Something isn't working
What happened and what did you expect to happen?
From
useLocalAudioOutput()
, after usingtoggleAudio()
,isAudioOn
should correctly reflect the current state of audio output.If
toggleAudio()
is called too early in the meeting lifecycle (eg: in our case, just after theaudioVideoDidStart
event is fired from the underlying meeting),isAudioOn
gets toggled tofalse
, but when the meeting finishes initializing, the underlying audio feed is set up as ifisAudioOn
was set totrue
as that's the default.Have you reviewed our existing documentation?
Reproduction steps
Create a component that uses the following
Triggering the bug involves firing toggleAudio as early as possible (ie: before
LocalAudioOutputProvider
gets a reference toaudioVideo
).In the above example, toggling
audioOutputShouldBeEnabled
totrue
is then a NOP, and toggling it back tofalse
successfully unbinds the audio output.Amazon Chime SDK React Components Library version
3.8.0
What browsers are you seeing the problem on?
Chrome (n/a)
Browser version
Latest (n/a)
Device Information
Desktop (n/a)
Meeting and Attendee ID Information.
No response
Browser console logs
None relevant.
Add any other context about the problem here.
On initial meeting load,
toggleAudio
getting fired early setsLocalAudioOutputProvider
'sisAudioOn
tofalse
. This initial call doesn't unbind the audio directly, asaudioVideo
is still unset. Shortly thereafter,audioVideo
gets hooked up inLocalAudioOutputProvider
, and the firstuseEffect
inLocalAudioOutputProvider
fires. This effect doesn't check for the state ofisAudioOn
, so it binds the audio element, but doesn't resetisAudioOn
, so the state is now mismatched.The fix here would presumably involve either:
isAudioOn
totrue
when initially binding the audio elementaudioVideo
is initially boundI'd guess the latter would be a better option here, to avoid an unnecessary bind-unbind cycle (and possibly a corresponding short burst of unwanted audio).
A workaround is to hook onto
audioVideo
in the application and wait for it to be populated, so we don't send the update too early, as below:The text was updated successfully, but these errors were encountered: