Android issue collection
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- android, rust
- Domain
- game-dev, mobile-dev
Research direction
The report groups several Android problems across winit, GameActivity touch handling, Bevy threading, rendering, background CPU use, timing, picking, audio, and lifecycle events. Start by choosing one symptom and tracing its linked issue or Bevy entry point; the report gives device and Android version details but no specific Bevy files or tests. Done would require a separately scoped issue with a reproducible case and a fix validated on Android.
Written by the indexing model from the issue text.
Description
I discovered these issues on 2 phones with bevy v0.19.* and I think all of them persist in
v0.20.*.
Devices:
- Samsung Galaxy A33 (Android 16 | Display 60Hz/90Hz)
- Samsung Galaxy S20 (Android 13 | Display 60Hz/120Hz)
Solving or patching the issues below I could reach CPU and GPU usages that are somewhat in range of
the app in Godot but I used GPUWatch from Samsung and I don't know how accurate this is.
ndk: 29.0.14206865
minSdk: 29
targetSdk: 37
GPU backend: Vulkan
winit
Android RecreationAttempt failure: https://github.com/rust-windowing/winit/issues/3325
There is a patch for this issue that I use: https://github.com/rib/winit/commit/c28e425214e82bdb86dcdf89c9488554a18e24b2
Crash when there are more than 8 touches (GameActivity)
- https://github.com/bevyengine/bevy/issues/16798
- https://github.com/rust-mobile/android-activity/issues/175
- Reopen: https://github.com/rust-mobile/android-activity/issues/253
Workaround patch: https://github.com/Johannes0021/android-activity/commit/d31a501a252a2dbb359bd7b4673128017aab7746
bevy
Allow AndroidApp handle activity recreation: https://github.com/bevyengine/bevy/pull/26015
After this fix the LogPlugin can be disabled in subsequent recreations in DefaultPlugins to
prevent error logging.
static FIRST_BUILD: AtomicBool = AtomicBool::new(true);
if !FIRST_BUILD.swap(false, Ordering::Relaxed) {
plugins = plugins.disable::<LogPlugin>();
}
multi_threaded feature:
Setting device fps to 90(A33) or 120(S20) even for simple apps the fps are unstable which ist not a nice experience.
Single-threaded it runs smooth like butter. I know that there is overhead using multiple threads and
that mobile phones are low power devices that aggressively save power, but I can't believe that my
app runs single-threaded no sweat and multi-threaded it's lagging.
I noticed that MSAA uses a lot of GPU power which makes sense but I was very confused that it is
enabled by default and I did not know why my GPU usage was so high.
Rendering on native resolution, a simple app can't hit 60fps (GPU maxed out).
The app is killed in the background because of CPU usage (~after 1h in bg). I had to disable the audio feature in
bevy, because the audio thread was still using too much CPU in the background.
Solved in a workaround replacement plugin for bevy_audio: https://github.com/Johannes0021/bevy_mod_audio
After that, I had to fix the remaining CPU usage with:
app.insert_resource(WinitSettings::game())
.add_systems(Update, update_winit_settings_on_lifecycle);
// ...
fn update_winit_settings_on_lifecycle(
mut winit_settings: ResMut<WinitSettings>,
mut lifecycle_messages: MessageReader<AppLifecycle>,
) {
for msg in lifecycle_messages.read() {
match msg {
AppLifecycle::Suspended => {
*winit_settings = WinitSettings {
unfocused_mode: bevy::winit::UpdateMode::Reactive {
wait: Duration::from_secs(1),
react_to_device_events: false,
react_to_user_events: false,
react_to_window_events: false,
},
..WinitSettings::game()
};
}
AppLifecycle::Running => *winit_settings = WinitSettings::game(),
AppLifecycle::Idle | AppLifecycle::WillSuspend | AppLifecycle::WillResume => (),
}
}
}
I also noticed that the delta time is very unstable and causes animations to stutter. If I force the
delta time to 60 fps, the animations are smooth. I think there may be a problem with the delta time
calculation. I wrote a small plugin that tries to work around this problem by smoothing the delta
time. It's a bit rough: https://github.com/Johannes0021/bevy_mod_time_smoothing.git
This greatly improves GPU performance:
DefaultPlugins.set(RenderPlugin {
render_creation: RenderCreation::Automatic(Box::new(WgpuSettings {
priority: WgpuSettingsPriority::WebGL2,
limits: WgpuLimits::downlevel_webgl2_defaults()
.using_resolution(WgpuLimits::default()),
..default()
})),
..default()
})
I think I also had issues with bevy_picking with touch input being cancelled and reported by winit but without receiving a release or drag out event.
I wrote a rough workaround by tracking the first finger pressed state and sprite picking events.
It would also be handy if bevy would expose a PointerOrder resource or else that assigns the finger an index somewhat like: https://github.com/Johannes0021/bevy_mod_input/blob/main/src/pointer_order.rs
In the past i had an issue with rodio that is still present: https://github.com/RustAudio/rodio/issues/836
Solved in a workaround replacement plugin for bevy_audio: https://github.com/Johannes0021/bevy_mod_audio
AppLifecycle: https://docs.rs/bevy/latest/bevy/window/enum.AppLifecycle.html
I think WillSuspend, WillResume, are never sent or received.
WinitSettings: https://docs.rs/bevy/latest/bevy/winit/struct.WinitSettings.html
I think the fn https://docs.rs/bevy/latest/bevy/winit/struct.WinitSettings.html#method.mobile
is misleading. It tries to pin the fps to 60. This might be okay for static apps but on Android
which forces VSync, this causes single frame drops on 60 fps and is unplayable on for example 90fps.
- Dominant language
- Rust
- Stars
- 49.8k
- Forks
- 5.1k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 136
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bevyengine/bevy
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bevyengine/bevy#26642 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bevyengine/bevy#26641 ·
Maintainers usually reply within 2 days
-
A-Animation AI-Assisted C-Bug D-Trivial S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy#26637 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy#26635 ·
Maintainers usually reply within 2 days
-
Feathers checkbox outline should have flex_shrink: 0Possibly taken @Tatsuya0330 claimed this today. OpenC-Bug S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bevyengine/bevy#26630 ·
Maintainers usually reply within 2 days
Similar issues
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
bug triaged tui ux wontfix
Difficulty 2/5 Half a day Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day