[Android] SIGABRT in libaaudio prepareBuffersForStop → IsochronousClockModel::convertPositionToTime when Oboe's error thread stops the exclusive output stream
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 20/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- android, cpp, react-native
調査の方向性
Start with the latency-hint to sharing/performance-mode mapping that #1445 changed, and the AndroidAudioPlayer error callbacks, to see exactly what latencyHint: 'interactive' opens today. The stack is in Oboe's AudioStreamAAudio.cpp (oboe_aaudio_error_thread_proc_common at line 75) and libaaudio's prepareBuffersForStop, which is only reached for a free-running MMAP endpoint. Done means either an exclusive stream no longer reaches that stop path or every error code is handled in onError with the stream torn down by the library; verifying it needs an affected Samsung device, since the report has no reproducer.
索引モデルが issue の本文から書いたものです。
説明
Description
On Android, a few Samsung mid-range phones crash with SIGABRT inside libaaudio when Oboe's error thread stops the output stream, usually right after the app returns from the background. The abort happens in AudioStreamInternalPlay::prepareBuffersForStop, which only runs for a free-running (MMAP, exclusive) endpoint. AudioPlayer opens its output with SharingMode::Exclusive + PerformanceMode::LowLatency, and on 1.0.1 and main that is still what the default latencyHint: 'interactive' opens (#1445 made only balanced / playback shared).
Expected: an error on the output stream is recovered or reported, not a native crash.
Crashing thread (Oboe 1.9.3, from the AAR the library depends on):
oboe_aaudio_error_thread_proc_shared AudioStreamAAudio.cpp:97
oboe_aaudio_error_thread_proc_common AudioStreamAAudio.cpp:75
oboe::AudioStreamAAudio::requestStop AudioStreamAAudio.cpp:617
oboe::AudioStreamAAudio::requestStop_l AudioStreamAAudio.cpp:632
libaaudio_internal.so aaudio::AudioStream::systemStopInternal
libaaudio_internal.so aaudio::AudioStreamInternal::requestStop_l
libaaudio_internal.so aaudio::AudioStreamInternalPlay::prepareBuffersForStop
libaaudio_internal.so aaudio::IsochronousClockModel::convertPositionToTime
libaaudio_internal.so <unsymbolicated>
libc.so abort
AudioStreamAAudio.cpp:75 in Oboe 1.9.3 is the default handling in oboe_aaudio_error_thread_proc_common: onError() returned false, so Oboe runs requestStop() → onErrorBeforeClose() → close() → onErrorAfterClose(). AndroidAudioPlayer (0.13.5, 1.0.1 and main) overrides only onErrorAfterClose, so every output-stream error goes through that default requestStop().
Why it aborts (our reading of AOSP, not verified on a device):
AudioStreamInternalPlay::prepareBuffersForStop()returns straight away unlessmAudioEndpoint->isFreeRunning(), i.e. unless the stream is MMAP exclusive with the DSP reading the buffer directly. A shared stream skips the whole block.- For an exclusive stream it computes
mClockModel.convertPositionToTime(getFramesWritten() + framesPerBurst).IsochronousClockModel::convertDeltaPositionToTime()is(AAUDIO_NANOS_PER_SECOND * framesDelta) / mSampleRate, whereframesDeltais the distance from the clock model's last marker position. - libaaudio is built with
sanitize: { integer_overflow: true }(media/libaaudio/src/Android.bp), so an overflow in that arithmetic callsabort()instead of wrapping. The frame betweenconvertPositionToTimeandabortis unsymbolicated, which fits the sanitizer's handler. - Suspected trigger: after the app is backgrounded and resumed, the MMAP stream gets an error (the exclusive endpoint is taken away or invalidated), and when Oboe stops it, the clock model still holds a stale marker, so
framesDeltais huge and the multiplication overflows.
Something we tried. In our app we override onError for ErrorDisconnected (stop + close the stream ourselves under the context's lock, return true). The abort still arrives through Oboe's default path in builds that include that change. So either the error code there is not ErrorDisconnected (Oboe doesn't put it in the crash), or onError bailed out early. Either way, a narrower onError does not keep the default requestStop() from running.
Possible fixes
- Open the output stream
SharingMode::Sharedand keepPerformanceMode::LowLatency. On most devices AAudio still gives a low-latency MMAP shared path through the AAudio service mixer, andprepareBuffersForStopis skipped for it. This would extend #1445 tointeractive, or make exclusive opt-in. - Handle every error code in
onError()(returntrue) rather than only reacting inonErrorAfterClose. I'm not sure this is enough on its own. Oboe's contract is that the app then stops and closes the stream itself, and libaaudio'sAudioStreamInternal::release_l()callsrequestStop_l()on an active or disconnected stream anyway, so an exclusive stream would still reachprepareBuffersForStop. It would at least move the stop under the library's own lock and timing. Option 1 is the one that removes the path.
Steps to reproduce
No minimal reproducer yet: we see this only in production, on Samsung phones, after the app resumes from background. I don't have an affected device, and the Android emulator's audio HAL has no MMAP exclusive path, so a repro I could run there would not exercise prepareBuffersForStop. I'm reporting the stack and the code path rather than claim a repro I haven't run.
What the app does, as far as audio-api is concerned:
- Create an
AudioContext({ sampleRate })with the defaultlatencyHintand play short UI sounds (AudioBufferSourceNode). suspend()the context after a short idle period;resume()it on the next play.- Background the app and bring it back; the next output-stream error after resume aborts in the stack above.
Frequency: ~24 crashes from 7 users in the last month, all fatal.
Snack or a link to a repository
None. No minimal reproducer yet (see above). This report was prepared with the help of an AI assistant. The template asks AI-assisted reports to include a verified MRE, and we could not build one that actually reproduces without the affected hardware, so we're saying so rather than attaching an unverified one.
React Native Audio API version
0.13.5 (Oboe 1.9.3). The relevant code is unchanged on 1.0.1 and main for the default interactive hint.
React Native version
0.88.0
Platforms
Android
JavaScript runtime
Hermes
Workflow
Expo Dev Client (Expo prebuild; crashes are from EAS release builds)
Architecture
Fabric (New Architecture)
Build type
Release app & production bundle
Device
Real device
Device model
Samsung Galaxy A36 5G (SM-A366B, SM-A366E) and SM-A276B, Android 15 (21 events) and Android 16 (3 events)
Acknowledgements
Yes. I searched this repo (open and closed) for prepareBuffersForStop, convertPositionToTime, IsochronousClockModel, requestStop, SIGABRT, abort, MMAP, onErrorAfterClose and error callback. Nearest but different: #1088 and #1328 (error-callback recovery, not this abort), #1231 / #1232 / #1445 (sharing and performance mode for latency hints). In google/oboe I found nothing for prepareBuffersForStop, convertPositionToTime, requestStop_l or systemStopInternal. The closest there is google/oboe#1489, also an abort inside libaaudio's timestamp math, but on the legacy (AudioStreamLegacy::getBestTimestamp) path, not MMAP stop.
- 主要言語
- C++
- スター
- 864
- フォーク
- 103
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 77
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
software-mansion/react-native-audio-api のほかの issue
-
AudioContext destructor dereferences a null audioPlayer_ when construction fails before initialize()対応中かも @maciejmakowski2003 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
software-mansion/react-native-audio-api#1504 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bug ios
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
software-mansion/react-native-audio-api#1238 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Closed AudioContext / OfflineAudioContext is never released: stateChange listener is never unregistered対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 4/5 1〜2日 初心者へのやさしさ 35/100
software-mansion/react-native-audio-api#1497 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
DelayNode: signals connected to delayTime are ignored, and delayTime = 0 delays by maxDelayTime対応中かも @mdydek が 6 日前に担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
software-mansion/react-native-audio-api#1491 ·
メンテナーはふだん 1 日以内に返信
-
[Android] AudioRecorder reopens a disconnected input stream with no limit: a re-route on every open (Samsung, concurrent capture) loops hundreds of times a minute and records nothing対応中かも @maciejmakowski2003 が 18 日前に担当しました。 オープンandroid bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
software-mansion/react-native-audio-api#1416 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
software-mansion/react-native-audio-api の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
component: tabs platform: macOS
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
zen-browser/desktop#16860 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
metasequoiaime/msime#12003 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
windirstat/windirstat#776 ·
メンテナーはふだん 2 日以内に返信