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

Crash when exiting app using Oboe/AAudio on Android 8.0 #473

Closed
extreamsd opened this issue Apr 28, 2019 · 4 comments
Closed

Crash when exiting app using Oboe/AAudio on Android 8.0 #473

extreamsd opened this issue Apr 28, 2019 · 4 comments
Assignees

Comments

@extreamsd
Copy link

extreamsd commented Apr 28, 2019

So I finally decided to try out Oboe and I am facing several issues. Let's start with the crash on exit. I am running a Samsung S3 tablet with Android 8.0.0. The first question would be why Oboe defaults to OpenSLES on Android 8.0 and not AAudio since AAudio was introduced at Android 8? I read it defaults to AAudio on 8.1, but didn't find why.

So, all the app does to recreate the problem is:

oboe::AudioStreamBuilder builder;
builder.setDirection(oboe::Direction::Output);
builder.setPerformanceMode(oboe::PerformanceMode::LowLatency);
builder.setSharingMode(oboe::SharingMode::Exclusive);
builder.setFormat(oboe::AudioFormat::Float);
builder.setChannelCount(oboe::ChannelCount::Stereo);
builder.setSampleRate(GetMainSampleRate()); // which is 48000Hz and the native rate in this case
builder.setAudioApi(oboe::AudioApi::AAudio);
builder.setCallback(this);

oboe::Result result = builder.openStream(&m_oboePlaybackStream);

it opens fine. On the destructor of this class, m_oboePlaybackStream->close() is called, after checking if m_oboePlaybackStream is not a nullptr. No start() or requestStart() is called. Just opening the stream and closing it is enough to cause this.

A bit after the app finishes, I get the message in Android that the app has stopped and logcat shows:

2019-04-28 14:20:29.504 6652-6652/? A/DEBUG: Build fingerprint: 'samsung/gts3lwifixx/gts3lwifi:8.0.0/R16NW/T820XXU2BRL1:user/release-keys'
2019-04-28 14:20:29.504 6652-6652/? A/DEBUG: Revision: '5'
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: ABI: 'arm64'
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: pid: 6540, tid: 6562, name: Binder:6540_1 >>> com.extreamsd.aemobile <<<
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: Cause: null pointer dereference
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x0 000000726b682fc8 x1 0000007287b04f00 x2 0000000000000001 x3 0000000000000000
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x4 0000000000000000 x5 0000000000000000 x6 0000000000000000 x7 000000726ca56ec8
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x8 000000726b682f08 x9 00000000000000c0 x10 0000000000000008 x11 0000000000000000
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x12 000000726ca57298 x13 000000726ca572d0 x14 00000072878bbd20 x15 0000000000000000
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x16 0000007288cae3b0 x17 000000728b3ed6e8 x18 000000726ca55134 x19 0000000000000000
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x20 0000007287b04f00 x21 000000726b682fc8 x22 0000000000000000 x23 000000728b3f0e48
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x24 000000726ca57570 x25 000000726c95b000 x26 0000000000000000 x27 0000000000000000
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: x28 0000000000000000 x29 000000726ca57350 x30 0000007288c656f8
2019-04-28 14:20:29.505 6652-6652/? A/DEBUG: sp 000000726ca57330 pc 000000728b3ed704 pstate 0000000060000000
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: backtrace:
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #00 pc 000000000000d704 /system/lib64/libutils.so (_ZNK7android7RefBase9decStrongEPKv+28)
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #1 pc 00000000000626f4 /system/lib64/libbinder.so (_ZN7android14IPCThreadState20processPendingDerefsEv+136)
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #2 pc 000000000006275c /system/lib64/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+52)
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #3 pc 00000000000830e4 /system/lib64/libbinder.so (_ZN7android10PoolThread10threadLoopEv+24)
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #4 pc 000000000001160c /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+280)
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #5 pc 00000000000fcd20 /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+136)
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #6 pc 000000000006820c /system/lib64/libc.so (_ZL15__pthread_startPv+36)
2019-04-28 14:20:29.535 6652-6652/? A/DEBUG: #7 pc 000000000001f774 /system/lib64/libc.so (__start_thread+68)

When I leave out:
builder.setAudioApi(oboe::AudioApi::AAudio);

this does not happen. When I run it on a Samsung S9 with Android 9, it does not happen either.

I'm on NDK 20beta2 (only this version solves a serious bug in the x86 code generation of clang that I found, so I cannot run any version before this).

Does this just mean "Don't use AAudio on Android 8.0"?

@philburk
Copy link
Collaborator

Let's start with the crash on exit. I am running a Samsung S3 tablet with Android 8.0.0.
The first question would be why Oboe defaults to OpenSLES on Android 8.0 and not
AAudio since AAudio was introduced at Android 8?

Oboe uses OpenSL ES on 8.0 because AAudio crashes on exit on some devices running 8.0.
There was a race condition in another part of the system that caused the crash. It is fairly rare on some devices so we missed it before launch. But it is common on some device so we had to avoid using AAudio on 8.0.

I read it defaults to AAudio on 8.1, but didn't find why.

Good point. I will add a warning. #477

When I run it on a Samsung S9 with Android 9, it does not happen either.

The bug was fixed on 8.1.

Does this just mean "Don't use AAudio on Android 8.0"?

Right. It is there on 8.0. It is "supported". But it sometimes crashes so we do not "recommend" it. Oboe follows the recommendation by default.

For more detail, see the original bug: #40

@philburk philburk self-assigned this Apr 28, 2019
@extreamsd
Copy link
Author

Ok, thanks for the explanation! I'll know delve into track-to-track sync issues. :)

@philburk
Copy link
Collaborator

This is a separate issue but I wanted to warn you. If you have multiple internal output "tracks" then we recommend opening only one Oboe stream and mixing your tracks before output. The overhead for each Oboe stream is much higher if you open multiple Oboe Streams. Plus you cannot sync them accurately. Also there are limits to how many Oboe streams can be open at once.

@extreamsd
Copy link
Author

Of course, AEM never opens multiple streams and does all mixing itself. I'll create a separate issue for this when I have gathered enough information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants