[Android] SIGABRT in libaaudio prepareBuffersForStop → IsochronousClockModel::convertPositionToTime when Oboe's error thread stops the exclusive output stream
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- android, cpp, react-native
- Lĩnh vực
- audio-video-rtc, mobile-dev
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 864
- Fork
- 103
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 77
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của software-mansion/react-native-audio-api
-
AudioContext destructor dereferences a null audioPlayer_ when construction fails before initialize()Có thể đã có người làm @maciejmakowski2003 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
software-mansion/react-native-audio-api#1504 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ios
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
software-mansion/react-native-audio-api#1238 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Closed AudioContext / OfflineAudioContext is never released: stateChange listener is never unregisteredCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 35/100
software-mansion/react-native-audio-api#1497 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DelayNode: signals connected to delayTime are ignored, and delayTime = 0 delays by maxDelayTimeCó thể đã có người làm @mdydek đã nhận 6 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
software-mansion/react-native-audio-api#1491 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[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 nothingCó thể đã có người làm @maciejmakowski2003 đã nhận 18 ngày trước. Đang mởandroid bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
software-mansion/react-native-audio-api#1416 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của software-mansion/react-native-audio-api
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
component: tabs platform: macOS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
zen-browser/desktop#16860 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
metasequoiaime/msime#12003 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
windirstat/windirstat#776 ·
Maintainer thường phản hồi trong vòng 2 ngày