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 in libaudioutils memcpy_to_i16_from_float #1329

Open
sonicdebris opened this issue Jul 5, 2021 · 7 comments
Open

Crash in libaudioutils memcpy_to_i16_from_float #1329

sonicdebris opened this issue Jul 5, 2021 · 7 comments
Assignees
Labels
bug Samsung specific to Samsung devices

Comments

@sonicdebris
Copy link

We have been receiving reports of the following crash through the play console. It looks like all are on Android 10:

#00  pc 000000000000f638  /system/lib64/libaudioutils.so (memcpy_to_i16_from_float+216)
  #00  pc 0000000000040224  /system/lib64/libaaudio.so (flowgraph::SinkI16::read(void*, int)+164)
  #00  pc 0000000000034c64  /system/lib64/libaaudio.so (aaudio::AudioStreamInternalPlay::writeNowWithConversion(void const*, int)+356)
  #00  pc 00000000000346c0  /system/lib64/libaaudio.so (aaudio::AudioStreamInternalPlay::processDataNow(void*, int, long, long*)+528)
  #00  pc 0000000000031ea8  /system/lib64/libaaudio.so (aaudio::AudioStreamInternal::processData(void*, int, long)+376)
  #00  pc 0000000000034234  /system/lib64/libaaudio.so (aaudio::AudioStreamInternalPlay::callbackLoop()+316)
  #00  pc 000000000001d388  /system/lib64/libaaudio.so (AudioStream_internalThreadProc(void*) [clone .cfi]+224)
  #00  pc 00000000000e3b24  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36)
  #00  pc 0000000000085330  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

We are unable to reproduce it ourselves, and I it looks like it's related to AAudio so not really an Oboe issue, but maybe there's some obvious way we might be misusing the Oboe API or something that can be fixed with a device or android version specific quirk?

I've noticed other people encountered the same issue:
https://www.audiokinetic.com/qa/7573/libaudioutils-memcpy_to_i16_from_float-memcpy_to_i16_from_float
https://forum.juce.com/t/android-audio-application-template-crashing-at-start-up-on-samsung-s9/44003
But no helpful info there.

@sonicdebris sonicdebris added the bug label Jul 5, 2021
@philburk philburk self-assigned this Jul 6, 2021
@philburk
Copy link
Collaborator

philburk commented Jul 6, 2021

@sonicdebris - thanks for the report. I have a few questions.

What version of Oboe are you using?

What devices are you seeing this on?

Generally this sort of problem occurs when a stream is closed while the callback is still running. Then the callback accesses freed memory. We have prevented the race conditions in AAudio in R and S. And we added workarounds to Oboe 1.5.0 that should prevent it on older versions. I recommend using the latest Oboe.

The key is to wait a few msec between stop and close. See PR #1017

Maybe we are not delaying enough. Increasing kDelayBeforeCloseMillis might solve this.

This issue is often associated with a disconnect event: #953

@sonicdebris
Copy link
Author

Thanks for looking into this. We are using oboe 1.5.1 and the play console reports are all from three devices:

  • Samsung Galaxy S9
  • Samsung Galaxy S9+
  • Samsung Galaxy Note9

All of them running Android 10 (Q).

We already plan upgrading to the latest Oboe, and will try and increase kDelayBeforeCloseMillis.

@philburk
Copy link
Collaborator

@sonicdebris - Did you try increasing kDelayBeforeCloseMillis ?

@philburk philburk added the Samsung specific to Samsung devices label Aug 18, 2021
@danoli3
Copy link

danoli3 commented Jan 17, 2022

Can confirm issue is present in latest Oboe for

  • Samsung Galaxy S9+
  • Samsung Galaxy Note9
backtrace:
  #00  pc 000000000000f638  /system/lib64/libaudioutils.so (memcpy_to_i16_from_float+216)
  #00  pc 0000000000040224  /system/lib64/libaaudio.so (flowgraph::SinkI16::read(void*, int)+164)
  #00  pc 0000000000034c64  /system/lib64/libaaudio.so (aaudio::AudioStreamInternalPlay::writeNowWithConversion(void const*, int)+356)
  #00  pc 00000000000346c0  /system/lib64/libaaudio.so (aaudio::AudioStreamInternalPlay::processDataNow(void*, int, long, long*)+528)
  #00  pc 0000000000031ea8  /system/lib64/libaaudio.so (aaudio::AudioStreamInternal::processData(void*, int, long)+376)
  #00  pc 0000000000034234  /system/lib64/libaaudio.so (aaudio::AudioStreamInternalPlay::callbackLoop()+316)
  #00  pc 000000000001d388  /system/lib64/libaaudio.so (AudioStream_internalThreadProc(void*) [clone .cfi]+224)
  #00  pc 00000000000e3b24  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36)
  #00  pc 0000000000085330  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

@philburk
Copy link
Collaborator

@sonicdebris and @danoli3 - Are you using the std::shared_ptr for the OboeStream?

std::shared_ptr<oboe::AudioStream> mStream;

@danoli3
Copy link

danoli3 commented Jan 18, 2022

Yes however it is static
static std::shared_ptr<oboe::AudioStream> audioStream;

@sonicdebris
Copy link
Author

sonicdebris commented Jan 18, 2022

@sonicdebris and @danoli3 - Are you using the std::shared_ptr for the OboeStream?

Yes, we are.

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

No branches or pull requests

3 participants