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

Crashes on many Android 8.0 devices #40

Closed
svenoaks opened this issue Jan 7, 2018 · 33 comments
Closed

Crashes on many Android 8.0 devices #40

svenoaks opened this issue Jan 7, 2018 · 33 comments
Assignees
Labels
bug P1 high priority

Comments

@svenoaks
Copy link

svenoaks commented Jan 7, 2018

I recently tried Oboe in my app for sound output for Android 8.0+ (only). I had to halt rollout because probably the majority of devices with Android 8.0 (none with 8.1) have repeating crashes probably making app unusable. I can't reproduce on API 26 or 27 emulator or a Nexus 5X which I upgraded and tested on both 8.0 and 8.1. When I removed Oboe for 8.0 in new release crashes went away.

The most common crashes not directly implicate Oboe, but lesser crashes on same devices do. Perhaps relevant information is I am building Oboe with old Android.mk system and with APP_PLATFORM = android-14 (though I think it is using 21 for Arm64 anyway automatically). Clang and c++_shared. NDK latest version in SDK manager. 16.1.4479499

Thinking about buying one of these devices and trying to get more information.

1
2
3
4
5
6
7
8

@philburk philburk self-assigned this Jan 8, 2018
@philburk philburk added the bug label Jan 8, 2018
@philburk
Copy link
Collaborator

philburk commented Jan 8, 2018

Thanks for this report. We need to resolve this.

Some background:
On 8.0 devices Oboe will use AAudio by default because it is available. AAudio on those 8.0 will use the older legacy audio data path. It only uses MMAP on Pixel devices on 8.1+.

Do you have a bugreport file that we can analyze?

If not, can you provide an APK that crashes so we can collect a bugreport.

The most common crashes not directly implicate Oboe, but lesser crashes on same devices do.

This might be related to some "smart pointer" issues. There were changes between 8.0 and 8.1 in that area. That can cause seemingly random crashes. The mentions of RefBase::decStrong are a possible clue.

In your code, are you stopping and restarting a stream multiple times?

Are you using any of the error callback functions?

Are you using the latest or a recent Oboe?

@svenoaks
Copy link
Author

svenoaks commented Jan 9, 2018

Unfortunately I don't have a bug report file at this time beyond the stack traces. I tried flashing Nexus 5X back to 8.0 and can't repo.

Stream is created and started with requestStart(), stream is requestPause() and requestStart() on play/pause button. Stream is requestStop() and close(), and a new one can be created quickly when the track changes.
Here is link to apk that can cause the crash:

https://drive.google.com/file/d/18GKXpLnN6ooIxzhHUFNijscKiFIDScJF/view?usp=sharing

Most of the code used was basically hello_oboe. Except stream is created like this:

void ElastiquePlayer::createPlaybackStream() {
        oboe::AudioStreamBuilder builder;
        if (builder.isAAudioSupported()) {
                builder.setDirection(oboe::Direction::Output);
                builder.setPerformanceMode(oboe::PerformanceMode::LowLatency);
                builder.setSharingMode(oboe::SharingMode::Exclusive);
                //PROPERTY_OUTPUT_SAMPLE_RATE
                builder.setSampleRate(samplerate);
                builder.setChannelCount(2);
                builder.setFormat(oboe::AudioFormat::I16);
                builder.setCallback(this);

                oboe::Result result = builder.openStream(&audioStream);

                mFramesPerBurst = audioStream->getFramesPerBurst();

                audioStream->setBufferSizeInFrames(buffersize > mFramesPerBurst? buffersize : mFramesPerBurst);
                
                //this line is actually a bug, but was in the apk. buffersize would be at least 
                //PROPERTY_OUTPUT_FRAMES_PER_BUFFER big. (Is 
                //PROPERTY_OUTPUT_FRAMES_PER_BUFFER always the same as frames per burst?)
                audioStream->setBufferSizeInFrames(buffersize);

                mLatencyTuner = std::unique_ptr<oboe::LatencyTuner>(new oboe::LatencyTuner(*audioStream));

                result = audioStream->requestStart();
                if (result != oboe::Result::OK) {
                    LOGI("Error starting stream. %s", oboe::convertToText(result));
                }
        } else {
          ...
        }
}

@philburk
Copy link
Collaborator

philburk commented Jan 9, 2018

Thanks Steve. I got the APK and found an icon called "MusicSpeed". I assume that is the app. You can remove that APK from Drive now. I will run the app against 8.0.

This might be related to an internal issue relating to pointer management. That can look pretty random. But I'm not sure yet.

Your open code looks fine. Are you doing anything in the callback in response to errors, eg. headphone disconnects?

When you try to reproduce the error, try plugging and unplugging headphones. Also try starting and stopping other sound apps or send the phone a notification. Also try starting a bunch of other apps and leaving them open so that there is memory pressure.

PROPERTY_OUTPUT_FRAMES_PER_BUFFER always the same as frames per burst?

For the legacy data path, when using the speakers or wired headphones, on 8.0, generally yes.
Bluetooth uses much larger burst sizes. MMAP mode to speakers on 8.1 can use smaller bursts.
The query in Java is useful as a starting point but is not specific enough. You have to actually open the stream before you can know the real size. That is why in AAudio we let the lower level code report its actual burst size.

@philburk
Copy link
Collaborator

philburk commented Jan 9, 2018

I started an internal bug tracker b/71758614

@philburk philburk added the P1 high priority label Jan 9, 2018
@svenoaks
Copy link
Author

svenoaks commented Jan 9, 2018

Tried all those things on Nexus 5X with 8.0 with Sept 5, 2017 security patch. Yes I have the error callback for disconnects, tried plug/unplug headphones rapidly, connecting/disconnecting to bluetooth speakers, other music apps and switch rapidly, ducking under notification, rapid play/pause and track switching. It's all completely solid, no crashes.

Haven't tried filling up memory yet but you may be on to something. In Fabric, all the devices are listed as between 1-5% RAM free. The rate of crashing is very high, which may suggest there is something with oboe and these devices that is causing some sort of memory leak. I have other unrelated crashes with MAPERR, that I can replicate by consuming tons of memory, but these are at much lower rates on mostly old devices with low memory.

@philburk
Copy link
Collaborator

The memory leak may or may not be in AAudio. I suspect not.

But I suspect that low memory conditions may be causing the lowmemorykiller to kill some processes, and for the garbage collector to behave differently. That may be triggering a bug that is normally not exposed.

@svenoaks
Copy link
Author

Slowly filling a vector until it crashes doesn't reveal much, not the same stack trace.

I should also mention I did release a beta with oboe for Android < 8.0 where it would use OpenSL. No crashes there either.

Only thing to do seems to get ahold of one of those devices, are any accessible to you?

@dturner
Copy link
Collaborator

dturner commented Jan 10, 2018

I should be able to get my hands on some of the models which are crashing in the office today - will try to repro as soon as I'm there.

@dturner
Copy link
Collaborator

dturner commented Jan 10, 2018

Test environment

Device: Sony Xperia XZ (Model: F8331)
Android version: 8.0.0
Build number: 41.3.A.2.24

Steps to reproduce:

Expected result

  • Track changes to next track in playlist and continues to change with each successive tap

Actual result

  • App crashes with the following logcat output:
01-10 12:29:43.228 12768-12768/? D/AAudio: AAudioStream_requestStop(0x7c6fff0e00)
01-10 12:29:43.228 12768-12768/? D/AudioTrack: stop() called with 70272 frames delivered
                                               
                                               [ 01-10 12:29:43.230 12768:12768 D/         ]
                                               PlayerBase::stop() from IPlayer
01-10 12:29:43.430 12768-12768/? D/AAudio: AAudioStream_close(0x7c6fff0e00)
                                           
                                           [ 01-10 12:29:43.432 12768:12768 D/         ]
                                           TrackPlayerBase::~TrackPlayerBase()
                                           
                                           [ 01-10 12:29:43.432 12768:12768 D/         ]
                                           PlayerBase::~PlayerBase()
01-10 12:29:43.456 12768-12768/? D/OboeAudio: AudioStreamBuilder.build(): mAudioApi 0, mChannelCount = 2, mFramesPerCallback = 0
01-10 12:29:43.456 12768-12768/? D/OboeAudio: AudioStreamAAudio() call isSupported()
01-10 12:29:43.456 12768-12768/? D/OboeAudio: AudioStreamAAudio():  AAudio_createStreamBuilder()
01-10 12:29:43.456 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() try with deviceId = 0
01-10 12:29:43.456 12768-12768/? D/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
01-10 12:29:43.456 12768-12768/? D/AAudio: AudioStreamBuilder(): mmapPolicy = 1, mapExclusivePolicy = 1
01-10 12:29:43.456 12768-12768/? W/AAudio: AudioStreamBuilder(): EXCLUSIVE sharing mode not supported. Use SHARED.
                                           
                                           [ 01-10 12:29:43.456 12768:12768 D/         ]
                                           PlayerBase::PlayerBase()
                                           
                                           [ 01-10 12:29:43.457 12768:12768 D/         ]
                                           TrackPlayerBase::TrackPlayerBase()
01-10 12:29:43.457 12768-12768/? I/AAudio: AudioStream::open() rate = 48000, channels = 2, format = 1, sharing = 1, dir = OUTPUT
01-10 12:29:43.457 12768-12768/? I/AAudio: AudioStream::open() device = 0, perfMode = 12, callbackFrames = 0
01-10 12:29:43.457 12768-12768/? D/AAudio: AudioStreamTrack::open(), request notificationFrames = -8, frameCount = 0
01-10 12:29:43.457 671-1995/? D/compress_voip: voice_extn_compress_voip_out_get_parameters: enter
01-10 12:29:43.458 12768-12768/? I/AudioTrack: AUDIO_OUTPUT_FLAG_FAST successful; frameCount 1536 -> 1536
01-10 12:29:43.458 12768-12768/? D/AudioTrack: Client defaulted notificationFrames to 192 for frameCount 1536
01-10 12:29:43.460 12768-12768/? D/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for (0x7c61a98600) ----------------
01-10 12:29:43.460 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() app    format = 1
01-10 12:29:43.460 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() native format = 1
01-10 12:29:43.460 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() sample rate   = 48000
01-10 12:29:43.460 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() capacity      = 1536
01-10 12:29:43.460 12768-12768/? D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK, mAAudioStream = 0x7c61a98600
01-10 12:29:43.460 12768-12768/? D/AAudio: AAudioStream_requestStart(0x7c61a98600)
                                           
                                           [ 01-10 12:29:43.463 12768:12768 D/         ]
                                           PlayerBase::start() from IPlayer
01-10 12:29:43.464 12768-12768/? D/AAudio: AAudioStream_requestPause(0x7c61a98600)
                                           
                                           [ 01-10 12:29:43.465 12768:12768 D/         ]
                                           PlayerBase::pause() from IPlayer
01-10 12:29:43.474 12768-12768/? W/AudioManager: Use of stream types is deprecated for operations other than volume control
01-10 12:29:43.474 12768-12768/? W/AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-10 12:29:43.475 1411-3286/? I/MediaFocusControl:  AudioFocus  requestAudioFocus() from uid/pid 10000/12768 clientId=android.media.AudioManager@961957com.smp.musicspeed.player.PlayFileService@36f98ce req=1 flags=0x0
01-10 12:29:43.475 1411-1432/? D/CompatibilityInfo: mCompatibilityFlags - 0
01-10 12:29:43.475 1411-1432/? D/CompatibilityInfo: applicationDensity - 480
01-10 12:29:43.475 1411-1432/? D/CompatibilityInfo: applicationScale - 1.0
01-10 12:29:43.476 12768-12768/? D/AAudio: AAudioStream_requestStart(0x7c61a98600)
01-10 12:29:43.477 12768-12984/? D/AudioStreamLegacy: onAudioDeviceUpdate() deviceId 34
                                                      
                                                      [ 01-10 12:29:43.477 12768:12768 D/         ]
                                                      PlayerBase::start() from IPlayer
