alexa / avs-device-sdk

An SDK for commercial device makers to integrate Alexa directly into connected products.
https://developer.amazon.com/alexa/alexa-voice-service
Apache License 2.0
1.26k stars 602 forks source link

StopCapture is never received from the AVS cloud in some cases causing failure to start keyword recognition #158

Closed simplistiq closed 6 years ago

simplistiq commented 7 years ago

We rely on StopCature to restart keyword detection. However in some cases when there are Http2 errors there is no way to restart keyword recognition as we rely on StopCapture directive to do the same. SDK should

  1. Fix this issue, or
  2. Provide a mechanism through an observer to let the application know that keyword detection needs a restart.

The contention is here.

2017-09-13 18:56:26.436 [ a] 0 EventBuilder:buildJsonEventString:messageId=a7022c45-5694-4abe-acfd-0958a1276799,namespace=SpeechRecognizer,name=Recognize 2017-09-13 18:56:26.436 [ a] 0 AudioInputProcessor:executeOnFocusChanged:newFocus=FOREGROUND 2017-09-13 18:56:56.703 [ 5] I HTTP2Transport:streamProgressTimedOut:streamId=5

FULL logs follow below.

############################

Listening...

############################ UIManager::onDialogUXStateChanged state = LISTENING InteractionManager::onDialogUXStateChanged to LISTENING 2017-09-13 18:56:26.431 [ 11] 0 QCMediaPlayer:QCMediaPlayer::duckVolume - Set Volume = 0.3 2017-09-13 18:56:26.431 [ 9] 0 AudioPlayer:executeProvideState:sendToken=true,stateRequestToken=6 2017-09-13 18:56:26.431 [ 9] 9 QCMediaPlayer:getOffsetInMillisecondsCalled 2017-09-13 18:56:26.432 [ 9] 9 QCMediaPlayer:getOffsetInMilliseconds Exit 2017-09-13 18:56:26.433 [ 2] 9 QCMediaPlayer:handleGetOffsetInMillisecondsCalled QsthwClient::getDOADirection() - [Session:1] in get parameters 0 [Session:1] param to get st_direction_of_arrival process_get_param_data: target angle boundaries [250, 290] 2017-09-13 18:56:26.434 [ 2] 9 QCMediaPlayer:handleGetOffsetInMilliseconds exit 2017-09-13 18:56:26.434 [ 9] 0 ContextManager:updateStateLocked:action=updatedState,state={"token"\:"amzn1.as-ct.v1.Dee-Domain-Music#ACRI#url#ACRI#8c251538-373f-4c3b-95f5-1d9852af42ed\:1"\,"offsetInMilliseconds"\:99035\,"playerActivity"\:"PLAYING"},namespace=AudioPlayer,name=PlaybackState 2017-09-13 18:56:26.435 [ 7] 0 ContextManager:buildContextSuccessful:context={"context"\:[{"header"\:{"namespace"\:"Speaker"\,"name"\:"VolumeState"}\,"payload"\:{"volume"\:30\,"muted"\:0}}\,{"header"\:{"namespace"\:"AudioPlayer"\,"name"\:"PlaybackState"}\,"payload"\:{"token"\:"amzn1.as-ct.v1.Dee-Domain-Music#ACRI#url#ACRI#8c251538-373f-4c3b-95f5-1d9852af42ed\:1"\,"offsetInMilliseconds"\:99035\,"playerActivity"\:"PLAYING"}}\,{"header"\:{"namespace"\:"SpeechSynthesizer"\,"name"\:"SpeechState"}\,"payload"\:{"token"\:"amzn1.as-ct.v1.Domain\:Application\:Music#ACRI#DeviceTTSRendererV4_5a759f98-3844-4687-acbe-accb2d1d02ae"\,"offsetInMilliseconds"\:0\,"playerActivity"\:"FINISHED"}}\,{"header"\:{"namespace"\:"Alerts"\,"name"\:"AlertsState"}\,"payload"\:{"allAlerts"\:[]\,"activeAlerts"\:[]}}\,{"header"\:{"namespace"\:"SpeechRecognizer"\,"name"\:"RecognizerState"}\,"payload"\:{"wakeword"\:"ALEXA"}}]} 2017-09-13 18:56:26.435 [ a] 0 AudioInputProcessor:executeOnContextAvailable:jsonContext={"context"\:[{"header"\:{"namespace"\:"Speaker"\,"name"\:"VolumeState"}\,"payload"\:{"volume"\:30\,"muted"\:0}}\,{"header"\:{"namespace"\:"AudioPlayer"\,"name"\:"PlaybackState"}\,"payload"\:{"token"\:"amzn1.as-ct.v1.Dee-Domain-Music#ACRI#url#ACRI#8c251538-373f-4c3b-95f5-1d9852af42ed\:1"\,"offsetInMilliseconds"\:99035\,"playerActivity"\:"PLAYING"}}\,{"header"\:{"namespace"\:"SpeechSynthesizer"\,"name"\:"SpeechState"}\,"payload"\:{"token"\:"amzn1.as-ct.v1.Domain\:Application\:Music#ACRI#DeviceTTSRendererV4_5a759f98-3844-4687-acbe-accb2d1d02ae"\,"offsetInMilliseconds"\:0\,"playerActivity"\:"FINISHED"}}\,{"header"\:{"namespace"\:"Alerts"\,"name"\:"AlertsState"}\,"payload"\:{"allAlerts"\:[]\,"activeAlerts"\:[]}}\,{"header"\:{"namespace"\:"SpeechRecognizer"\,"name"\:"RecognizerState"}\,"payload"\:{"wakeword"\:"ALEXA"}}]} 2017-09-13 18:56:26.436 [ a] I DirectiveProcessor:setDialogRequestIdLocked:oldValue=1ec061b5-f566-4ea4-8a7d-d85d83903be6,newValue=fe78343c-cad4-4f53-81f8-aa7c706e4dba 2017-09-13 18:56:26.436 [ a] 0 DirectiveProcessor:scrubDialogRequestIdLocked:dialogRequestId=1ec061b5-f566-4ea4-8a7d-d85d83903be6 2017-09-13 18:56:26.436 [ a] 0 EventBuilder:buildJsonEventString:messageId=a7022c45-5694-4abe-acfd-0958a1276799,namespace=SpeechRecognizer,name=Recognize 2017-09-13 18:56:26.436 [ a] 0 AudioInputProcessor:executeOnFocusChanged:newFocus=FOREGROUND 2017-09-13 18:56:56.703 [ 5] I HTTP2Transport:streamProgressTimedOut:streamId=5 2017-09-13 18:58:29.552 [ 5] 0 MessageRouter:connectionStatusChanged:reason=SERVER_SIDE_DISCONNECT,newStatus=PENDING #############################

