Skip to content

Conversation

@mnmaita
Copy link
Member

@mnmaita mnmaita commented Jul 29, 2025

Objective

Solution

  • Updated both cpal and rodio to their latest versions.
  • Updated code to address rodio's breaking changes.
  • Reworked audio related feature flags so symphonia becomes the default audio backend except for .ogg files, where we will still default to lewton.
  • Replaced aarch64-apple-ios-sim target with arm64-apple-ios-simulator.

Testing

  • Tested audio related examples.

@mnmaita
Copy link
Member Author

mnmaita commented Jul 29, 2025

Outstanding items:

  • Fix tools/example-showcase/disable-audio.patch
  • Figure out why the soundtrack and spatial examples are not working.
  • Do we want to make symphonia the default?
  • Is it ok to have lewton as the default ogg backend due to issues with the symphonia implementation when using looped/buffered sources?
  • Is the target change for iOS simulator sensible here or should we postpone that?
  • Review feature flag names.
  • Add a migration guide.
  • Remove minimp3.
  • Bump cpal once it releases a new version with the Send + Sync fix and remove the patch in Cargo.toml.

@alice-i-cecile alice-i-cecile added A-Audio Sounds playback and modification C-Dependencies A change to the crates that Bevy depends on S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Jul 29, 2025
@alice-i-cecile alice-i-cecile added the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jul 29, 2025
@github-actions
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@nyfair
Copy link

nyfair commented Oct 16, 2025

Symphonia released 0.5.5 last week, and bevy_audio picks it up by default after cargo update. However, the combination of rodio 0.20 and symphonia 0.5.5 causes a panic when decoding MPEG-4 streams.

This bug can be verified by running this rodio example directly
https://github.com/RustAudio/rodio/blob/v0.20.1/examples/music_m4a.rs

I suggest either merging this PR or pinning the symphonia dependency to version 0.5.4 in Cargo.toml.

@mnmaita
Copy link
Member Author

mnmaita commented Oct 22, 2025

@nyfair this PR is quite broken so I wouldn't merge it yet. We could do the version pinning as a stopgap and leave a comment on said change to fix it later. I might have some time to update this PR in a couple of days so I'll try my best to finalize it soon. @alice-i-cecile in the meantime, would you be able to help me figuring out the 3rd, 4th and 5th items that I left in my comment?

@mnmaita mnmaita force-pushed the mnmaita/dependabot/cargo/cpal-0.16 branch from 7111175 to 51b8311 Compare October 22, 2025 12:57
@mnmaita mnmaita marked this pull request as ready for review October 22, 2025 13:47
/// which iterates over samples of type [`rodio::Sample`].
/// Must be a [`rodio::Source`] so that it can provide information on the audio it is iterating over.
type Decoder: rodio::Source + Send + Iterator<Item = Self::DecoderItem>;
type Decoder: rodio::Source + Send + Iterator<Item = rodio::Sample>;
Copy link
Member Author

Choose a reason for hiding this comment

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

rodio::Source has Iterator<Item = rodio::Sample> as a bound as far as I can see, should we drop this redundant bound or should we keep it?

@mnmaita
Copy link
Member Author

mnmaita commented Oct 22, 2025

There's an unreleased change in cpal that makes Source Send. This will fix the build issues in MacOS as far as I can tell. I'll try bothering some people here and there to push this forward... 😅

EDIT:
Confirmed that the latest changes in cpal fix the MacOS builds, but... this change broke the windows build as there seems to be a type that doesn't implement Sync and makes it not possible to derive Resource for AudioOutput (it seems to be struct HANDLE(pub *mut core::ffi::c_void) from the windows crate).

If someone has any suggestions on how to proceed from here please let me know. Related issue: RustAudio/cpal#1038

@mnmaita mnmaita force-pushed the mnmaita/dependabot/cargo/cpal-0.16 branch from b85a940 to 6248b2e Compare October 27, 2025 23:41
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

We shouldn't be exposing minimp3 at all, per #20183

@github-project-automation github-project-automation bot moved this to Needs Update in Audio Oct 29, 2025
@mnmaita mnmaita force-pushed the mnmaita/dependabot/cargo/cpal-0.16 branch from 6248b2e to 9ef8982 Compare October 29, 2025 19:14
@mnmaita
Copy link
Member Author

mnmaita commented Oct 29, 2025

We shouldn't be exposing minimp3 at all, per #20183

Rebased, removed the unwanted feature and fixed some wrongly set internal feature flags for the fallbacks. I've also cleaned up my own messages as there was too much noise in the PR. Later I will try pushing a temporary commit to see if I can fix the outstanding issues and we can finally test this, analyze what options we have and make a decision for this upgrade.

@github-actions
Copy link
Contributor

You added a new feature but didn't update the readme. Please run cargo run -p build-templated-pages -- update features to update it, and commit the file change.

@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Nov 23, 2025
@alice-i-cecile alice-i-cecile added S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 10, 2025
@alice-i-cecile
Copy link
Member

Can you please resolve merge conflicts and get CI passing?

@alice-i-cecile alice-i-cecile removed this from the 0.18 milestone Dec 10, 2025
@mnmaita
Copy link
Member Author

mnmaita commented Dec 10, 2025

Can you please resolve merge conflicts and get CI passing?

Hey @alice-i-cecile, I can fix the conflicts but I don't think I can fix the CI, we'd need a new version of cpal to be cut. From what I can see in the check-sources job, it's not desirable to patch cpal version with an arbitrary revision from their main branch (which contains the fix for Send+Sync issues in some of their types). How should we proceed here? I held off on writing the migration guide for this reason, but I could work on finishing that too if desirable.

@alice-i-cecile
Copy link
Member

Can you track down the cpal authors and pester them (politely and patiently!) for a release? You're correct that we can't ship this with a git dependency.

@mnmaita
Copy link
Member Author

mnmaita commented Dec 11, 2025

Can you track down the cpal authors and pester them (politely and patiently!) for a release? You're correct that we can't ship this with a git dependency.

Relevant: RustAudio/cpal#1065 😄

Please also check this question I had:

Is it ok to have lewton as the default ogg backend due to RustAudio/rodio#775 (comment) with the symphonia implementation when using looped/buffered sources?

It seems like a PR that fixed that "got too big" and was just closed, and I didn't see any other PRs pushed to fix that. So as a follow up question:

Do we want to make symphonia the default (for the rest of the audio formats)?

As far as I understand, symphonia is an opt-in feature right now.

Thanks @alice-i-cecile!

@mnmaita mnmaita force-pushed the mnmaita/dependabot/cargo/cpal-0.16 branch from e230b93 to 210a0bb Compare December 11, 2025 12:53
@mnmaita
Copy link
Member Author

mnmaita commented Dec 11, 2025

Rebased and added a migration guide. I just realized that this will probably become a bump to rodio 0.22 as cpal's next version will be breaking.

@mnmaita mnmaita force-pushed the mnmaita/dependabot/cargo/cpal-0.16 branch from 9c9e8fb to fa00c43 Compare December 11, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Audio Sounds playback and modification C-Dependencies A change to the crates that Bevy depends on M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Blocked This cannot move forward until something else changes

Projects

Status: Needs Update

Development

Successfully merging this pull request may close these issues.

3 participants