Native audio lib hangs the app when built with NDK r13+, works with r11 or r12 - help needed

31 views
Skip to first unread message

Bartosz Nowotny

unread,
Jan 8, 2021, 3:18:16 PM1/8/21
to android-ndk
Hi!

I'm a developer of a Unity 3D game which uses a native library that utilizes fluidsynth to play MIDI music via OpenSL ES. It is based on music-synthesizer-for-android, following guidelines specified by Glenn Kasten, Raph, Levien, and Ian Ni-Lewis in High Performance Audio video.

Recently, we've tried to rebuild our native library using the same NDK version that Unity 3D uses the build the game, i.e. r19. Rebuilding our native library using r19 was straightforward and did not require any code changes. The issue is that the game hangs completely after playing a single note. I've bisected the NDK versions and confirmed that if we build our native synth library with NDK r11 or r12, it works as intended (i.e. we can play music, switch instruments etc.). When built with r13 and up, it always leads to the same result, app hangs completely without any error after playing a single note. Inspecting ADB logs there's nothing out of ordinary. We're at a loss.

Any ideas and tips on how to debug this? While I cannot share the source code, I am open to any ideas and can provide any logs deemed helpful. Please advise.

Regards,
Bartosz Nowotny


phil...@google.com

unread,
Jan 8, 2021, 4:21:09 PM1/8/21
to android-ndk
If you take a bugreport then look in the tombstones section. It will show a stack dump for each thread.
You may be able to see where the thread hung.

    https://source.android.com/devices/tech/debug

Are you playing a MIDI file or sending note commands to the synth?

Are there any native crashes in the bugreport file?

Also try stubbing out FluidSynth or OpenSL ES to see which one is hanging.

BTW, instead of using OpenSL ES directly, we now strongly recommend using Oboe instead.
Oboe uses AAudio on API 27 and later, and uses OpenSL ES on earlier versions.
(AAudio on API 26 is not stable.)
Oboe also has multiple workarounds for problems on various devices and Android versions.
And it can help you get better latency.

Bartosz Nowotny

unread,
Jan 12, 2021, 5:17:36 PM1/12/21
to android-ndk
Thank you for you reply.

After doing some research we've updated to the most recent FluidSynth which now ships with an Oboe driver. Basically, we work around the entire issue.

Consider this issue resolved.

Regards,
Bartosz Nowotny
Reply all
Reply to author
Forward
0 new messages