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 setFramesPerCallback(#frames) is used for input stream #778

Closed
katyo opened this issue Feb 2, 2020 · 9 comments · Fixed by #1011
Closed

Crash when setFramesPerCallback(#frames) is used for input stream #778

katyo opened this issue Feb 2, 2020 · 9 comments · Fixed by #1011
Assignees
Labels
bug P1 high priority
Milestone

Comments

@katyo
Copy link
Contributor

katyo commented Feb 2, 2020

Android Version(s): 9
Android Device(s): several
Oboe Version: latest

Short Description

I develop an app which operates with constantly sized buffer of frames. So I set the number of frames per callback with builder.setFramesPerCallback(256) but the aaudio backend crashes in this case.

Steps To Reproduce

Set the number of frames per callback using builder.setFramesPerCallback(N_of_frames).

Expected behavior

Normal operating.

Actual behavior

SIGABRT with:

F/AudioStreamRecord(26563): maybeConvertDeviceData() conversion size 512 too large for buffer 256
F/libc    (26563): Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 26636 (AudioRecord), pid 26563
<...>
backtrace:
    #00 pc 0000000000021afc  /system/lib64/libc.so (abort+124)
    #01 pc 00000000000080f8  /system/lib64/liblog.so (__android_log_assert+296)
    #02 pc 0000000000031b94  /system/lib64/libaaudio.so (aaudio::AudioStreamRecord::maybeConvertDeviceData(void const*, int)+236)
    #03 pc 000000000002e30c  /system/lib64/libaaudio.so (aaudio::AudioStreamLegacy::callDataCallbackFrames(unsigned char*, int)+260)
    #04 pc 00000000000371a4  /system/lib64/libaaudio.so (FixedBlockWriter::processVariableBlock(unsigned char*, int)+220)
    #05 pc 000000000002e928  /system/lib64/libaaudio.so (aaudio::AudioStreamLegacy::processCallbackCommon(int, void*)+696)
    #06 pc 000000000005ab04  /system/lib64/libaudioclient.so (android::AudioRecord::processAudioBuffer()+1396)
    #07 pc 000000000005a27c  /system/lib64/libaudioclient.so (android::AudioRecord::AudioRecordThread::threadLoop()+252)
    #08 pc 000000000000fb78  /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+280)
    #09 pc 000000000008429c  /system/lib64/libc.so (__pthread_start(void*)+36)
    #10 pc 00000000000233fc  /system/lib64/libc.so (__start_thread+68)

Additional context

Also I sets channels count to 1 (mono) if it matter.

@katyo katyo added the bug label Feb 2, 2020
@philburk philburk self-assigned this Feb 3, 2020
@philburk
Copy link
Collaborator

Thank you! I was able to reproduce this on master using OboeTester on Pixel 3a:

  1. launch OboeTester
  2. enter "Callback size:" 64
  3. tap TEST INPUT
  4. uncheck the MMAP box so we use the Legacy path
  5. tap OPEN
  6. tap START

Internal bug tracker at: 149249791

We should be able to add a workaround by using a BlockSizeAdapter in Oboe.

@philburk philburk added the P1 high priority label Feb 10, 2020
@rpattabi
Copy link
Contributor

We hit this problem when we tried to start input stream. Any update on this issue? We would appreciate a workaround.

@philburk
Copy link
Collaborator

I'll work on this next week.

@rpattabi
Copy link
Contributor

Few high priority issues were identified for this release v1.5. Any idea when this release can be expected? Rough idea about the release will help us plan our work.

corrados added a commit to jamulussoftware/jamulus that referenced this issue Sep 13, 2020
@philburk
Copy link
Collaborator

09-14 16:48:08.434 9495 9495 F DEBUG : Abort message: 'maybeConvertDeviceData() conversion size 128 too large for buffer 64'
(__android_log_assert+296)
09-14 16:48:08.440 9495 9495 F DEBUG : #2 pc 0000000000031b94 /system/lib64/libaaudio.so (aaudio::AudioStreamRecord::maybeConvertDeviceData(void const*, int)+236)
09-14 16:48:08.440 9495 9495 F DEBUG : #3 pc 000000000002e30c /system/lib64/libaaudio.so (aaudio::AudioStreamLegacy::callDataCallbackFrames(unsigned char*, int)+260)
09-14 16:48:08.440 9495 9495 F DEBUG : #4 pc 00000000000371a4 /system/lib64/libaaudio.so (FixedBlockWriter::processVariableBlock(unsigned char*, int)+220)
09-14 16:48:08.440 9495 9495 F DEBUG : #5 pc 000000000002e928 /system/lib64/libaaudio.so (aaudio::AudioStreamLegacy::processCallbackCommon(int, void*)+696)
09-14 16:48:08.440 9495 9495 F DEBUG : #6 pc 00000000000599ac /system/lib64/libaudioclient.so (android::AudioRecord::processAudioBuffer()+1396)

@philburk
Copy link
Collaborator

This is tracked internally in
b/149249791 | AAudio INPUT asserts if AAudioStreamBuilder_setFramesPerDataCallback(small) used
A fix for this is in R AAudio.

philburk added a commit that referenced this issue Sep 15, 2020
Avoid using callback size adapters in AAudio because of various bugs.
If setFramesPerCallback() called then use a filter stream and do the
block size adaptation in Oboe as part of the data conversion flowgraph.

Fixes #778
Fixes #973
Fixes #983
@philburk
Copy link
Collaborator

@rpattabi - does PR #1011 fix this problem for you?

@rpattabi
Copy link
Contributor

On Nokia 5.1 Plus (Android 10), we still experience the same crash. This is what we did:

  1. Pulled cbsizeproxy branch and built oboe tester.
  2. Built and launched oboe tester.
  3. Set callback size to 256
  4. Test Input > Open > Start

Crashes with

09-15 10:21:23.299  9392  9447 F AudioStreamRecord: maybeConvertDeviceData() conversion size 512 too large for buffer 256
09-15 10:21:23.299  9392  9447 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 9447 (AudioRecord), pid 9392 (oboe.manualtest)

It crashes irrespective of the callback size. If we set 512, the error reads conversion size 1024 too large for buffer 512. Native crash stack trace is at https://gist.github.com/rpattabi/7bd4e814b9af7d3aff09298621f17f59

Device details:

ro.product.brand = Nokia
ro.product.manufacturer = HMD Global
ro.product.model = Nokia 5.1 Plus
ro.product.device = PDA_sprout
ro.product.cpu.abi = arm64-v8a
ro.build.description = Panda_00WW-user 10 QP1A.190711.020 00WW_3_11E release-keys
ro.hardware = mt6771

If you want us to check anything specific, please let us know.

philburk added a commit that referenced this issue Sep 16, 2020
Avoid using callback size adapters in AAudio because of various bugs.
If setFramesPerCallback() called then use a filter stream and do the
block size adaptation in Oboe as part of the data conversion flowgraph.

Fixes #778
Fixes #973
Fixes #983
@rpattabi
Copy link
Contributor

Got the latest from master which has this change. Tried the scenario I mentioned in the previous message. It crashed as before. However, I realize that I didn't check "enable Oboe workarounds" before.

With workarounds enabled, there is no crash and input works fine on the same device (Nokia 5.1 plus). I guess that's the reason this issue is closed which makes sense. Thank you.

philburk added a commit that referenced this issue May 26, 2022
The TODO said they were hanging. But I think that was caused by
a native crash in AAudio related to callback size.

See #778
philburk added a commit that referenced this issue May 28, 2022
The TODO said they were hanging. But I think that was caused by
a native crash in AAudio related to callback size.

See #778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P1 high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants