-
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
Crashes in oboe::AudioStreamAAudio::read(void*, int, long) [AudioStreamAAudio.cpp:490] #1484
Comments
@taemincho - Thanks for reporting this. A crash like this generally occurs if one thread is closing a stream while another thread is reading from the stream. In Oboe there is an error callback when a headset is disconnected. That spawns a thread that stops and closes the stream. This could collide with another thread reading the stream that is being closed.. We will try to reproduce this scenario. Do you know if this happens when users unplug or plug in a headset? The three devices are all very different. So I don't think it is a HAL bug that is common to all three phones. It seems more likely that they have similar timing when there is a disconnect and that leads to a race condition happening more often. We need to try to reproduce this scenario in our lab. Please send us more details on how the different streams and threads are interacting. |
I notice that read() and write() do not hold mLock. oboe/src/aaudio/AudioStreamAAudio.cpp Line 475 in a0731d6
Maybe they should. But that could create new deadlocks. |
@RobertWu - the PR #1200 was to fix #1180
Yes, perhaps. Please write an Oboe unit test that writes (or reads) a BIG buffer that will take a second or more to complete. Then from another thread try closing the stream. it will probably crash. Then try the locks. We have to make sure we are not creating new issues with these locks. |
The fact that it is more often on those phones suggests it might also be related to an audioserver crash. |
I wrote the unit test and the change in mStreamLock read and writes. See https://github.com/google/oboe/tree/robertwu/testStreamStopWrite It seems like there is no noticeable differences between not having and having locks. I don't notice any crashes nor significant changes in the buffer size. Is there a programatic way of checking for crashes? |
Same thing happens for Android R and T. I don't see any issues with my unittest. |
Please create a PR for your test. it looks good but I have some suggestions that I want to tie to the code. |
@taemincho - Is the read() being called from the output stream callback? Or is it being called from another thread? Here is a possible sequence of events: The outputStream callback is called. Then an error callback occurs because of a disconnect on the output stream. Another scenario is if BandLab is defining an onErrorBeforeClose() method and that method closes the input stream. |
Phil and I talked offline and it seems like I've made a mistake in my test and tested for stop() instead of close(). I've opened a PR that solves these issues for AAudio in Oboe. |
Sorry for the late response, @philburk Yes, we call In addition, actually, we couldn't find strong evidence that the headphone connection was causing the problem. |
A Bluetooth connection can cause a routing change and a DISCONNECT the same as a wired headset. @taemincho - Are you by any chance closing the streams because of a Broadcast Device change event? Is it possible that you are closing the input stream before the output stream is getting closed? |
@philburk We always close the output stream first then close the input stream. We also check |
@taemincho wrote:
That's good. Then you can set the sample rate for input to match the output sample rate.
Good. That way the output will not have errors when it reads the input. It does seem like the callback is still running when the close() happens. We are continuing to investigate this. When closing an Oboe stream, Oboe stops the stream in case it is not stopped, |
Android version(s): Android 11, and 12
Android device(s): Pixel 6, Pixel 6 Pro, Redmi Note 10, and TECNO POVA 2
Oboe version: 1.6.1
App name used for testing:
(Please try to reproduce the issue using the OboeTester or an Oboe sample.)
Recently, we got a noticeable number of crashes in oboe::AudioStreamAAudio::read(void*, int, long) [AudioStreamAAudio.cpp:490]
The crashes have been rare before but remarkably increased recently in the latest phones and thus 99% in Android 11 and 12.
The firebase shows that
Another interesting pattern was that only TECNO POVA 2 crashed with SIGSEGV while all other phones crashed with SIGABRT as shown below:
Pixel6, Pixel6Pro, and Xiaomi Redmi Note 10
TECNO POVA 2
The text was updated successfully, but these errors were encountered: