Closed CAD97 closed 3 years ago
Good find. These events should not be cleared twice. Removing the update from gilrs is the correct way to fix this.
Incidentally, that system looks like it no longer need to be exclusive: we should fix that in the same PR.
AIUI systems that access non-send resources (like Gilrs
is) still need to be exclusive. Or if they don't, I didn't find the correct way to request access.
Nope, they'll work fine in ordinary systems :) Just use NonSend as a system parameter.
Bevy version
git master
What you did
Looked at the code (I'm playing around with building a custom mini engine using bevy ECS, for learning purposes).
What you expected to happen
Events::update
says it should be called once per tick, to manage the double buffer correctly.What actually happened
update
appears to be getting called twice per tick:bevy_input
callsadd_event::<GamepadEventRaw>
https://github.com/bevyengine/bevy/blob/99199338ad5e3d89d767f639ef4cd7b6da52ed83/crates/bevy_input/src/lib.rs#L65 and this registers theEvent::update_system
https://github.com/bevyengine/bevy/blob/99199338ad5e3d89d767f639ef4cd7b6da52ed83/crates/bevy_app/src/app.rs#L583-L589bevy_gilrs
'sgilrs_event_system
callsevent.update
on theEvents<GamepadEventRaw>
https://github.com/bevyengine/bevy/blob/99199338ad5e3d89d767f639ef4cd7b6da52ed83/crates/bevy_gilrs/src/gilrs_system.rs#L19-L23Additional information
It's possible I'm just misunderstanding what's going on here, but this seems wrong at first glance. At the very least, the
update
call inbevy_gilrs
probably deserves a comment calling out that it's a secondupdate
call in the simulation tick explaining why we want to discard the double buffer in this case.