Skip to content

fix: AudioContext::resume reanimates the failed Oboe stream due to the change in AudioPlayer::resume - #1252

Draft
basiav wants to merge 4 commits into
mainfrom
fix/oboe-stream-dies
Draft

fix: AudioContext::resume reanimates the failed Oboe stream due to the change in AudioPlayer::resume #1252
basiav wants to merge 4 commits into
mainfrom
fix/oboe-stream-dies

Conversation

@basiav

@basiav basiav commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #1230

⚠️ Breaking changes ⚠️

Introduced changes

  1. Current Oboe stream death recovery paths:
  • only oboe::Result::ErrorDisconnected is being handled in AudioPlayer::onErrorAfterClose, the author in the issue mentions other types of errors not being handled in their real life situations, e.g. ErrorNoService, ErrorTimeout -> they are being skipped by the "if" statement and the stream is not being rebuilt.
  • In the PR, in AudioPlayer:onErrorAfterClose the condition error != oboe::Result::ErrorDisconnected was deleted to enable handling more errors by a try to rebuild the stream.
  1. After the Oboe stream death and unrebuilt stream, when AudioContext::resume was called, audioPlayer_->resume was failing.
  • added stream rebuild to AudioPlayer:resume.

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage
  • Added support for web
  • Updated old arch android spec file

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

WPT non-regression comparison

ERROR — the run produced no report.

Workflow run · this comment is updated on every push.

@closetcaiman closetcaiman changed the title Fix on Android: AudioContext::resume reanimates the failed Oboe stream due to the change in AudioPlayer::resume fix: AudioContext::resume reanimates the failed Oboe stream due to the change in AudioPlayer::resume Aug 25, 2026
@closetcaiman closetcaiman added fix Code changes specifically addressing and resolving a bug android Native Android implementation, C++/Java/Kotlin bindings, or Android-specific issues labels Aug 25, 2026
Comment on lines +190 to +195
const bool wasRunning = isRunning_.load(std::memory_order_acquire);

if (!rebuildStream()) {
return;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If rebuildStream fails, isRunning flag may stay true.

Comment on lines -161 to +171
if (error != oboe::Result::ErrorDisconnected || driverMutex_ == nullptr) {
// error != oboe::Result::ErrorDisconnected condition is deleted to handle more cases of errors
if (driverMutex_ == nullptr) {

@closetcaiman closetcaiman Aug 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this guard seems really dangerous to me. Consider this: should all types of errors result in stream rebuild retry? What about some non-recoverable errors, won't that create an infinite loop? Maybe it is better to choose action in response to specific errors - oboe::Result is not that big of an enum.

Comment on lines 90 to 105
if (mStream_ != nullptr) {
auto result = mStream_->requestStart() == oboe::Result::OK;
isRunning_.store(result, std::memory_order_release);
return result;
if (mStream_->requestStart() == oboe::Result::OK) {
isRunning_.store(true, std::memory_order_release);
return true;
}
}

if (rebuildStream()) {
if (mStream_ != nullptr && mStream_->requestStart() == oboe::Result::OK) {
isRunning_.store(true, std::memory_order_release);
return true;
}
}

isRunning_.store(false, std::memory_order_release);
return false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of resume being responsible for rebuilding the stream. Seems like it tries to act both as resume and start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android Native Android implementation, C++/Java/Kotlin bindings, or Android-specific issues fix Code changes specifically addressing and resolving a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] AudioContext.resume() fails permanently after the Oboe stream dies with a non-Disconnected error (audio silent for the rest of the session)

2 participants