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

Maybe blocked by network api avformat_open_input() #1977

Closed xlb767923274 closed 1 year ago

xlb767923274 commented 3 years ago

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

1965

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,
  2. Interval 20s
  3. alexa, tell me a joke
  4. Interval 20s
  5. Repeat 1-4

Tell us about your environment:

What version of the AVS Device SDK are you using?

  <x.y.z>avs sdk 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):

Logfile in debug9 ,The file is too big, I only kept the problematic part avs20210915-090300.log

xlb767923274 commented 3 years ago

because of issue #1965 ,I temporarily modified AndroidSLESMediaPlayer::configureNewRequest()

=====》

    stop(m_sourceId); //move stop to here, fix dead lock
    std::lock_guard<std::mutex> requestLock{m_requestMutex};
    {
        // Use global lock to stop player and set new source id.
        std::lock_guard<std::mutex> lock{m_operationMutex};
        if (m_hasShutdown) {
            return ERROR;
        }
        //stopLocked();
        m_sourceId = g_id.fetch_add(1);
        m_almostDone = false;
        m_initialOffset = offset;
    }
    ......
    m_mediaQueue.reset();  // Delete old queue before configuring new one.    
    ACSDK_DEBUG9(LX(__func__).d("to", "FFmpegDecoder::create()"));   // _position1_

image

And from the log positon1 haven't been print , so thread has blocked in m_mediaQueue.reset();

xlb767923274 commented 3 years ago

I guess there is still a deadlock problem here,But I don't know how to fix it, can you give me some suggestions before the next release version is released?

xlb767923274 commented 3 years ago

I know the problem, that is blocked at

AndroidSLESMediaPlayer::configureNewRequest
-> m_mediaQueue.reset(); -> AndroidSLESMediaQueue::~AndroidSLESMediaQueue() -> m_executor.waitForSubmittedTasks();

configureNewRequest() will wait the old m_mediaQueue be destructed, but m_mediaQueue maybe blocked at AndroidSLESMediaQueue::fillBuffer() -> FFmpegDecoder::read() -> FFmpegDecoder::initialize() ->FFmpegUrlInputController::getCurrentFormatContext() ->avformat_open_input() // here maybe blocked by network because of don't set // "avFormatContext->interrupt_callback.callback"

image

blazusiak-amazon commented 1 year ago

Hello @xlb767923274.

Are you still experiencing this issue on the latest version of the SDK (3.0)?

kclchan commented 1 year ago

I am closing this issue due to inactivity. If you have further questions, please open a new ticket and refer to this closed one.