Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible deadlock in AudioInputStreamOpenSLES::close() #1062

Closed
philburk opened this issue Nov 2, 2020 · 1 comment · Fixed by #1087
Closed

Possible deadlock in AudioInputStreamOpenSLES::close() #1062

philburk opened this issue Nov 2, 2020 · 1 comment · Fixed by #1087
Assignees
Labels
bug P1 high priority
Milestone

Comments

@philburk
Copy link
Collaborator

philburk commented Nov 2, 2020

A third-party developer wrote in an email:

...we are suspecting there might be a deadlock in the OpenSL implementation of the close() method called on the Input stream, namely: AudioInputStreamOpenSLES::close(). While we aren’t currently able to repro the problem on any of our devices, our logs indicate that a large number of devices are timing out (take more than 10 secs) waiting on the call to return. This happens when both input and output streams are opened and we stop the input stream.

Our integration uses the latest public Oboe release and creates a managed stream and we simply call stream_->stop() followed by stream_-flush(). We know the thing deadlocks there because we fire an event when close returns and we don’t see this event in the cases we mention.

Here’s the top 10 devices that this occurs on:

[various Vivo and Redmi devices.]

And the top 3 Android versions:

  • Android 9
  • Android 8.1
  • Android 7

I noticed this in AudioInputStreamOpenSLES::close()

  mLock.unlock(); // avoid recursive lock
  requestStop();
  mLock.lock();

[We think] a race can occur here, right before and right after calling requestStop();

[Consider using] std::recursive_mutex

@philburk philburk self-assigned this Nov 2, 2020
@philburk philburk added bug P1 high priority labels Nov 2, 2020
@philburk
Copy link
Collaborator Author

philburk commented Nov 2, 2020

We addressed a race condition in the AAudio side that seems related:

    #1017

We should consider adding the same change to the OpenSL ES side.

philburk added a commit that referenced this issue Nov 19, 2020
Do not unlock when stopping the stream.
Call requestStop_l() or requestPause_l().

Fixes #1062
@philburk philburk added this to the v1.5 milestone Nov 19, 2020
philburk added a commit that referenced this issue Nov 19, 2020
Do not unlock when stopping the stream.
Call requestStop_l() or requestPause_l().

Fixes #1062
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P1 high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant