oboe
oboe copied to clipboard
Android 11: ANR when opening stream on some samsung devices
Android version(s): 11 Android device(s): Samsung Galaxy M30s, Samsung Galaxy M31, Samsung Galaxy Note10 Lite, Samsung Galaxy M21, Samsung Galaxy A51, Samsung Galaxy F41 (System on chip: Exynos 9611 mostly and Exynos 9810) Oboe version: 1.5-stable (1cc51bbf83bb3b05d436bb9b4a7aea3446aa8e61) App name used for testing: Pocket Shruti Box and Shruti Carnatic Tuner.
Short description Lots of ANR reports when opening stream. Some users also reported that the app freezes upon opening. For these users the same version of the app used to work. The difference we see is that their devices received Android 11 update recently. All ANR reports in Google Play Console are also only from Android 11. This is the callstack:
#00 pc 000000000009b124 /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+4)
#00 pc 0000000000057dd0 /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+156)
#00 pc 00000000000529e4 /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+296)
#00 pc 0000000000053d38 /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+60)
#00 pc 0000000000053aa8 /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+184)
#00 pc 000000000004c014 /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+152)
#00 pc 000000000003d624 /system/lib64/libaaudio_internal.so (android::BpAAudioService::openStream(aaudio::AAudioStreamRequest const&, aaudio::AAudioStreamConfiguration&)+336)
#00 pc 0000000000039714 /system/lib64/libaaudio_internal.so (aaudio::AAudioBinderClient::openStream(aaudio::AAudioStreamRequest const&, aaudio::AAudioStreamConfiguration&)+172)
#00 pc 000000000002f180 /system/lib64/libaaudio_internal.so (aaudio::AudioStreamInternal::open(aaudio::AudioStreamBuilder const&)+1576)
#00 pc 0000000000033fd0 /system/lib64/libaaudio_internal.so (aaudio::AudioStreamInternalPlay::open(aaudio::AudioStreamBuilder const&)+92)
#00 pc 0000000000022c5c /system/lib64/libaaudio_internal.so (aaudio::AudioStreamBuilder::build(aaudio::AudioStream**)+860)
#00 pc 00000000000037a8 /system/lib64/libaaudio.so (AAudioStreamBuilder_openStream.cfi+144)
#00 pc 0000000000078bb8 /data/app/~~GJ14j16uejuWrNUJmjjvKA==/org.kuyil.shruti-NkXY0fPDmPbz-mBugtmV7w==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamAAudio::open()+568)
#00 pc 00000000000714cc /data/app/~~GJ14j16uejuWrNUJmjjvKA==/org.kuyil.shruti-NkXY0fPDmPbz-mBugtmV7w==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamBuilder::openStream(oboe::AudioStream**)+636)
#00 pc 0000000000071388 /data/app/~~GJ14j16uejuWrNUJmjjvKA==/org.kuyil.shruti-NkXY0fPDmPbz-mBugtmV7w==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamBuilder::openStream(oboe::AudioStream**)+312)
#00 pc 00000000000719b8 /data/app/~~GJ14j16uejuWrNUJmjjvKA==/org.kuyil.shruti-NkXY0fPDmPbz-mBugtmV7w==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamBuilder::openStream(std::__ndk1::shared_ptr<oboe::AudioStream>&)+136)
Steps to reproduce We open the stream like this:
std::shared_ptr<oboe::AudioStream> tmpStream;
streamBuilder
.setSampleRate(params.sampleRate) // native sample rate AudioManager::PROPERTY_OUTPUT_SAMPLE_RATE
->setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Medium)
->setAudioApi(params.audioApi) // AAudio for these devices
->setChannelCount(params.numChannels) // channels 2 in case of output stream, 1 in case of input stream
->setChannelConversionAllowed(true)
->setFormat(oboe::AudioFormat::Float)
->setFormatConversionAllowed(true)
->setSharingMode(oboe::SharingMode::Shared)
->setPerformanceMode(oboe::PerformanceMode::LowLatency)
->setDeviceId(params.deviceId) // only applicable for AAudio. This is ignored for OpenSL.
->setCallback(callback);
auto tmpStreamResult = streamBuilder
.setDirection(getDirection())
->openStream(tmpStream);
We don't have access to any of these devices. So this is the info we have for now. As and when we get more info based on our investigation, we'll update it here.
Thanks for the report. This is very concerning! We are now tracking the bug internally at: b/182320633
Some users also reported that the app freezes upon opening.
Is this happening every time? How often?
I tried Pocket Shruti Box on a Pixel 3a running RQ2A and it seemed to run fine.
Your stream open parameters look good. There should be no problem.
In order to figure out where it is hanging, we need to see a bugreport with tombstones. We also need to know the exact version of Android 11. If you can get a bugreport file then please create a bug here:
https://issuetracker.google.com/issues?q=componentid:192705
and then attach the bugreport file.
Samsung replied:
We checked Pocket Shruti Box and Shruti Carnatic Tuner on 3 devices running Android 11.
exynos9611: M21, A51 exynos9810: Samsung Galaxy Note10 Lite
Those devices support MMAP and both two apps are working well without ANR.
Can you please provide more information that will help us reproduce the error.
Does the ANR happen after plugging in headphones?
Does it happen after rebooting the phone?
I missed to respond to this. Terribly sorry about the delay.
Is this happening every time? How often?
From our users, it seems that it is happening every time. Please note however, that on these same devices the app used to work fine. The problem happens only after the update to Android 11.
One of the users ran our audio tests. They ran fine. It is not clear in which situation ANR happens on these devices.
We also need to know the exact version of Android 11
This is the info we have:
Android: 30 (11)
Device: samsung / SM-M307F / m30s
Board: exynos9611 Hardware: exynos9611
ABIs: arm64-v8a, armeabi-v7a, armeabi
Build: RP1A.200720.012.M307FXXU4CUAG
Fingerprint: samsung/m30sdd/m30s:11/RP1A.200720.012/M307FXXU4CUAG:user/release-keys
Screenshots from the user

we need to see a bugreport with tombstones
We have the bug reports on Google Play Console. It should be possible to get the full report, but we couldn't see a way to export it. Would you like screenshots of the stack of different threads?
Does the ANR happen after plugging in headphones?
Our users didn't mention about the headphones. It is not usual to use headphones for one of the apps for which the problem is reported.
Does it happen after rebooting the phone?
Rebooting does not help to address the ANRs/hanging. This is confirmed by the user. On a related note, we have one user who reported problem with volume being muted on Android 11 Samsung exynos9611 which was resolved by rebooting the device. This could be a different issue, but mentioned it just in case.
@rpatttabi - Thanks so much for your help with this. I really appreciate it.
I am concerned about a deadlock when pausing or stopping a stream. If that locked up the server then the next open would fail.
I am trying to figure out what is different about your apps.
Are you by any chance starting and then quickly stopping a stream? Maybe as a test?
Are you calling AAudioStream_release()?
->openStream(tmpStream);
Is tmpStream of type std::shared_ptroboe::AudioStream ?
Would you like screenshots of the stack of different threads?
I am interested in any stack traces you can get. Particularly traces from the audioserver that include stop() or pause(). And any that appear to be stuck waiting for a mutex.
My only Exynos CPU device is a Samsung Galaxy S9 which cannot be upgraded to Android 11. I am currently trying to get my hands on a Samsung Galaxy A51. If I'm successful I will attempt to reproduce.
Are you by any chance starting and then quickly stopping a stream?
Yes, we start a temporary stream to assess frames per burst and audio api. We just open it and after getting the details, we close it. We don't start it. Just opening and closing.
Are you calling AAudioStream_release()?
No, we never call release on any of our streams. Usually stop() and close().
Is tmpStream of type std::shared_ptr?
All our streams are std::shared_ptr<oboe::AudioStream> and opened using openStream().
I am interested in any stack traces you can get
ANR at stop is very rare. Of the 70 odd ANRs I checked only 2 of them happened during stop. About two thirds happened at open. Rest at start.
Open
#00 pc 000000000009b124 /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+4)
#00 pc 0000000000057dd0 /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+156)
#00 pc 00000000000529e4 /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+296)
#00 pc 0000000000053d38 /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+60)
#00 pc 0000000000053aa8 /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+184)
#00 pc 000000000004c014 /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+152)
#00 pc 000000000003d624 /system/lib64/libaaudio_internal.so (android::BpAAudioService::openStream(aaudio::AAudioStreamRequest const&, aaudio::AAudioStreamConfiguration&)+336)
#00 pc 0000000000039714 /system/lib64/libaaudio_internal.so (aaudio::AAudioBinderClient::openStream(aaudio::AAudioStreamRequest const&, aaudio::AAudioStreamConfiguration&)+172)
#00 pc 000000000002f180 /system/lib64/libaaudio_internal.so (aaudio::AudioStreamInternal::open(aaudio::AudioStreamBuilder const&)+1576)
#00 pc 0000000000033fd0 /system/lib64/libaaudio_internal.so (aaudio::AudioStreamInternalPlay::open(aaudio::AudioStreamBuilder const&)+92)
#00 pc 0000000000022c5c /system/lib64/libaaudio_internal.so (aaudio::AudioStreamBuilder::build(aaudio::AudioStream**)+860)
#00 pc 00000000000037a8 /system/lib64/libaaudio.so (AAudioStreamBuilder_openStream.cfi+144)
#00 pc 00000000000770c4 /data/app/~~aFO-d1h9WZNAEQefbS5S7w==/org.kuyil.shrutibox-90izOBwAj4h54Ly_M1_qaw==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamAAudio::open()+524)
#00 pc 000000000006ff04 /data/app/~~aFO-d1h9WZNAEQefbS5S7w==/org.kuyil.shrutibox-90izOBwAj4h54Ly_M1_qaw==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamBuilder::openStream(oboe::AudioStream**)+608)
#00 pc 000000000006fd94 /data/app/~~aFO-d1h9WZNAEQefbS5S7w==/org.kuyil.shrutibox-90izOBwAj4h54Ly_M1_qaw==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamBuilder::openStream(oboe::AudioStream**)+240)
#00 pc 0000000000070398 /data/app/~~aFO-d1h9WZNAEQefbS5S7w==/org.kuyil.shrutibox-90izOBwAj4h54Ly_M1_qaw==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamBuilder::openStream(std::__ndk1::shared_ptr<oboe::AudioStream>&)+112)
Start
#00 pc 000000000009b124 /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+4)
#00 pc 0000000000057dd0 /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+156)
#00 pc 00000000000529e4 /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+296)
#00 pc 0000000000053d38 /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+60)
#00 pc 0000000000053aa8 /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+184)
#00 pc 000000000004c014 /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+152)
#00 pc 000000000003ddfc /system/lib64/libaaudio_internal.so (android::BpAAudioService::startStream(int)+308)
#00 pc 0000000000039d48 /system/lib64/libaaudio_internal.so (aaudio::AAudioBinderClient::startStream(int)+152)
#00 pc 000000000002e2d8 /system/lib64/libaaudio_internal.so (aaudio::AudioStreamInternal::requestStart()+568)
#00 pc 000000000002131c /system/lib64/libaaudio_internal.so (aaudio::AudioStream::systemStart()+336)
#00 pc 0000000000003c64 /system/lib64/libaaudio.so (AAudioStream_requestStart.cfi+148)
#00 pc 00000000000775cc /data/app/~~43Ar-M5f56Rf-1ailZWFeg==/org.kuyil.shrutibox-Yw7KrQccPis8lclnH7ePEw==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamAAudio::requestStart()+124)
#00 pc 000000000006f280 /data/app/~~43Ar-M5f56Rf-1ailZWFeg==/org.kuyil.shrutibox-Yw7KrQccPis8lclnH7ePEw==/lib/arm64/libpdnativeoboe.so (oboe::AudioStream::start(long)+28)
Stop
#00 pc 000000000009b124 /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+4)
#00 pc 0000000000057dd0 /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+156)
#00 pc 00000000000529e4 /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+296)
#00 pc 0000000000053d38 /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+60)
#00 pc 0000000000053aa8 /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+184)
#00 pc 000000000004c014 /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+152)
#00 pc 000000000003e1cc /system/lib64/libaaudio_internal.so (android::BpAAudioService::stopStream(int)+308)
#00 pc 000000000003a048 /system/lib64/libaaudio_internal.so (aaudio::AAudioBinderClient::stopStream(int)+152)
#00 pc 000000000002e7d8 /system/lib64/libaaudio_internal.so (aaudio::AudioStreamInternal::requestStop()+520)
#00 pc 0000000000021e64 /system/lib64/libaaudio_internal.so (aaudio::AudioStream::systemStopFromApp()+260)
#00 pc 00000000000777e8 /data/app/~~pXYdmcrQEPsXDXKOXJ0xTQ==/org.kuyil.shrutibox-5K_bJDrVz0QDoUBt1hCzeQ==/lib/arm64/libpdnativeoboe.so (oboe::AudioStreamAAudio::requestStop()+104)
#00 pc 000000000006f3c4 /data/app/~~pXYdmcrQEPsXDXKOXJ0xTQ==/org.kuyil.shrutibox-5K_bJDrVz0QDoUBt1hCzeQ==/lib/arm64/libpdnativeoboe.so (oboe::AudioStream::stop(long)+28)
I've managed to obtain a Samsung Galaxy A51:
ro.product.brand = samsung
ro.product.manufacturer = samsung
ro.product.model = SM-A515F
ro.product.device = a51
ro.product.cpu.abi = arm64-v8a
ro.build.description = a51nsxx-user 11 RP1A.200720.012 A515FXXU4DUB2 release-keys
ro.hardware = exynos9611
ro.hardware.chipname = exynos9611
ro.arch = exynos9610
| grep aaudio = [aaudio.hw_burst_min_usec]: [2000]
[aaudio.mmap_exclusive_policy]: [2]
[aaudio.mmap_policy]: [2]
I tested both apps on it but didn't experience any ANRs or crashes.
Is there any more reliable way to reproduce this issue?
@dturner Thanks for checking this. I suspected that this is specific to a particular Android 11 update. But I see from the build description you provided, it seems that the updates match.
As I mentioned before, all our audio tests ran fine on the problematic device. Really not sure on which conditions the issue is reproducible. I will get back if anything turns up.
Hmmm, it's frustrating that we can't reproduce as there's definitely a problem here. However, until we can reliably reproduce I will close this issue.
Feel free to add more details if you find anything more about this issue. We'll do the same.
I just obtained a Samsung Note10 Lite
ro.product.manufacturer = samsung
ro.product.model = SM-N770F
ro.product.device = r7
ro.product.cpu.abi = arm64-v8a
ro.build.description = r7naxx-user 11 RP1A.200720.012 N770FXXU7EUC6 release-keys
ro.hardware = exynos9810
ro.hardware.chipname = exynos9810
ro.arch = exynos9810
I installed Pocket Shruti Box and tried plugging and unplugging a 3.5mm jack and a USB adapter dozens of times. It did not fail. No ANRs.
I am now leaving it running overnight to see what happens.
I am reopening this because I am concerned that this may be related to a possible deadlock in the AAudio service. It is actually my highest priority bug at the moment. I now have several Samsung devices for testing and will be running lots of tests.
@rpattabi - I ran Pocket Shruti Box and it says: 04-22 17:42:24.423 26849 24459 I OboeAudio: openStream() OUTPUT -------- OboeVersion1.4.3 --------
I recommend using OboeVersion 1.5 because it has a number of bug fixes.
I ran the WaveMaker app on an A51, which can trigger #1145. Apparently the changes in RQ1A are not in the RP1A where we see the failures. So this Issue is not cause by the changes to the locking that led to #1145.
I ran Pocket Shruti for 13.5 hours. It had distorted sound but when I unlocked the device and touched the screen the sound cleared up.
I plugged in headphones and unplugged and the sound was fine. So it seems the problem is intermittent and difficult to reproduce. This is good for users but that make it harder for us to analyze.
Let's keep this open for a few weeks in case we can get more data.
@rpattabi - I notice that Pocket Shruti Box is running all the time even when I do not launch the app!
REPRODUCE Install Pocket Shruti Box. adb reboot Wait for phone to boot. adb shell dumpsys media.aaudio adb shell dumpsys media.aaudio
EXPECT No running devices.
ACTUAL I see a shared stream running and advancing its frame counts. I used the PID and entered:
adb shell ps | grep {PID_from_dumpsys}
and got "org.kuyil.shrutibox".
When I ran OboeTester, I could NOT get an Exclusive stream.
I uninstalled Pocket Shruti Box and tried this test again. Then there was no stream running and OboeTester could get an EXCLUSIVE stream.
Pocket Shruti Box should NOT run all the time. That will prevent other apps from getting low latency audio and will also drain the users battery. Please note that I was not using the app to produce sound and had not even run the app after rebooting.
@philburk Sorry about the late follow up. We've not been active at all.
Thanks a ton for finding this serious problem. It is never our intention to run the app or start the stream on reboot. The launch of app may be due to some services (e.g. firebase) which start on reboot and we, incorrectly assuming normal launch, start the audio. We'll fix Pocket Shruti Box.
I suspect many other apps could also be having similar issue. I remember there is something in audio policy for this (which didn't seem to help in this case). May be it is better to have the system to enforce a notification when an app in the background opens a stream (similar to what is mandated for running foreground service). This will make the developers aware of the stream and even if we miss, users can see the notification and some will report. This way audio apps unintentionally interfering with other audio apps could be minimized.
I wonder if the original problem reported here is the result of another app's interference. I have some basic questions:
- When shared stream is running, is it not possible to get an exclusive stream?
- OTOH, when an exclusive stream is running, is it possible to get a shared stream?
- Similarly, when a shared stream is running, is it possible to get another shared stream?
- In case of multiple audio apps, if an app gets a stream (exclusive or shared), does it imply that users can hear what it plays?

Hi! I have the problem on the Samsung Galaxy with openStream. Yesterday everything worked. Today I faced with ANR.
`oboe::AudioStreamBuilder builder; builder.setDirection(oboe::Direction::Input); builder.setPerformanceMode(oboe::PerformanceMode::LowLatency); builder.setSharingMode(oboe::SharingMode::Exclusive); builder.setSampleRate(48000); builder.setFormat(oboe::AudioFormat::Float); builder.setChannelCount(oboe::ChannelCount::Mono); builder.setCallback(recordingCallback); builder.setFramesPerCallback(480); builder.setContentType(oboe::ContentType::Speech); builder.setInputPreset(oboe::InputPreset::VoiceCommunication);
oboe::Result result = builder.openStream(mStream); `
Hi! I have the problem on the Samsung Galaxy with openStream. Yesterday everything worked. Today I faced with ANR.
`oboe::AudioStreamBuilder builder; builder.setDirection(oboe::Direction::Input); builder.setPerformanceMode(oboe::PerformanceMode::LowLatency); builder.setSharingMode(oboe::SharingMode::Exclusive); builder.setSampleRate(48000); builder.setFormat(oboe::AudioFormat::Float); builder.setChannelCount(oboe::ChannelCount::Mono); builder.setCallback(recordingCallback); builder.setFramesPerCallback(480); builder.setContentType(oboe::ContentType::Speech); builder.setInputPreset(oboe::InputPreset::VoiceCommunication);
oboe::Result result = builder.openStream(mStream); `
Next, my phone rebooted himself. Now everything works.
builder.setSharingMode(oboe::SharingMode::Exclusive);
I tried to use builder.setSharingMode(oboe::SharingMode::Shared); when my application was freeze but it did not help
Honestly, I do not understand what preceded this error. I develop an application from January this year and first come across this on my phone. I often use the phone in the car through Google Auto - perhaps this led to an error in the driver. I think this is a driver error. I can not find the application on my phone, which would block the work of my.
rpattabi wrote:
I wonder if the original problem reported here is the result of another app's interference.
Another app should not be able to cause an ANR.
I have some basic questions: When shared stream is running, is it not possible to get an exclusive stream?
It is not possible to get an EXCLUSIVE MMAP stream if another app already has a SHARED MMAP stream running.
OTOH, when an exclusive stream is running, is it possible to get a shared stream?
Starting in R, if one app has an EXCLUSIVE MMAP and then another app requests an EXCLUSIVE MMAP stream then the first stream will be disconnected. The second app will get a SHARED MMAP stream. If the first app reopens its stream it will get a SHARED MMAP stream. This was added to prevent an app from holding on to the EXCLUSIVE MMAP resource forever and not letting any other app use it.
Similarly, when a shared stream is running, is it possible to get another shared stream?
Yes.
In case of multiple audio apps, if an app gets a stream (exclusive or shared), does it imply that users can hear what it plays?
Yes, any running stream should be audible.
This seems to be stalled. Any new developments?
This might be an ANR due to an audioserver crash. See example of background operation in https://github.com/google/oboe/pull/1669.
Closing for now. Please start a fresh bug if you get more information.