01-10 12:29:43.478 8428-8428/? I/MediaScannerReceiver: action: android.intent.action.MEDIA_SCANNER_SCAN_FILE uri: file:///storage/emulated/0/Download/organfinale.mp3
01-10 12:29:43.480 8428-8428/? D/MediaScannerReceiver: action: android.intent.action.MEDIA_SCANNER_SCAN_FILE path: /storage/emulated/0/Download/organfinale.mp3
01-10 12:29:43.481 1411-4128/? D/CompatibilityInfo: mCompatibilityFlags - 0
01-10 12:29:43.481 1411-4128/? D/CompatibilityInfo: applicationDensity - 480
01-10 12:29:43.481 1411-4128/? D/CompatibilityInfo: applicationScale - 1.0
01-10 12:29:43.511 12768-13037/? I/Sugar: WaveformRecord saved : 1
01-10 12:29:43.511 1024-3376/? I/AudioPolicyManagerCustom: FLAG None hence request for a primary output
01-10 12:29:43.512 1024-3376/? I/AudioPolicyManagerCustom: FLAG None hence request for a primary output
01-10 12:29:43.539 12768-12768/? D/AAudio: AAudioStream_requestStop(0x7c61a98600)
01-10 12:29:43.539 12768-12768/? D/AudioTrack: stop() called with 3072 frames delivered
                                               
                                               [ 01-10 12:29:43.540 12768:12768 D/         ]
                                               PlayerBase::stop() from IPlayer
01-10 12:29:43.543 12768-12773/? I/zygote64: Do partial code cache collection, code=248KB, data=157KB
01-10 12:29:43.543 12768-12773/? I/zygote64: After code cache collection, code=243KB, data=155KB
01-10 12:29:43.543 12768-12773/? I/zygote64: Increasing code cache capacity to 1024KB
01-10 12:29:43.586 8428-8428/? I/MediaScannerService: updateExternalStorageVolumes: mExternalStorageVolumes=/storage/emulated/0
01-10 12:29:43.599 1121-2213/? I/ExtendedUtils: printFileName fd(8) -> /storage/emulated/0/Download/organfinale.mp3
01-10 12:29:43.606 1107-8147/? I/ExtendedExtractor: QTIParser is prefered .. flags 0
01-10 12:29:43.606 1107-8147/? I/QComExtractorFactory: QTI parser is not preferred for mime: audio/mpeg
01-10 12:29:43.606 1107-8147/? E/QCExtractor:  ExtendedExtractor failed to instantiate extractor 
01-10 12:29:43.606 1107-8147/? I/ExtendedExtractor: ExtendedExtractor::create 0x0
01-10 12:29:43.607 1121-2213/? E/MediaExtractor: Trace connect 0xe787c2e0 0xe782d6c0
01-10 12:29:43.741 12768-12768/? D/AAudio: AAudioStream_close(0x7c61a98600)
                                           
                                           [ 01-10 12:29:43.744 12768:12768 D/         ]
                                           TrackPlayerBase::~TrackPlayerBase()
                                           
                                           [ 01-10 12:29:43.744 12768:12768 D/         ]
                                           PlayerBase::~PlayerBase()
01-10 12:29:43.762 12768-12768/? D/OboeAudio: AudioStreamBuilder.build(): mAudioApi 0, mChannelCount = 2, mFramesPerCallback = 0
01-10 12:29:43.762 12768-12768/? D/OboeAudio: AudioStreamAAudio() call isSupported()
01-10 12:29:43.762 12768-12768/? D/OboeAudio: AudioStreamAAudio():  AAudio_createStreamBuilder()
01-10 12:29:43.762 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() try with deviceId = 0
01-10 12:29:43.762 12768-12768/? D/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
01-10 12:29:43.762 12768-12768/? D/AAudio: AudioStreamBuilder(): mmapPolicy = 1, mapExclusivePolicy = 1
01-10 12:29:43.762 12768-12768/? W/AAudio: AudioStreamBuilder(): EXCLUSIVE sharing mode not supported. Use SHARED.
                                           
                                           [ 01-10 12:29:43.762 12768:12768 D/         ]
                                           PlayerBase::PlayerBase()
                                           
                                           [ 01-10 12:29:43.762 12768:12768 D/         ]
                                           TrackPlayerBase::TrackPlayerBase()
01-10 12:29:43.762 12768-12768/? I/AAudio: AudioStream::open() rate = 48000, channels = 2, format = 1, sharing = 1, dir = OUTPUT
01-10 12:29:43.762 12768-12768/? I/AAudio: AudioStream::open() device = 0, perfMode = 12, callbackFrames = 0
01-10 12:29:43.762 12768-12768/? D/AAudio: AudioStreamTrack::open(), request notificationFrames = -8, frameCount = 0
01-10 12:29:43.763 671-1995/? D/compress_voip: voice_extn_compress_voip_out_get_parameters: enter
01-10 12:29:43.764 12768-12768/? I/AudioTrack: AUDIO_OUTPUT_FLAG_FAST successful; frameCount 1536 -> 1536
01-10 12:29:43.764 12768-12768/? D/AudioTrack: Client defaulted notificationFrames to 192 for frameCount 1536
01-10 12:29:43.765 12768-12768/? D/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for (0x7c61a98600) ----------------
01-10 12:29:43.765 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() app    format = 1
01-10 12:29:43.765 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() native format = 1
01-10 12:29:43.765 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() sample rate   = 48000
01-10 12:29:43.765 12768-12768/? D/OboeAudio: AudioStreamAAudio.open() capacity      = 1536
01-10 12:29:43.765 12768-12768/? D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK, mAAudioStream = 0x7c61a98600
01-10 12:29:43.765 12768-12768/? D/AAudio: AAudioStream_requestStart(0x7c61a98600)
                                           
                                           [ 01-10 12:29:43.768 12768:12768 D/         ]
                                           PlayerBase::start() from IPlayer
01-10 12:29:43.769 12768-12768/? D/AAudio: AAudioStream_requestPause(0x7c61a98600)
                                           
                                           [ 01-10 12:29:43.769 12768:12768 D/         ]
                                           PlayerBase::pause() from IPlayer
01-10 12:29:43.777 12768-12984/? D/AudioStreamLegacy: onAudioDeviceUpdate() deviceId 34
01-10 12:29:43.783 12768-12768/? W/AudioManager: Use of stream types is deprecated for operations other than volume control
01-10 12:29:43.783 12768-12768/? W/AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-10 12:29:43.783 1411-3286/? I/MediaFocusControl:  AudioFocus  requestAudioFocus() from uid/pid 10000/12768 clientId=android.media.AudioManager@961957com.smp.musicspeed.player.PlayFileService@36f98ce req=1 flags=0x0
01-10 12:29:43.784 12768-12768/? D/AAudio: AAudioStream_requestStart(0x7c61a98600)
                                           
                                           [ 01-10 12:29:43.785 12768:12768 D/         ]
                                           PlayerBase::start() from IPlayer
