Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android crashing with enabled bevy_audio #3648

Closed
Gordon-F opened this issue Jan 12, 2022 · 7 comments
Closed

Android crashing with enabled bevy_audio #3648

Gordon-F opened this issue Jan 12, 2022 · 7 comments
Labels
A-Audio Sounds playback and modification C-Bug An unexpected or incorrect behavior O-Android Specific to the Android mobile operating system

Comments

@Gordon-F
Copy link
Contributor

Bevy version

bevy#bc499591c2d090e17c95d2c59bc6e16ba60a023d

Operating system & version

Android 8

What you did

Enable bevy_audio on android.

2022-01-12 18:05:15.946 14333-14393/rust.android D/event crates\bevy_app\src\plugin_group.rs:117:  added plugin: bevy_audio::AudioPlugin
2022-01-12 18:05:15.946 14333-14392/rust.android I/RustStdoutStderr: thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\ndk-glue-0.6.0\src\lib.rs:59:39
@Gordon-F Gordon-F added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 12, 2022
@manokara
Copy link
Contributor

The panic comes from here:

https://github.com/rust-windowing/android-ndk-rs/blob/f4dc7265aaa3e51f355ff1cb298e18167685fc7f/ndk-glue/src/lib.rs#L58-L60

For some reason it can't get the activity for the app, it must be something on rodio or cpal causing it.

@manokara
Copy link
Contributor

manokara commented Jan 12, 2022

Ah, I think I see whats going on here. The activity handle is actually initialized in ndk_glue::init, which is usually called by using the ndk_glue::main macro. You need to add this above your main() function:

#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "full"))]

I wonder if there's a way to do that it bevy automatically?

@Gordon-F
Copy link
Contributor Author

I wonder if there's a way to do that it bevy automatically?

It's a part of bevy_main -

bevy::ndk_glue::init(

@manokara
Copy link
Contributor

Oh, right. Are you using it though? From reading the code in ndk_glue it should set the activity handle to Some, even if it's invalid somehow, because the panic would be somewhere else.

@mockersf mockersf added A-Audio Sounds playback and modification O-Android Specific to the Android mobile operating system and removed S-Needs-Triage This issue needs to be labelled labels Jan 12, 2022
@Gordon-F
Copy link
Contributor Author

Gordon-F commented Jan 12, 2022

Oh, right. Are you using it though?

Yep, this is init problem with bevy_audio and potentially with bevy_assets (it get a native_activity in Plugin build step too). But this should be a part of startup system, that running after native activity is available.

So, if you have a powerful device, maybe you didn't see this errors at all.

@b333z
Copy link

b333z commented Jan 14, 2022

Think this might be rust-mobile/ndk#211

@mockersf
Copy link
Member

winit is bringing in ndk 0.5, and rodio is using both ndk 0.3 and 0.6... so it's probably not possible to get audio working with bevy_audio...

@harudagondi harudagondi moved this to Open in Audio Nov 17, 2022
bors bot pushed a commit that referenced this issue Feb 6, 2023
# Objective

- Merge the examples on iOS and Android
- Make sure they both work from the same code

## Solution

- don't create window when not in an active state (from #6830)
- exit on suspend on Android (from #6830)
- automatically enable dependency feature of bevy_audio on android so that it works out of the box
- don't inverse y position of touch events
- reuse the same example for both Android and iOS

Fixes #4616
Fixes #4103
Fixes #3648
Fixes #3458
Fixes #3249
Fixes #86
bors bot pushed a commit that referenced this issue Feb 6, 2023
# Objective

- Merge the examples on iOS and Android
- Make sure they both work from the same code

## Solution

- don't create window when not in an active state (from #6830)
- exit on suspend on Android (from #6830)
- automatically enable dependency feature of bevy_audio on android so that it works out of the box
- don't inverse y position of touch events
- reuse the same example for both Android and iOS

Fixes #4616
Fixes #4103
Fixes #3648
Fixes #3458
Fixes #3249
Fixes #86
@bors bors bot closed this as completed in 7e0a9bf Feb 6, 2023
@github-project-automation github-project-automation bot moved this from Open to Done in Audio Feb 6, 2023
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-Bug An unexpected or incorrect behavior O-Android Specific to the Android mobile operating system
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants