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 604 forks source link

ContextManager: STATE_PROVIDER_TIMEDOUT #1965

Open xlb767923274 opened 3 years ago

xlb767923274 commented 3 years ago

IMPORTANT: Before you create an issue, please take a look at our Issue Reporting Guide.

Briefly summarize your issue:

Repeatedly play music and joke, after a period of time, STATE_PROVIDER_TIMEDOUT error appears,and alexa can wake up no longer。

What is the expected behavior?

STATE_PROVIDER_TIMEDOUT does not appear, alexa can wake up

What behavior are you observing?

STATE_PROVIDER_TIMEDOUT error appears,and alexa can wake up no longer。

Provide the steps to reproduce the issue, if applicable:

**1. alexa, play music,

  1. Interval 20s
  2. alexa, tell me a joke
  3. Interval 20s
  4. Repeat 1-4**

    Tell us about your environment:

    What version of the AVS Device SDK are you using?

    <x.y.z> = 1.24.0 + ss sdk 2.7.0 + apl core1.6.1

Tell us what hardware you're using:

Tell us about your OS (Type & version):

xlb767923274 commented 3 years ago

Log file in debug9,The file is too large and some logs have been deleted

speaker_20210826-133526.log

xlb767923274 commented 3 years ago

08-26 14:37:23.501 D/AlexaSampleApp(23338): [ 44] 0 AudioPlayer:provideState:stateRequestToken=106

void AudioPlayer::provideState( const avsCommon::avs::NamespaceAndName& stateProviderName, unsigned int stateRequestToken) { ACSDK_DEBUG(LX("provideState").d("stateRequestToken", stateRequestToken)); m_executor.submit([this, stateRequestToken] { executeProvideState(true, stateRequestToken); }); }

why executeProvideState() havn't been execute... ?

xlb767923274 commented 3 years ago

I know the problem,there is a deadlock..

In AndroidSLESMediaPlayer::configureNewRequest()

std::lock_guard requestLock{m_requestMutex}; { // Use global lock to stop player and set new source id. std::lock_guard lock{m_operationMutex}; if (m_hasShutdown) { ACSDK_ERROR(LX("configureNewRequestFailed").d("name", RequiresShutdown::name()).d("reason", "playerHasShutdown")); return ERROR; } stopLocked(); m_sourceId = g_id.fetch_add(1); m_almostDone = false; m_initialOffset = offset; }

  1. Here is locked std::lock_guard lock{m_operationMutex};
  2. OnPlaybackStopped(m_sourceId, createMediaPlayerState(m_sourceId)) may be called in stopLocked() And createMediaPlayerState, getOffset() will request the lock m_operationMutex again

==》Deadlock

kclchan commented 3 years ago

@xlb767923274, thanks for the findings. I have created an internal ticket to investigate this.

xlb767923274 commented 3 years ago

When will this issue be resolved? Will there be a new release version this month? Will the new version solve this issue?

blazusiak-amazon commented 2 years ago

Hello @xlb767923274,

Is this issue still experienced on the latest version of the SDK (3.0)?