01-10 12:29:43.785 1411-1432/? D/CompatibilityInfo: mCompatibilityFlags - 0
01-10 12:29:43.785 1411-1432/? D/CompatibilityInfo: applicationDensity - 480
01-10 12:29:43.785 1411-1432/? D/CompatibilityInfo: applicationScale - 1.0
01-10 12:29:43.786 8428-8428/? I/MediaScannerReceiver: action: android.intent.action.MEDIA_SCANNER_SCAN_FILE uri: file:///storage/emulated/0/Download/piano2-Audacity1.2.5.mp3
01-10 12:29:43.789 8428-8428/? D/MediaScannerReceiver: action: android.intent.action.MEDIA_SCANNER_SCAN_FILE path: /storage/emulated/0/Download/piano2-Audacity1.2.5.mp3
01-10 12:29:43.792 1411-3286/? D/CompatibilityInfo: mCompatibilityFlags - 0
01-10 12:29:43.792 1411-3286/? D/CompatibilityInfo: applicationDensity - 480
01-10 12:29:43.792 1411-3286/? D/CompatibilityInfo: applicationScale - 1.0
01-10 12:29:43.810 1024-1024/? I/AudioPolicyManagerCustom: FLAG None hence request for a primary output
01-10 12:29:43.811 1024-1024/? I/AudioPolicyManagerCustom: FLAG None hence request for a primary output
01-10 12:29:43.832 12768-13044/? I/Sugar: WaveformRecord saved : 2
01-10 12:29:43.847 12768-12768/? D/AAudio: AAudioStream_requestStop(0x7c61a98600)
01-10 12:29:43.847 12768-12768/? D/AudioTrack: stop() called with 3264 frames delivered
                                               
                                               [ 01-10 12:29:43.848 12768:12768 D/         ]
                                               PlayerBase::stop() from IPlayer
01-10 12:29:43.896 8428-8428/? I/MediaScannerService: updateExternalStorageVolumes: mExternalStorageVolumes=/storage/emulated/0
01-10 12:29:43.909 1121-2213/? I/ExtendedUtils: printFileName fd(8) -> /storage/emulated/0/Download/piano2-Audacity1.2.5.mp3
01-10 12:29:43.916 1107-8147/? I/ExtendedExtractor: QTIParser is prefered .. flags 0
01-10 12:29:43.916 1107-8147/? I/QComExtractorFactory: QTI parser is not preferred for mime: audio/mpeg
01-10 12:29:43.917 1107-8147/? E/QCExtractor:  ExtendedExtractor failed to instantiate extractor 
01-10 12:29:43.917 1107-8147/? I/ExtendedExtractor: ExtendedExtractor::create 0x0
01-10 12:29:43.919 1121-2213/? E/MediaExtractor: Trace connect 0xe787c4c0 0xe5ab1700
01-10 12:29:43.964 1411-1420/? I/zygote64: NativeAllocBackground concurrent copying GC freed 76711(3MB) AllocSpace objects, 6(136KB) LOS objects, 42% free, 19MB/33MB, paused 4.100ms total 187.498ms
01-10 12:29:43.973 12768-13006/? E/AAudio: stream not closed, in state 9
                                           
                                           [ 01-10 12:29:43.973 12768:13006 D/         ]
                                           TrackPlayerBase::~TrackPlayerBase()
                                           
                                           [ 01-10 12:29:43.974 12768:13006 D/         ]
                                           PlayerBase::~PlayerBase()
01-10 12:29:43.974 12768-13006/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xffffffffffffffe8 in tid 13006 (Binder:12768_6)
01-10 12:29:44.028 13080-13080/? W/crash_dump64: type=1400 audit(0.0:4407): avc: denied { search } for name="com.google.android.gms" dev="dm-1" ino=82100 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 ppid=1 pcomm="init" pgid=1 pgcomm="init"
01-10 12:29:44.028 13080-13080/? W/crash_dump64: type=1400 audit(0.0:4408): avc: denied { search } for name="com.smp.musicspeed" dev="dm-1" ino=901498 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 ppid=1 pcomm="init" pgid=1 pgcomm="init"
01-10 12:29:44.057 13080-13080/? I/crash_dump64: obtaining output fd from tombstoned
01-10 12:29:44.058 1169-1169/? I//system/bin/tombstoned: received crash request for pid 12768
01-10 12:29:44.058 13080-13080/? I/crash_dump64: performing dump of process 12768 (target tid = 13006)
01-10 12:29:44.059 13080-13080/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-10 12:29:44.059 13080-13080/? A/DEBUG: Build fingerprint: 'Sony/F8331/F8331:8.0.0/41.3.A.2.24/1453798961:user/release-keys'
01-10 12:29:44.059 13080-13080/? A/DEBUG: Revision: '0'
01-10 12:29:44.059 13080-13080/? A/DEBUG: ABI: 'arm64'
01-10 12:29:44.059 13080-13080/? A/DEBUG: pid: 12768, tid: 13006, name: Binder:12768_6  >>> com.smp.musicspeed <<<
01-10 12:29:44.059 13080-13080/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xffffffffffffffe8
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x0   0000007c62fd0760  x1   0000007c8c2d0980  x2   0000007c61a00000  x3   0000000000000010
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x4   0000000000000098  x5   0000007c6dc49210  x6   0000000000000000  x7   0000007c723f4800
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x8   0000007c6fff0f08  x9   0000000000000000  x10  0000000000000001  x11  0000000000000000
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x12  0000000000000001  x13  0000000000000000  x14  00000000ffffffff  x15  0000000000014580
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x16  0000007c90017cb8  x17  0000007c8ffb6040  x18  0000007c8bf7a280  x19  0000007c6d43c7c0
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x20  0000000000000002  x21  0000000000000001  x22  0000000000000000  x23  0000007c8d52deb0
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x24  0000007c6dc49570  x25  0000007c6db4d000  x26  0000000000000000  x27  0000000000000000
01-10 12:29:44.059 13080-13080/? A/DEBUG:     x28  00000000140c1e60  x29  0000007c6dc49380  x30  0000007c8eb8b1e4
01-10 12:29:44.059 13080-13080/? A/DEBUG:     sp   0000007c6dc49360  pc   0000007c8eb8b1d8  pstate 0000000080000000
01-10 12:29:44.077 13080-13080/? A/DEBUG: backtrace:
01-10 12:29:44.077 13080-13080/? A/DEBUG:     #00 pc 00000000000621d8  /system/lib64/libbinder.so (_ZN7android14IPCThreadState20processPendingDerefsEv+128)
01-10 12:29:44.077 13080-13080/? A/DEBUG:     #01 pc 0000000000062248  /system/lib64/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+52)
01-10 12:29:44.077 13080-13080/? A/DEBUG:     #02 pc 0000000000082bfc  /system/lib64/libbinder.so (_ZN7android10PoolThread10threadLoopEv+24)
01-10 12:29:44.077 13080-13080/? A/DEBUG:     #03 pc 0000000000011674  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+280)
01-10 12:29:44.077 13080-13080/? A/DEBUG:     #04 pc 00000000000b7214  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+136)
01-10 12:29:44.077 13080-13080/? A/DEBUG:     #05 pc 00000000000668a0  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
01-10 12:29:44.077 13080-13080/? A/DEBUG:     #06 pc 000000000001f374  /system/lib64/libc.so (__start_thread+68)

