[Android] SIGABRT in libaaudio prepareBuffersForStop → IsochronousClockModel::convertPositionToTime when Oboe's error thread stops the exclusive output stream
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 20/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- android, cpp, react-native
- Ambito
- audio-video-rtc, mobile-dev
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C++
- Stelle
- 864
- Fork
- 103
- Merge medio
- 1g 16h
- PR unite (30g)
- 77
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di software-mansion/react-native-audio-api
-
AudioContext destructor dereferences a null audioPlayer_ when construction fails before initialize()Forse già presa @maciejmakowski2003 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
software-mansion/react-native-audio-api#1504 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
bug ios
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
software-mansion/react-native-audio-api#1238 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Closed AudioContext / OfflineAudioContext is never released: stateChange listener is never unregisteredForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
software-mansion/react-native-audio-api#1497 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
DelayNode: signals connected to delayTime are ignored, and delayTime = 0 delays by maxDelayTimeForse già presa @mdydek l’ha presa 6 giorni fa. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
software-mansion/react-native-audio-api#1491 ·
I maintainer di solito rispondono entro 1 giorno
-
[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 nothingForse già presa @maciejmakowski2003 l’ha presa 18 giorni fa. Apertaandroid bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
software-mansion/react-native-audio-api#1416 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di software-mansion/react-native-audio-api
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
component: tabs platform: macOS
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
zen-browser/desktop#16860 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
metasequoiaime/msime#12003 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
windirstat/windirstat#776 ·
I maintainer di solito rispondono entro 2 giorni