0

On some devices, android oboe library for high performance audio is working fine. However on other devices it crashes after loading the sound files.

This jni method is executed fine:

void SoundFunctions::loadSounds() {

    LOGD("SoundFunctions loadSounds called");

    // Load the RAW PCM data files for both the clap sound and backing track into memory.
    stdB = SoundRecording::loadFromAssets(mAssetManager, "std_kit_b.wav");
    stdSN= SoundRecording::loadFromAssets(mAssetManager, "std_kit_sn.wav");

    // Add all to mixer
    mMixer.addTrack(stdB);
    mMixer.addTrack(stdSN);


    // Create a builder
    AudioStreamBuilder builder;
    builder.setFormat(AudioFormat::I16);
    builder.setChannelCount(1);
    builder.setSampleRate(kSampleRateHz);
    builder.setCallback(this);
    builder.setPerformanceMode(PerformanceMode::LowLatency);
    builder.setSharingMode(SharingMode::Exclusive);
    LOGD("After creating a builder");

    // Open stream
    Result result = builder.openStream(&mAudioStream);
    if (result != Result::OK){
        LOGE("Failed to open stream. Error: %s", convertToText(result));
    }
    LOGD("After openstream");

    // Reduce stream latency by setting the buffer size to a multiple of the burst size
    mAudioStream->setBufferSizeInFrames(mAudioStream->getFramesPerBurst() * 2);

    // Start the stream
    result = mAudioStream->requestStart();
    if (result != Result::OK){
        LOGE("Failed to start stream. Error: %s", convertToText(result));
    }
    LOGD("After starting stream");


}

However, shortly afterwards, there is a native crash E/AudioALSAPlaybackHandlerBase: openPcmDriver(), pcm_start(0xeff82fc0) fail due to cannot start channel: Broken pipe

What does it mean and how can I resolve?

This is the error log:

12-12 14:55:14.995 11622-11622/com.learntomaster.dlmp D/RhythmGame: After starting stream 12-12 14:55:15.006 1462-1987/? E/AudioALSAPlaybackHandlerBase: openPcmDriver(), pcm_start(0xeff82fc0) fail due to cannot start channel: Broken pipe

--------- beginning of crash 12-12 14:55:15.047 11622-11622/com.learntomaster.dlmp A/libc: Fatal signal 11 (SIGSEGV),

code 1, fault addr 0x90 in tid 11622 (rntomaster.dlmp) 12-12 14:55:15.137 10957-11660/? E/Icing: Aborting indexing of corpus playlists 12-12 14:55:15.151 11895-11895/? I/AEE/AED: * * 12-12 14:55:15.152 11895-11895/? I/AEE/AED: Build fingerprint: 'Lenovo/LenovoTB3-850F/TB3-850F:6.0/MRA58K/TB3-850F_S100031_171010_ROW:user/release-keys' 12-12 14:55:15.152 11895-11895/? I/AEE/AED: Revision: '0' 12-12 14:55:15.152 11895-11895/? I/AEE/AED: ABI: 'arm64' 12-12 14:55:15.152 11895-11895/? I/AEE/AED: pid: 11622, tid: 11622, name: rntomaster.dlmp