@dturner
Copy link
Collaborator

dturner commented Jan 10, 2018

Some comments:

  1. It's only necessary to create a new stream when the audio device changes (e.g. when inserting headphones), rather than each time a new track is loaded. You might be able to significantly reduce the number of crashes by keeping the same stream open all the time.

  2. I wasn't able to reproduce the issue by unplugging and replugging in the headphones.

  3. Would you be able to post your stream stop/close/reopen code? There's definitely a problem in there somewhere. It might be in your code, or in the way that legacy streams are handled on Android 8.0.

@svenoaks
Copy link
Author

Thanks for capturing it. You're right of course about creating a new stream everytime, but it would be a major redesign at this point. Will post my full code later.

01-10 12:29:43.973 12768-13006/? E/AAudio: stream not closed, in state 9

This happens right before crash, what is state 9?

@dturner
Copy link
Collaborator

dturner commented Jan 10, 2018

To make this bug easier to reproduce, and so you don't have to share (potentially proprietary) code I have modified the hello-oboe sample to reproduce this issue: https://github.com/googlesamples/android-audio-high-performance/tree/android-8.0-crash/oboe

Steps to reproduce:

  • Run the hello-oboe sample
  • Repeatedly tap the "Restart stream" button in quick succession

Expected result:

  • App does not crash

Actual result

  • App crashes with the following logcat output:
01-10 15:43:03.964 19639-19639/com.google.sample.oboe.hellooboe I/AUDIO-APP: Restarting stream
01-10 15:43:03.964 19639-19639/com.google.sample.oboe.hellooboe D/AAudio: AAudioStream_requestStop(0x7c8c27fc00)
01-10 15:43:03.964 19639-19639/com.google.sample.oboe.hellooboe D/AudioTrack: stop() called with 2304 frames delivered
                                                                              
                                                                              [ 01-10 15:43:03.964 19639:19639 D/         ]
                                                                              PlayerBase::stop() from IPlayer
01-10 15:43:03.964 19639-19639/com.google.sample.oboe.hellooboe D/AAudio: AAudioStream_close(0x7c8c27fc00)
                                                                          
                                                                          [ 01-10 15:43:03.966 19639:19639 D/         ]
                                                                          TrackPlayerBase::~TrackPlayerBase()
                                                                          
                                                                          [ 01-10 15:43:03.966 19639:19639 D/         ]
                                                                          PlayerBase::~PlayerBase()
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamBuilder.build(): mAudioApi 0, mChannelCount = 2, mFramesPerCallback = 0
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio() call isSupported()
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio():  AAudio_createStreamBuilder()
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio.open() try with deviceId = 0
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe D/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe D/AAudio: AudioStreamBuilder(): mmapPolicy = 1, mapExclusivePolicy = 1
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe W/AAudio: AudioStreamBuilder(): EXCLUSIVE sharing mode not supported. Use SHARED.
                                                                          
                                                                          [ 01-10 15:43:03.966 19639:19639 D/         ]
                                                                          PlayerBase::PlayerBase()
                                                                          
                                                                          [ 01-10 15:43:03.966 19639:19639 D/         ]
                                                                          TrackPlayerBase::TrackPlayerBase()
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe I/AAudio: AudioStream::open() rate = 0, channels = 2, format = 0, sharing = 1, dir = OUTPUT
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe I/AAudio: AudioStream::open() device = 0, perfMode = 12, callbackFrames = 0
01-10 15:43:03.966 19639-19639/com.google.sample.oboe.hellooboe D/AAudio: AudioStreamTrack::open(), request notificationFrames = -8, frameCount = 0
01-10 15:43:03.967 671-1436/? D/compress_voip: voice_extn_compress_voip_out_get_parameters: enter
01-10 15:43:03.968 1411-1420/? I/zygote64: Background concurrent copying GC freed 309380(14MB) AllocSpace objects, 28(1376KB) LOS objects, 42% free, 20MB/35MB, paused 1.849ms total 195.132ms
01-10 15:43:03.969 19639-19639/com.google.sample.oboe.hellooboe I/AudioTrack: AUDIO_OUTPUT_FLAG_FAST successful; frameCount 1536 -> 1536
01-10 15:43:03.969 19639-19639/com.google.sample.oboe.hellooboe D/AudioTrack: Client defaulted notificationFrames to 192 for frameCount 1536
01-10 15:43:03.970 19639-19639/com.google.sample.oboe.hellooboe W/AAudio: AudioStreamTrack::open() sampleRate changed from 0 to 48000
01-10 15:43:03.971 19639-19639/com.google.sample.oboe.hellooboe D/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for (0x7c8c27fc00) ----------------
01-10 15:43:03.971 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio.open() app    format = 2
01-10 15:43:03.971 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio.open() native format = 2
01-10 15:43:03.971 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio.open() sample rate   = 48000
01-10 15:43:03.971 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio.open() capacity      = 1536
01-10 15:43:03.971 19639-19639/com.google.sample.oboe.hellooboe D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK, mAAudioStream = 0x7c8c27fc00
01-10 15:43:03.971 19639-19639/com.google.sample.oboe.hellooboe D/AAudio: AAudioStream_requestStart(0x7c8c27fc00)
                                                                          
                                                                          [ 01-10 15:43:03.972 19639:19639 D/         ]
                                                                          PlayerBase::start() from IPlayer
01-10 15:43:03.978 19639-19653/com.google.sample.oboe.hellooboe D/AudioStreamLegacy: onAudioDeviceUpdate() deviceId 2
01-10 15:43:03.982 1024-13971/? I/AudioPolicyManagerCustom: FLAG None hence request for a primary output
01-10 15:43:03.982 1024-13971/? I/AudioPolicyManagerCustom: FLAG None hence request for a primary output
01-10 15:43:04.000 19639-19653/com.google.sample.oboe.hellooboe E/AAudio: stream not closed, in state 3
01-10 15:43:04.001 19639-19651/com.google.sample.oboe.hellooboe A/RefBase: decStrong() called on 0x7c71e64aa0 too many times
                                                                           
                                                                           [ 01-10 15:43:04.001 19639:19653 D/         ]
                                                                           TrackPlayerBase::~TrackPlayerBase()
01-10 15:43:04.001 19639-19653/com.google.sample.oboe.hellooboe D/AudioTrack: stop() called with 1152 frames delivered
01-10 15:43:04.001 19639-19667/com.google.sample.oboe.hellooboe A/RefBase: decStrong() called on 0x7c71e64aa0 too many times
01-10 15:43:04.001 19639-19745/com.google.sample.oboe.hellooboe A/RefBase: decStrong() called on 0x7c71e64aa0 too many times
01-10 15:43:04.002 19639-19652/com.google.sample.oboe.hellooboe A/RefBase: decStrong() called on 0x7c71e64aa0 too many times
                                                                           
                                                                           [ 01-10 15:43:04.002 19639:19653 D/         ]
                                                                           PlayerBase::~PlayerBase()
01-10 15:43:04.002 19639-19651/com.google.sample.oboe.hellooboe A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 19651 (Binder:19639_1)
01-10 15:43:04.050 20076-20076/? I/crash_dump64: obtaining output fd from tombstoned
01-10 15:43:04.050 1169-1169/? I//system/bin/tombstoned: received crash request for pid 19639
01-10 15:43:04.086 20076-20076/? I/crash_dump64: performing dump of process 19639 (target tid = 19651)
01-10 15:43:04.087 20076-20076/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-10 15:43:04.087 20076-20076/? A/DEBUG: Build fingerprint: 'Sony/F8331/F8331:8.0.0/41.3.A.2.24/1453798961:user/release-keys'
01-10 15:43:04.087 20076-20076/? A/DEBUG: Revision: '0'
01-10 15:43:04.087 20076-20076/? A/DEBUG: ABI: 'arm64'
01-10 15:43:04.087 20076-20076/? A/DEBUG: pid: 19639, tid: 19651, name: Binder:19639_1  >>> com.google.sample.oboe.hellooboe <<<
01-10 15:43:04.087 20076-20076/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
01-10 15:43:04.091 20076-20076/? A/DEBUG: Abort message: 'decStrong() called on 0x7c71e64aa0 too many times'
01-10 15:43:04.091 20076-20076/? A/DEBUG:     x0   0000000000000000  x1   0000000000004cc3  x2   0000000000000006  x3   0000000000000008
01-10 15:43:04.091 20076-20076/? A/DEBUG:     x4   0000000000000000  x5   0000000000000000  x6   0000000000000000  x7   7f7f7f7f7f7f7f7f
01-10 15:43:04.091 20076-20076/? A/DEBUG:     x8   0000000000000083  x9   b5300b0c549314dd  x10  0000000000000000  x11  0000000000000001
01-10 15:43:04.092 20076-20076/? A/DEBUG:     x12  ffffffffffffffff  x13  ffffffffffffffff  x14  ff00000000000000  x15  ffffffffffffffff
01-10 15:43:04.092 20076-20076/? A/DEBUG:     x16  0000007c900172e8  x17  0000007c8ffb8f10  x18  0000007c738e9a84  x19  0000000000004cb7
01-10 15:43:04.092 20076-20076/? A/DEBUG:     x20  0000000000004cc3  x21  0000007c8c27fdc8  x22  0000000000000000  x23  0000007c8d52deb0
01-10 15:43:04.092 20076-20076/? A/DEBUG:     x24  0000007c738eb570  x25  0000007c737ef000  x26  0000000000000000  x27  0000000000000000
01-10 15:43:04.092 20076-20076/? A/DEBUG:     x28  0000000000000000  x29  0000007c738eae10  x30  0000007c8ff6cfe4
01-10 15:43:04.092 20076-20076/? A/DEBUG:     sp   0000007c738eadd0  pc   0000007c8ffb8f18  pstate 0000000060000000
01-10 15:43:04.120 20076-20076/? A/DEBUG: backtrace:
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #00 pc 0000000000069f18  /system/lib64/libc.so (tgkill+8)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #01 pc 000000000001dfe0  /system/lib64/libc.so (abort+88)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #02 pc 0000000000007eec  /system/lib64/liblog.so (__android_log_assert+304)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #03 pc 000000000000d790  /system/lib64/libutils.so (_ZNK7android7RefBase9decStrongEPKv+168)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #04 pc 00000000000621e0  /system/lib64/libbinder.so (_ZN7android14IPCThreadState20processPendingDerefsEv+136)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #05 pc 0000000000062248  /system/lib64/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+52)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #06 pc 0000000000082bfc  /system/lib64/libbinder.so (_ZN7android10PoolThread10threadLoopEv+24)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #07 pc 0000000000011674  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+280)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #08 pc 00000000000b7214  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+136)
01-10 15:43:04.120 20076-20076/? A/DEBUG:     #09 pc 00000000000668a0  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
01-10 15:43:04.121 20076-20076/? A/DEBUG:     #10 pc 000000000001f374  /system/lib64/libc.so (__start_thread+68)

@dturner
Copy link
Collaborator

dturner commented Jan 10, 2018

@svenoaks State 9 is STOPPING. Full list of states:

    AAUDIO_STREAM_STATE_UNINITIALIZED = 0,
    AAUDIO_STREAM_STATE_UNKNOWN,        // 1
    AAUDIO_STREAM_STATE_OPEN,           // 2 
    AAUDIO_STREAM_STATE_STARTING,       // 3
    AAUDIO_STREAM_STATE_STARTED,        // 4
    AAUDIO_STREAM_STATE_PAUSING,        // 5
    AAUDIO_STREAM_STATE_PAUSED,         // 6
    AAUDIO_STREAM_STATE_FLUSHING,       // 7
    AAUDIO_STREAM_STATE_FLUSHED,        // 8
    AAUDIO_STREAM_STATE_STOPPING,       // 9
    AAUDIO_STREAM_STATE_STOPPED,        // 10
    AAUDIO_STREAM_STATE_CLOSING,        // 11
    AAUDIO_STREAM_STATE_CLOSED,         // 12
    AAUDIO_STREAM_STATE_DISCONNECTED    // 13

