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

Current main branch introduces stutter #14

Closed
CleanCut opened this issue Jan 16, 2022 · 9 comments
Closed

Current main branch introduces stutter #14

CleanCut opened this issue Jan 16, 2022 · 9 comments

Comments

@CleanCut
Copy link
Contributor

CleanCut commented Jan 16, 2022

I'm experiencing stutter on my best hardware with the current main branch at 7859f9b. I was able to resolve the stutter by removing DebugLinesPlugin.

diff --git a/src/game.rs b/src/game.rs
index a910174..2cf7c20 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -224,7 +224,7 @@ pub fn update_window_dimensions(windows: Res<Windows>, mut engine_state: ResMut<
 #[doc(hidden)]
 pub fn draw_sprite_colliders(
     engine_state: Res<EngineState>,
-    mut lines: ResMut<DebugLines>,
+    //mut lines: ResMut<DebugLines>,
     sprite_query: Query<&Sprite>,
 ) {
     if !engine_state.debug_sprite_colliders {
@@ -239,7 +239,7 @@ pub fn draw_sprite_colliders(
         let mut curr = 0;
         let mut next = 1;
         while curr < length {
-            lines.line(points[curr].extend(0.0), points[next].extend(0.0), 0.0);
+            //lines.line(points[curr].extend(0.0), points[next].extend(0.0), 0.0);
             curr += 1;
             next = (next + 1) % length;
         }
@@ -306,7 +306,7 @@ impl<S: Send + Sync + 'static> Game<S> {
             .add_system(exit_on_esc_system)
             // External Plugins
             .add_plugin(AudioPlugin) // kira_bevy_audio
-            .add_plugin(DebugLinesPlugin::always_in_front()) // bevy_prototype_debug_lines, for displaying sprite colliders
+            //.add_plugin(DebugLinesPlugin::always_in_front()) // bevy_prototype_debug_lines, for displaying sprite colliders
             // Rusty Engine Plugins
             .add_plugin(AudioManagerPlugin)
             .add_plugin(KeyboardPlugin)

The weirdest part was that the stutter is in an example program which isn't using debug lines (it is literally not calling lines.line(...) from the diff above) because I've got code at the top of the function returning early and skipping the debug line drawing entirely (see code below). So I've got stutter...and the plugin ostensibly isn't even doing anything!

   if !engine_state.debug_sprite_colliders {
        return;
    }

The stutter happens randomly with an interval that feels like it's random between about 0.25s - 5s. The stutter seems to last at least a couple frames and sometimes more like a dozen.

Here's the specs for my workstation with the problem:

image

# I tried Rust 1.57 -- same thing
$ rustc --version
rustc 1.58.0 (02072b482 2022-01-11)

I do NOT see the problem on my laptop, which is really weird:

mbpro-screenshot

Steps to Reproduce

$ git clone https://github.com/CleanCut/rusty_engine.git
$ cd rusty_engine
$ git checkout choppy
$ cargo run --release --example road_race

# Use the arrow keys to avoid obstacles - observe periodic stutters on some hardware

$ git checkout smooth
$ cargo run --release --example road_race

# no stutters now - neither of these will draw any debug lines (`engine_state.debug_sprite_colliders`
  is `false` in this example)
@Toqozz
Copy link
Owner

Toqozz commented Jan 17, 2022

Hey! Thanks for the issue.

This is a weird issue, but I'm not too surprised by it. The upgrade to bevy 0.6 introduced huge changes (#10) and there are definitely still some kinks to work out. I'm really busy lately but am going to be working through them.

Thanks for the detailed report!

@CleanCut
Copy link
Contributor Author

CleanCut commented Jan 17, 2022

More info:

  • I tried ripping out bevy_prototype_debug_lines and using bevy_prototype_lyon instead...and the exact same stutter behavior starts up again. AFAIK the thing in common between these two plugins is that they use custom shaders. Given the massive rendering overhaul in Bevy 0.6, this may be more of a Bevy issue than anything. 🤔 It would still be great if we could find that issue! I tagged this commit choppy-lyon
  • I tried patched Cargo.toml to use the current Bevy main branch (currently on commit 3fcdc5a), and the problem persists...so nothing merged into main since the 0.6.0 release has fixed it, yet. I tried this with both plugins:

So, I've got 5 tags/branches you can check out if you like. They're all exhibit the stutter for me except the first:

  • The smooth tag uses neither plugin
  • The choppy tag is bevy_prototype_debug_lines with Bevy 0.6.0
  • The bevy-main-debug-lines branch is bevy_prototype_debug_lines with Bevy main
  • The choppy-lyon tag is bevy_prototype_lyon with Bevy 0.6.0
  • The bevy-main-lyon branch is bevy_prototype_lyon with Bevy main

@CleanCut
Copy link
Contributor Author

I filed an issue on bevyengine/bevy as well, since it could very well be an upstream problem.

@CleanCut
Copy link
Contributor Author

The issue is most certainly upstream Bevy 0.6. Feel free to close this, or leave it open until upstream is resolved. Whatever you prefer.

@Toqozz
Copy link
Owner

Toqozz commented Jan 22, 2022

Leaving it open :)

@adsick
Copy link

adsick commented Feb 17, 2022

Hi, for me it seems like stutters are present from the very beginning (in my case from versions 0.3-0.4). I've observed noticeable drops with 2-5 seconds interval since those version and thought "well, some day this will be fixed"

hardware: amd ryzen 5 3500U, Vega 8 graphics, Fedora Linux 35. (also I remember it on Windows with bevy 0.5)

@Toqozz
Copy link
Owner

Toqozz commented Feb 22, 2022

Hi, for me it seems like stutters are present from the very beginning (in my case from versions 0.3-0.4). I've observed noticeable drops with 2-5 seconds interval since those version and thought "well, some day this will be fixed"

hardware: amd ryzen 5 3500U, Vega 8 graphics, Fedora Linux 35. (also I remember it on Windows with bevy 0.5)

I've never noticed any stutter on my end. The way the plugin works (especially prior to 0.6.0) is super simple, so I don't see many places that could cause a stutter. Maybe a memory bandwidth issue due to the integrated graphics? But it seems unlikely.

We split lines between multiple meshes in 0.6.0, which might help with that. Would you mind trying it out?

@adsick
Copy link

adsick commented Feb 22, 2022

We split lines between multiple meshes in 0.6.0, which might help with that.

what do you mean?

edit: oh, wait, I actually meant that Bevy stutters in general, not only with debug lines plugin. I've came from bevyengine/bevy#3709 that issue on the Bevy repo.

@CleanCut
Copy link
Contributor Author

CleanCut commented Aug 2, 2022

Resolved in Bevy 0.8

@CleanCut CleanCut closed this as completed Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants