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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Bartosz Nowotny
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


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/9a5993a5-3f02-49e6-af73-b2a7d3d81ac2n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Phil Burk
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.


On Friday, January 8, 2021 at 12:18:16 PM UTC-8 Bartosz Nowotny wrote:
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


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/23d2f7c1-a815-465f-bb12-1a7b19237a7fn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

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

Bartosz Nowotny
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

On Friday, January 8, 2021 at 10:21:09 PM UTC+1 [hidden email] wrote:
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.


On Friday, January 8, 2021 at 12:18:16 PM UTC-8 Bartosz Nowotny wrote:
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


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/0073a669-63fa-416c-a643-cdffff4091b8n%40googlegroups.com.