@philburk
Copy link
Collaborator

Thanks Don. Having an easy repro case will be a big help? Can you get it to crash on Marlin? if so then we can instrument AAudio and get a bit more info.

E/AAudio: stream not closed, in state 3

That is printed from the destructor for the stream in legacy mode. state 3 is starting.

Something is deleting that object while it is still in use. It could be a call from the app (hopefully, easy to fix). Or it could be internal, which I suspect is the case.

Feel free to move the detailed investigation to the internal bug tracker at b/71758614

@dturner
Copy link
Collaborator

dturner commented Jan 30, 2018

Action: Change the test to open and close stream. Try the address sanitizer.

@dturner dturner assigned mnaganov and unassigned philburk Jan 30, 2018
@svenoaks
Copy link
Author

svenoaks commented Feb 5, 2018

Hello, is there any update on status of this bug? (I can't see internal bug tracker) Or, most importantly how to fix, aside from leaving the same stream opened.

@mnaganov
Copy link
Collaborator

mnaganov commented Feb 5, 2018

I've attempted to reproduce this error on recent (that means, what will come after 8.1) Android builds instrumented with Address Sanitizer (ASAN), and haven't seen any problems so far. It's possible that the bug was indeed fixed after Android 8.0.

svenoaks@ Steve, do you see those crashes only in bugreports from 8.0, or there are also any from 8.1?

If this bug is specific for 8.0, then I would suggest disabling AAudio path in Oboe if the app is running on 8.0.

@svenoaks
Copy link
Author

svenoaks commented Feb 5, 2018 via email

mnaganov pushed a commit that referenced this issue Feb 6, 2018
From #40, it seems that AAudio
on Android 8.0 isn't stable enough. As a safety measure, always
fall back to OpenSL ES on it.
@mnaganov
Copy link
Collaborator

mnaganov commented Feb 6, 2018

Steven, you can try enabling Oboe again. On 8.0 devices it will now use OpenSL ES to avoid those AAudio crashes.

@mnaganov mnaganov closed this as completed Feb 6, 2018
dturner pushed a commit that referenced this issue Feb 12, 2018
From #40, it seems that AAudio
on Android 8.0 isn't stable enough. As a safety measure, always
fall back to OpenSL ES on it.
@svenoaks
Copy link
Author

Are we sure 8.1 is going to be fine when it is released on third party devices? Only devices which have 8.1 are Pixel and Nexus. The crash did not occur on Pixel and Nexus on 8.0 only third party.

It's a really bad bug, I hope it is actually fixed in 8.1. Now that I have device with 8.0 to repo it, it occurs any time stream closes even when disconnected headphones.

@rom1v
Copy link

rom1v commented May 15, 2018

I had the same problem with a stacktrace involving _ZNK7android7RefBase9decStrongEPKv (demangled as android::RefBase::decStrong(void const*) const).

The problem is probably fixed by 8a8a9e5d91c8cc110b9916982f4c5242efca33e3.

@stereomatch
Copy link

stereomatch commented May 18, 2018

Seeing the same thing as reported by svenoaks - for our hearing aid (low latency) app (using AAudio and not Oboe):

  • all crashes are for Android 8.0, none for 8.1
  • huge number of crashes (seems like 1/3 of user base)

362 reports for 202 impacted users are of this type:

21 minutes ago on app version 112
Samsung Galaxy S8 (dreamqltesq), 4096MB RAM, Android 8.0
Report 1


pid: 0, tid: 0 >>> com.stereomatch.hearing.aid <<<
backtrace:
#00 pc 00000000000626ec /system/lib64/libbinder.so (_ZN7android14IPCThreadState20processPendingDerefsEv+128)
#1 pc 000000000006275c /system/lib64/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+52)
#2 pc 00000000000830e0 /system/lib64/libbinder.so (_ZN7android10PoolThread10threadLoopEv+24)
#3 pc 0000000000011674 /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+280)
#4 pc 00000000000fce24 /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+136)
#5 pc 0000000000068160 /system/lib64/libc.so (_ZL15__pthread_startPv+36)
#6 pc 000000000001f664 /system/lib64/libc.so (__start_thread+68)

52 reports for 39 impacted users are of this type:

Today, 10:37 AM on app version 112
Xiaomi Mi A1 (tissot_sprout), 4096MB RAM, Android 8.0
Report 1


pid: 0, tid: 0 >>> com.stereomatch.hearing.aid <<<
backtrace:
#00 pc 000000000000d704 /system/lib64/libutils.so (_ZNK7android7RefBase9decStrongEPKv+28)
#1 pc 00000000000622dc /system/lib64/libbinder.so (_ZN7android14IPCThreadState20processPendingDerefsEv+136)
#2 pc 0000000000062344 /system/lib64/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+52)
#3 pc 0000000000082ca8 /system/lib64/libbinder.so (_ZN7android10PoolThread10threadLoopEv+24)
#4 pc 0000000000011674 /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+280)
#5 pc 00000000000b7bc0 /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+136)
#6 pc 0000000000066660 /system/lib64/libc.so (_ZL15__pthread_startPv+36)
#7 pc 000000000001f164 /system/lib64/libc.so (__start_thread+68)

Since we promise a low-latency solution - probably we will just limit the app to target Oreo 8.1 and above (thereby losing out on the 8.0 demographic).

Unless there is a way to circumvent the bug, or close the app before we do a close stream (if close stream is the one causing the crash).

@philburk
Copy link
Collaborator

We do not know of a way to circumvent the bug in AAudio.

We believe that the bug is limited to Oreo 8.0 and was fixed for 8.1. The changes are too extensive to back-port to AOSP.

It can sometime be triggered by Java garbage collector so the behavior can seem a bit random.

@stereomatch
Copy link

Thanks.

@zipswich
Copy link

zipswich commented Sep 6, 2018

An app suddenly had a surge of crashes looking related to this thread. I don't think it is related to Java code change, it may related to the change of build.gradle. I am wondering if compileSdkVersion has any impact on this.

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
_ZNK7android7RefBase9decStrongEPKv
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
backtrace:
  #00  pc 000000000000d704  /system/lib64/libutils.so (_ZNK7android7RefBase9decStrongEPKv+28)
  #01  pc 00000000001555e4  /system/lib64/libstagefright.so (_ZN7android10MediaCodec5resetEv+76)
  #02  pc 0000000000032c74  /system/lib64/libmedia_jni.so (_ZL30android_media_MediaCodec_resetP7_JNIEnvP8_jobject+80)
  #03  pc 000000000069290c  /system/framework/arm64/boot-framework.oat (android.os.Binder.destroy [DEDUPED]+124)
  #04  pc 0000000000e093bc  /system/framework/arm64/boot-framework.oat (android.media.MediaCodec.reset+60)
  #05  pc 0000000000507f84  /system/lib64/libart.so (art_quick_invoke_stub+580)
  #06  pc 00000000000d84f4  /system/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+200)
  #07  pc 0000000000282158  /system/lib64/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+352)
  #08  pc 000000000027c820  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+672)
  #09  pc 00000000004f2908  /system/lib64/libart.so (MterpInvokeVirtualQuick+680)
  #10  pc 00000000004fd694  /system/lib64/libart.so (ExecuteMterpImpl+29972)
  #11  pc 000000000025d59c  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
  #12  pc 0000000000263c9c  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
  #13  pc 000000000027c800  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
  #14  pc 00000000004f0d08  /system/lib64/libart.so (MterpInvokeStatic+468)
  #15  pc 00000000004f9a94  /system/lib64/libart.so (ExecuteMterpImpl+14612)
  #16  pc 000000000025d59c  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
  #17  pc 0000000000263c9c  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
  #18  pc 000000000027c800  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
  #19  pc 00000000004f0a50  /system/lib64/libart.so (MterpInvokeDirect+504)
  #20  pc 00000000004f9a14  /system/lib64/libart.so (ExecuteMterpImpl+14484)
  #21  pc 000000000025d59c  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
  #22  pc 0000000000263c9c  /system/lib64/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+212)
  #23  pc 000000000027c800  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+640)
  #24  pc 00000000004f2908  /system/lib64/libart.so (MterpInvokeVirtualQuick+680)
  #25  pc 00000000004fd694  /system/lib64/libart.so (ExecuteMterpImpl+29972)
  #26  pc 000000000025d59c  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+444)
  #27  pc 00000000004e3664  /system/lib64/libart.so (artQuickToInterpreterBridge+1468)
  #28  pc 000000000051141c  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
  #29  pc 00000000001fcc0c  /system/framework/arm64/boot.oat (java.lang.Thread.run+76)
  #30  pc 0000000000507f84  /system/lib64/libart.so (art_quick_invoke_stub+580)
  #31  pc 00000000000d84f4  /system/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+200)
  #32  pc 000000000043081c  /system/lib64/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+104)
  #33  pc 00000000004319a8  /system/lib64/libart.so (_ZN3art35InvokeVirtualOrInterfaceWithJValuesERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDP6jvalue+432)
  #34  pc 00000000004579ec  /system/lib64/libart.so (_ZN3art6Thread14CreateCallbackEPv+1140)
  #35  pc 0000000000067ce8  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
  #36  pc 000000000001f324  /system/lib64/libc.so (__start_thread+68)

@dturner
Copy link
Collaborator

dturner commented Sep 6, 2018

Please could you provide the make, model and O/S version of the device and also confirm that you're using the latest version of Oboe.

@dturner dturner reopened this Sep 6, 2018
@dturner
Copy link
Collaborator

dturner commented Sep 6, 2018

It looks like the bug is associated with MediaCodec which isn't anything to do with AAudio or Oboe

@dturner dturner closed this as completed Sep 6, 2018
@zipswich
Copy link

zipswich commented Sep 6, 2018

@dturner No, the app is not using AAudio or Oboe directly. I just thought it might be related. Could you tell me how you told it is related to MediaCodec. The app is primarily for video streaming.

Here are some examples of the devices sending the crash report:
Samsung Galaxy S7 (herolte), Android 8.0
Huawei P10 Plus (HWVKY), Android 8.0
Samsung Galaxy S8 (dreamlte), Android 8.0
Samsung Galaxy S7 (herolte), Android 8.0
Samsung Galaxy Note8 (greatlte), Android 8.0
Samsung Galaxy S7 (heroqltevzw), Android 8.0
Huawei Mate 9 (HWMHA), Android 8.0
Samsung Galaxy S9+ (star2lte), Android 8.0
HTC U11 (htc_ocndugl), Android 8.0

@zipswich
Copy link

zipswich commented Sep 6, 2018

@dturner OK. I figured you told by:
#02 pc 00000000000331b0 /system/lib64/libmedia_jni.so (_ZL30android_media_MediaCodec_resetP7_JNIEnvP8_jobject+80)

@philburk
Copy link
Collaborator

philburk commented Sep 7, 2018

This bug involves reference counting, which could be triggered by a change in Java code. If your Java code changed, and this suddenly started happening, then review the Java changes. If it does not look like a bug in your app then it might be a bug in Android related to MediaCodec and libstagefright.

#00 pc 000000000000d704 /system/lib64/libutils.so (_ZNK7android7RefBase9decStrongEPKv+28)
#1 pc 00000000001555e4 /system/lib64/libstagefright.so (_ZN7android10MediaCodec5resetEv+76)

Feel free to file a bug at:
https://source.android.com/setup/contribute/report-bugs

@zipswich
Copy link

zipswich commented Sep 7, 2018

@philburk Thank you for the tip. I believe that I have found the culprit as indicated in the stack trace: MediaCodec.Reset(). I updated the app after excluding Android 8.0 device in executing MediaCodec.Reset(). I have not seen the crash so far.
It had a surge of the crash because of the increase of the frequency of running MediaCodec.Reset() in the previous update. I will urge users of Android 8.0 devices to upgrade the OS to Android 8.1 if possible.

@akinesia
Copy link

akinesia commented Jan 7, 2019

I am trying to use oboe on my android app. And I have something to ask.

I am using compileSdkVersion 26. And if I import oboe on my app, I couldn't build this.
However if I do this on 27 version, it is okay.
As you know, it is hard to change compileSdkVersion.

So..!
There is no way to use on 26 version?
Or do I have to upgrade this version?

@dturner
Copy link
Collaborator

dturner commented Jan 7, 2019

I see you've opened a new issue for this question - which is what I was going to recommend :)

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

No branches or pull requests

8 participants