-
Notifications
You must be signed in to change notification settings - Fork 572
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
aaudio crash, assert in releaseBuffer #535
Comments
Are there any other details when/how the crash is caused? Are you using callback methods or blocking reads/writes? Any specific device versions/API levels? A preliminary guess is the AudioStream is closed, while a blocking read is pending, causing a crash when the read attempts to access the closed stream. However, any additional details would be extremely helpful. |
Thank you, I found that this could happen when our app goes background. |
Hey @taemincho, any chance you can share a few more details of the problem so that we can advise other developers on how to avoid the issue? Closing streams is a particularly tricky topic. |
Sorry for the late reply, I was on vacation. We created input stream and output stream and used a blocking read from the input stream inside the output stream callback. However we still get many crashes that look like below
Any ideas? FYI: I found the same error reported in Stack Overflow. |
I can also report that we are experiencing relatively frequent crash which matches with the stack overflow post @taemincho posted in the comment above:
We use callbacks and not blocking reads though.
|
This is an assert failure in libaudioclient. Do either of you have a full logcat of the crash (including libaudioclient error messages)? That would make debugging this particular issue much easier, since it seems difficult to reproduce. |
@atneya Unfortunately - we don't. We don't collect full logcat from the field and we couldn't reproduce the issue in house. |
But maybe device list from developer console for the crash could help:
|
@milos-pesic-sc Are you able to get a full list of devices (expand Others) to confirm? It is unlikely that this is an Oboe specific issue (especially considering the StackOverflow post linked refers to using OpenSLES), however all additional information makes debugging the underlying issue easier. Although, perhaps Oboe is exacerbating/exposing an underlying issue, and we can implement a workaround. Did you encounter this issue when using OpenSLES without Oboe in the past? @taemincho Were the original crashes on the input side resolved by using a lock? Were the output crashes present prior as well? Do you have any additional device details/logs/information regarding when the crash occurs? |
@atneya |
Internal reference: b/136268149 |
@atneya Do we have more info on this one? Any updates? |
No updates on internal bug as of yet, assigning to @philburk to track internal. |
This is being tracked internally at b/136268149 |
This bug seems to be related to AudioRecord read() and AudioTrack write() not being thread safe. And if a stream is using a callback then the app should not also call a blocking read/write for that stream from any thread. @taemincho - Please check your app to see if it might be doing something that is not thread safe. |
Do you have the full log message, for example a line starting with "Abort message: " ? |
Also am looking for a reproducible test case, in other words ... a sequence of steps that are likely to show the bug. Thanks! |
Hi,
I am able to reproduce it on the MegaDrone Sample, only in openSL mode but I think it is a good start. Easy Reproducing steps in Megadrone :
After doing this for some times you will have a crash. This crash is the number one of our app Remixlive , after we updated our engine to use Juce + Oboe. |
Thank you so much for describing that clear repro case. That's the most important step in fixing a bug. It is Thanksgiving weekend here in the US but I will try to verify the repro steps and then we will tackle it next week. By the way have you tried putting a 200 msec sleep in the onErrorBeforeClose callback? |
Hi, I just reviewed Audio Stream implementation for OpenSLES, and onErrorBeforeClose or onErrorAfterClose is never called. Have a great weekend |
Yay! I made the changes you suggested to MegaDrone. |
Oh right. OpenSL ES does not disconnect the stream when you change devices. It switches automatically. But this can cause problems with buffers getting bigger or smaller and causing glitches, or crashes like this. That is why AAudio tries to disconnect the stream when the device changes. |
Hi, |
The assert in releaseBuffer() seems to be caused by a race condition.
But the new device sees that the buffer came from the old device and rejects it. That causes the assert and the crash. If the callback is very quick, then the window is small and the crash may not occur. |
We are looking for a workaround. @taemincho - you said the probablility went down when you switched to your own OpenSL ES implementation. What is different between your code and ours?
|
|
I also encounter this issue, in our crash report system, Below are Android 10 devices:
And I checked logs of
BTW, I'm using the OpenSLES mode. |
Seeing regularly crashes I think related to this. Using AAudio, not through Oboe. But ofcourse also interested in a workaround or solution. Could using mutexes in the callback and the shutdown logic
|
Has there been any updates to this issue? We are also seeing this this callstack as one of our most common crashes on play store. |
I have added a techNote dedicated to this Issue. Check there for the latest status. @peterdk It is rare for this crash to occur when using AAudio because the routing is handled differently. I would love to get more information:
[UPDATE: Calling getFramesRead() from the callback can trigger this for AAudio!] |
Move call to getPosition() outside the callback. This was triggering a restoreTrack_l() inside AudioFlinger folowing a headset insertion. That in turn caused an assert in releaseBuffer() in AudioTrack or AudioRecord. Now it is called when needed by getFramesRead() or getFramesWritten(). Fixes ##535
I think we found a workaround for this crash in releaseBuffer() for OpenSL ES. Oboe version 1.4.1 has the fix for OpenSL ES in #863. |
Move call to getPosition() outside the callback. This was triggering a restoreTrack_l() inside AudioFlinger folowing a headset insertion. That in turn caused an assert in releaseBuffer() in AudioTrack or AudioRecord. Now it is called when needed by getFramesRead() or getFramesWritten(). Fixes ##535
I did an experiment. Calling getFramesRead() from the callback of a Legacy Oboe OUTPUT stream |
Also encountered this prblem and got the following log:
|
@xuchuanyin - Please use Oboe v1.4.1 or later. It has a fix. See https://github.com/google/oboe/wiki/TechNote_ReleaseBuffer |
We’re using Oboe v1.6.1 and still seeing this crash quite frequently. Is there anything else we should be doing to avoid it? We don’t call |
Hi, we've published a beta version app which first uses Oboe, and got reported a lot of crashes look similar to below:
Any idea what could cause these crashes ?
The text was updated successfully, but these errors were encountered: