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

The lifetime of Events seems to have changed in 0.12 #11026

Closed
MJohnson459 opened this issue Dec 19, 2023 · 3 comments
Closed

The lifetime of Events seems to have changed in 0.12 #11026

MJohnson459 opened this issue Dec 19, 2023 · 3 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior

Comments

@MJohnson459
Copy link
Contributor

MJohnson459 commented Dec 19, 2023

Bevy version

0.12.1

What you did

I just upgraded to 0.12.1 and I noticed that this code no longer works for panning the camera with a mouse drag:

fn pan_camera(
    mut ev_motion: EventReader<MouseMotion>,
    input_mouse: Res<Input<MouseButton>>,
) {
...
    if input_mouse.pressed(pan_button) {
        for ev in ev_motion.read() {
            pan += ev.delta;
        }
    }

Previously the ev_motion reader would only contain events from the last frame. Now it seems that there is a backlog of events stored and so clicking the mouse results in a large pan happening.

I believe previously bevy used to only store the delta for two frames but now it is unbounded? I didn't see anything in the release or migration notes about this but I am guessing it might be related to #7728 (@james7132 )?

The workaround for now is to just clean the events every frame. This will fix the symptoms for one system but doesn't fix the underlying change which has implications for memory usage etc.

    if input_mouse.pressed(pan_button) {
        for ev in ev_motion.read() {
            pan += ev.delta;
        }
    } else {
        ev_motion.clear();
    }
@MJohnson459 MJohnson459 added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 19, 2023
@mockersf
Copy link
Member

seems related to #10877

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Dec 21, 2023
@alice-i-cecile
Copy link
Member

Closing as duplicate.

@alice-i-cecile alice-i-cecile closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2023
@james7132
Copy link
Member

I believe previously bevy used to only store the delta for two frames but now it is unbounded? I didn't see anything in the release or migration notes about this but I am guessing it might be related to #7728 (@james7132 )?

#7728 will only stop running the update if both internal stores are empty. I don't think this is the cause of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

4 participants