Connecting...

############################# 2017-09-13 18:58:30.019 [ 17] 0 MessageRouter:connectionStatusChanged:reason=ACL_CLIENT_REQUEST,newStatus=CONNECTED 2017-09-13 18:58:30.019 [ 6] I StateSynchronizer:requestingContext:reason=connectionStatusChanged,receivedStatus=CONNECTED 2017-09-13 18:58:30.020 [ 7] 0 ContextManager:updateStateLocked:action=updatedState,state={"volume"\:30\,"muted"\:0},namespace=Speaker,name=VolumeState

sanjayrd commented 7 years ago

Hi @simplistiq,

Thanks for pointing this out. We'll see if we can provide a solution to fix this in an upcoming release. That being said, how about this as a temporary solution:

Having the DialogUXStateAggregator inherit from ConnectionStatusObserverInterface and resetting its internal m_currentState back to IDLE whenever a connection is not equal to CONNECTED or POST_CONNECTED.

AIP (the component that deals with StopCaptures and audio streaming) currently inherits from the DialogUXStateAggregatorObserverInterface resets its internal state back to IDLE whenever DialogUXState goes to IDLE.

Thanks, Sanjay

kjkh commented 6 years ago

Hi,

Has the work around provided by @sanjayrd proven to be sufficient? Are there any additional comments or follow-ups on this issue?

kclchan commented 6 years ago

This issue is fixed in release v1.1.0. Thanks!