com.learntomaster.dlmp <<< 12-12 14:55:15.152 11895-11895/? I/AEE/AED: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x90 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x0 0000000000000090 x1 0000007fdedc7540 x2 0000000000000000 x3 0000000000000000 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x4 0000000000000000 x5 0000000000000000 x6 0000000000000000 x7 0000000000000000 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x8 0000000000000001 x9 0000007f956290a0 x10 0000000000000001 x11 0000007f937c20e0 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x12 0000007f96ecea40 x13 0000000000000004 x14 0000000000000005 x15 00000000000000c0 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x16 0000007f9562e760 x17 0000007f96e9048c x18 0000007f937c20e0 x19 0000000000000000 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x20 0000000000000090 x21 0000007f7ea3b488 x22 0000007f7ea3b380 x23 0000007f7ea3b4b0 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x24 0000007fdedc7540 x25 0000000000000000 x26 0000007fdedc7a78 x27 0000279200002d66 12-12 14:55:15.174 11895-11895/? I/AEE/AED: x28 0000279200002d66 x29 0000007fdedc7490 x30 0000007f955948a4 12-12 14:55:15.174 11895-11895/? I/AEE/AED: sp 0000007fdedc7490 pc
0000007f96e90494 pstate 0000000060000000 12-12 14:55:15.195 1462-1988/? E/AudioFlinger: getNextBuffer, get null buffer 12-12 14:55:15.203 11895-11895/? I/AEE/AED: backtrace: 12-12 14:55:15.203 11895-11895/? I/AEE/AED: #00 pc 0000000000068494 /system/lib64/libc.so (pthread_mutex_lock+8) 12-12 14:55:15.203 11895-11895/? I/AEE/AED: #01 pc 000000000002f8a0 /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread5queueEPNS1_10RenderTaskE+28) 12-12 14:55:15.203 11895-11895/? I/AEE/AED: #02 pc 000000000002e324 /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread11RenderProxy11postAndWaitEPNS1_22MethodInvokeRenderTaskE+132) 12-12 14:55:15.203 11895-11895/? I/AEE/AED: #03 pc 000000000002e600 /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread11RenderProxy20loadSystemPropertiesEv+92) 12-12 14:55:15.203 11895-11895/? I/AEE/AED: #04 pc 0000000002a1b990 /system/framework/arm64/boot.oat (offset 0x2439000) 12-12 14:55:15.795 1858-1858/? E/WifiTrafficPoller: TRAFFIC_STATS_POLL true Token 14 num clients 9 12-12 14:55:15.796 1858-1858/? E/WifiTrafficPoller: packet count Tx=11477 Rx=15018 12-12 14:55:15.823 11895-11895/? I/AEE/AED: Tombstone written to: /data/tombstones/tombstone_04 12-12 14:55:15.824 11895-11895/? E/AEE/AED: AM write failed: Broken pipe 12-12 14:55:15.824 11895-11895/? E/AEE/AED: request.action: 0

TomV
  • 1,157
  • 1
  • 13
  • 25
  • "on other devices" - which devices? – donturner Dec 12 '18 at 17:36
  • Works fine on: Moto G6 (8.0), Nexus 7 (5.1), Galaxy S3 (4.3), Pixel 2 (9),K3 2017 (6.0). Native crash on: Mate 9 (7.0) LG S6 (7.0), Galaxy S9 (8.0), Xperia XZ1 Compact (8,0), Moto G4 Play (6.0) In fact, working closely with the Nexus 7, it seems the native crash happens sometimes. – TomV Dec 12 '18 at 18:20
  • Does the crash happen with any of the Oboe samples e.g. RhythmGame? – donturner Dec 17 '18 at 17:38
  • On the 4 test devices in the office, no crashes are experienced with RhythmGame. The other devices used for testing was those available from Google Play when you upload an .apk to beta. One big difference between the RhythmGame and our app is that we used a mixer for about 40 sound samples, where rhythm game has 2 or 3. Could this have anything to do with it? – TomV Dec 22 '18 at 15:19

1 Answers1

1

My guess is that your application is attempting to use more memory than is available to it. Each time you call SoundRecording::loadFromAssets you're loading the entire contents of a sound file into memory and you have 40 sound files.

If even one of these sound files fails to load then the resulting SoundRecording * object will be null pointer. This is added to the Mixer. After calling mAudioStream->requestStart() the first callback occurs during which Mixer::renderAudio is called, which in turn calls SoundRecording::renderAudio which dereferences that null pointer causing the SEGV_MAPERR.

I'm not 100% sure but I think at least one callback needs to occur to start the stream (it certainly does when using OpenSL ES), which would explain why the pcm_start method fails.

An easy way to verify this is to check for nullptr after calling loadFromAssets:

if (stdB == nullptr){ LOGE("Failed to load sound file"); }

You should also check out the updated sample code which fixes a memory leak in the RhythmGame sample, and uses smart pointers.

donturner
  • 17,867
  • 8
  • 59
  • 81
  • Thanks. Checking for the nullptr on loadingFromAssets has now increased the stability, as I can handle the native error elegantly. If I detect that, I revert from native oboe/c++ to the traditional Android Soundpool. – TomV Dec 31 '18 at 16:19
  • Just tried it on various devices, e.g. Samsung S9 (Android 8,0), Mate 9 Huawei (7.0), Sony Xperia XZ1 Compact (8.0), Samsung Galaxy S3 (Android 4.3) and still getting the SEGV_MAPERR crash, which unable to handle. Here's the error log from S9: Build fingerprint: 'samsung/starqlteue/starqlteue:8.0.0/R16NW/G960U1UEU1ARB7:user/release-keys' Revision: '14' ABI: 'arm64' pid: 24507, tid: 24507, name: rntomaster.dlmp >>> com.learntomaster.dlmp <<< signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x90 Cause: null pointer dereference – TomV Jan 01 '19 at 13:49