-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 Support #86
Comments
I'm working on this issue now, can I get it assigned to me to help head off accidental parallel implementations? |
absolutely! thanks for picking it up. this will be huge ❤️ |
haha just noticed @karroffel already beat me to it |
@PrototypeNM1 could you please share your progress and what's left to be done? I have some time on weekends that I could dedicate to adding Android support to Bevy. Last weekend I added Android support to cpal, which was one of the major blockers. There are still some issues on |
To my knowledge there are 4 main blockers for Android support.
I'm working on 4. @endragor since you started investigating cpal/oboe issues, I recommend figuring out why |
@PrototypeNM1 FYI over at #87 I put up #324 where currently uses I too have now run into the missing touch support... I might hack something in just so I can play with it, not exactly sure what the correct API is. |
Hey all! I was able to run Bevy 3d example on my Android phone. Proof and repo: Current issues are next:
This is the current status. Any feedback and advice are highly appreciated. |
Fantastic! This is a big step 😄
Yeah as we discussed elsewhere I think we'll want to solve this by adding pre-compiled shader support with the various permutations available. We'll want a system like that anyway to improve startup times in release builds. Alternatively we can try adding dynamic compilation support by (1) waiting for Naga or (2) somehow making shaderc compile on android
Yeah thats a bit annoying, but it seems like we can work around it by selecting formats according to the platform. Alternatively, it might be worth checking with the wgpu folks to see if its something they can fix on their end.
Hmm maybe we need to add them to some sort of asset manifest? I haven't worked with android for awhile, but i vaguely remember something like that. |
@enfipy Awesome! Referencing your changes for TextureFormat I got runtime shader generation working on Android. |
After about 10 hours of unsuccessful tries to make @PrototypeNM1 example with Status update:
Things need to be resolved:
This is all I remembered. |
Very nice progress! I just merged the asset system changes. I'm making a few more changes to AssetIo to re-add wasm compatibility. It should also make integrating the android AssetIo backend slightly easier (as I'm boxing AssetIo) |
I'd like to just say, I'm not working on this issue, but am wildly excited to see its progress. Huge thanks to everyone working on it and know that the community is ecstatic to see this moving forward!! |
I think this is a big enough issue / problem space that I don't think anyone needs to own it. |
Added support for runtime spirv generation using a rewrite of glsl-to-spirv. We're still waiting for a fix in cargo-apk's dependencies to land. The alternative of removing glob imports for bevy's workspaces is still a viable alternative if we wanted this working asap. |
Would like to bring attention to proper implementation of winit events Event::Suspended and Event::Resumed at https://github.com/bevyengine/bevy/blob/master/crates/bevy_winit/src/lib.rs#L170 so it can proper release and reload resources |
Would there be any interest in using cargo-mobile to help with building, generating Android Studio projects, running on device, etc? |
Medium-to-long term I might be interested in adopting higher level abstractions. Short term I'd rather keep it simple, encourage people to become familiar with the "native" mobile tooling, and maintain control over "official" templates. We will likely create an official A minor note on the current cargo-mobile bevy template: bevy has its own answer to |
Removing from the 0.8 milestone; even if we merge #4913 I don't think this should be closed for 0.8 until we have significantly more testing. |
Is there any update on that? What is the status of Android in 0.9? |
Although I haven't looked at Bevy recently we did finally get the One of the other notable thing upstreamed in Winit was that all backends now consistently deliver a Resume event which helps with writing portable code that runs on Android (where handling Resume is very important) and other window systems. I'm not sure atm how tricky it's going to be to rebase #4913 (or maybe something equivalent was done in the mean time) but something equivalent to that will be one of the main blockers still I expect. |
Works on some device but without audio, doesn't work on others at all.
Do you know if there has been work to replace it also in things like |
cpal has switched over to using E.g. for android-activity I created an example to test cpal here: https://github.com/rib/android-activity/tree/main/examples/agdk-cpal which works with |
here's the cpal PR that switched to ndk-context: RustAudio/cpal#641 for reference |
Also, our team was working on the toolkit for plugins and build cli for Android (iOS in the future): https://github.com/dodorare/crossbow. We succeeded in running different Google Play plugins on Android but Bevy was also blocked by stuff like audio, etc. @rib it would be awesome to take a look at how we can integrate with AGDK, we tried to design Here's an example with Macroquad (but will work with Bevy too): Honestly, I think if we all here put all this stuff together, we can make pretty fine Android support in Bevy v0.10, IMO. |
cool, I'd heard of crosssbow recently but hadn't had a chance to take a look so thanks for the pointer @enfipy Skimming that example I see it has a main entry point like #[macroquad::main("Macroquad UI")]
async fn main() -> anyhow::Result<()> {
} which makes me think that you're possibly defining your own glue layer between native and jvm code? Or does this maybe currently build on the ndk-glue macro perhaps? Winit (which Bevy usually builds on) is currently (for 0.28) implies needing to use I'd need to poke into crossbow more to understand how it defines its You should have some flexibility from the proc macro I guess but one notable thing about the entry point ABI for |
okey, I realize now that the example |
Got bevy_audio working if I tell cpal to enable oboe "shared-stdcxx" feature, meaning I am having an issue with "c++_static" linking. Still working on why, and not sure if its just me or not. |
In case it might give some insight/clue you could maybe poke at this minimal cpal example: https://github.com/rib/android-activity/tree/main/examples/agdk-cpal That example doesn't currently do anything special to choose the stdc++_shared vs static implementation and seemed to work. There's currently no standard convention amongst Rust Android crates for being able to configure whether to use the shared or static implementation which is a bit awkward, since it wouldn't really be desirable to have a mix and match amongst crates. It sounds kinda surprising that it works when enabling shared stdcxx. I would have thought you'd also have to make sure to copy the |
oh sorry, I lost track of which bug I was responding too and see I already linked that example quite recently in this thread so guess you've probably already seen it. |
It does, and your examples have been my starting point for everything in this PR. Used na-winit-wgpu quite a bit, and made sure I could get agdk-cpal working before anything else this morning. I do want to add AGDK bevy example (you put in so much work getting that working), plan to after I am happy with native activity with apk. |
|
@MarijnS95 does As a guess, that seem like it could explain a discrepancy between the |
@rib |
right, makes sense |
# 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
# 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
Android is reasonably well supported now, following #9937. #10158 will fix an important bug with audio playing while suspended, but in general, it should be functional. It needs more and better documentation still, and better multi-touch + haptic support, but the foundations are all there. If you run into further problems, please open a new issue! |
It should be possible to run Bevy Apps on Android
The text was updated successfully, but these errors were encountered: